Computer Science Canada Urgent! |
Author: | xzecution2 [ Mon Jan 19, 2009 9:39 pm ] | ||||
Post subject: | Urgent! | ||||
Hi, so I'm creating a program that needs a ship to have AI and all i need it to do is to be able to move randomly across the x-axis and shoot downwards randomly. here's an excerpt from my code that makes the ship.
Mod Edit: Remember to use syntax tags! Thanks ![]()
|
Author: | Insectoid [ Mon Jan 19, 2009 9:41 pm ] |
Post subject: | RE:Urgent! |
First, use code tags. Second, title your thread descriptively; 'urgent' tells us nothing of your problem. |
Author: | xzecution2 [ Mon Jan 19, 2009 9:45 pm ] |
Post subject: | RE:Urgent! |
sorry about that, I don't think i'll be able to edit it now though since you can't edit posts that have been replied to. |
Author: | DemonWasp [ Tue Jan 20, 2009 1:02 am ] | ||
Post subject: | RE:Urgent! | ||
I'm assuming that you have: Player (basic player, not used on its own) HumanPlayer extends Player (the human, controlled by the keyboard) AIPlayer extends Player (the computer) Then you need to add a method (let's call it "update") to Player, overridden by AIPlayer, which runs the AI to determine what to do. In HumanPlayer, update() checks the keyboard for input and moves that player. Then your main game loop looks like this:
|