#### Archived

This topic is now archived and is closed to further replies.

# Asteroid/spaceship logic

This topic is 6933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m trying to make a game where I have about 15 asteroids and a spaceship that has the ability to destroy asteroids. What would be a reasonably algorithm to use where I could have the asteroids attack the spaceship while giving it a chance to destroy the asteroids without being too easy.

##### Share on other sites
What do you mean?

Do you need to know how to make the asteroids move or what?

(Sorry if i sound angry, im not. im only tired)

========================
Game project(s):
www.fiend.cjb.net

##### Share on other sites
I know how to move the asteroids around, but what I''d like to do is have the asteroids appear as if the had some grudge against the spaceship without destroying it instantly.

##### Share on other sites
You could spawn them outside the screeen, making them head for the player (So that if the player doesent move, he gets killed).

========================
Game project(s):
www.fiend.cjb.net

##### Share on other sites
You could make the asteroids only head at the player when a certain random number is produced. That way, by setting a threshold for the random number you can control the difficulty. Ex: (my rand function works like this: rand(min, max)

if (rand(0, 10) < DifficultyLevel)
{
// seek human
}
else
// just keep drifiting on current course

This is similar to what I did with pong... to make the computer lose sometimes

--------------------

You are not a real programmer until you end all your sentences with semicolons;

##### Share on other sites
Just adding to the anon poster's logic with the asteroids "seeking the human" according to different levels of difficulty. You could make the asteroids seek the ship by doing some simple calculations.

if (ship.x < enemy.x)enemy.x--;else if (ship.x > enemy.x)enemy.x++;
Pretty self-explanatory. You probably won't need to do any y calculations since the asteroids will always be traveling in a downward fashion, so you'd keep on adding to the y coordinates.

Martin

Edited by - lpsoftware on 4/26/00 11:55:53 AM

##### Share on other sites
Thanks to everyone for their suggestions. Using the information that I''ve gathered, I will attempt to make my very first game in mode0x13(I know that mode13 is dead, but at least I won''t have to worry about the details of setting up directdraw ).

• 16
• 9
• 15
• 10
• 13
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!