Jump to content
  • Advertisement

Archived

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

boolean010

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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;

Yanroy@usa.com

Visit the ROAD Programming Website

Share this post


Link to post
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 this post


Link to post
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 ).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!