Sign in to follow this  

Side scrolling shoot em up!

This topic is 4866 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 currently writing a shoot em up and was wondering the best way to get the 'baddies' to fly around the screen (as in r-type, for example). I need to be able to set paths for them to follow...what's the best way to do this? I'm working in C++ by the way, if that makes a difference... thanks for any suggestions! :)

Share this post


Link to post
Share on other sites
I'm working on this exact 'problem' now with Manta-X.

A simple way of doing things would be to have a small state machine inside each of the enemy ships. The states would simply be an array of bytes which correspond to MOVE_UP, MOVE_DOWN, MOVE_LEFT (or THRUST_FWD), MOVE_RIGHT (or THUST_BACK), FIRE_GUNl, etc. You could then write a simple system which essentially sets these bytes during the game. So for example, you'd create an event type system which would feed a MOVE_UP event at 1 second, a THRUST_FWD event at 1.5 seconds etc, and the ship would continue that motion until the event is cancelled (eg: state[THRUST_FWD] = 0). I did this with the first iteration of Manta-X and it proved to be simple, yet effective.

I'm currently working on a more sophisticated pathing system in which you attach a range of control point nodes (eg: node at 0,0, node at 10,10) and a PathNavigator which will output the motion for that particular frame based on the position in the path. I can see myself combining the two methods so I can have scripted path motion with a simple state machine for firing and other methods the enemies might wish to engage in.

Share this post


Link to post
Share on other sites
my suggestion is to base their paths on trigonomic functions ... something like this ...

y = screenHeight * SIN (magnitude * x);
x ++;

this will give whatever is at (x, y) a wavy pattern, try using sin, cos, and tan and just substitute different values in and see what you get ... as for more complex patterns, like enemies going in circles and what not you can use some other formulas aswell ...

(x + a)^2 + (y + b)^2 = radius
... i think this is the circle formula, someone correct me if i'm wrong ...
or again you can use trigonomic functions ...

x = height * COS (magnitude * T);
y = height * SIN (magnitude * T);
T ++;

as we see in old school commercial games, the enemies move in a circle then maybe in a wavy pattern then back into a circle ...
i'm not sure how exactly they do it, but you can probably accomplish this by doing something like this ...

- save old x and y co-ordinates
- move enemy in circle
- when enemy is at old x and y co-ordinates
- change pattern to a wavy pattern
- reapet however you want ...

i hope some of this helped

Share this post


Link to post
Share on other sites
Thanks guys, some useful info there. I'll read up on state machines (remember reading about them a while ago I think...) and have an experiment with those trig functions. I'd love to see the source code for some of those old console shooters (gradius, thunderforce, etc) to see how they used to do those things! :) Think Konami will release some to me? hehe, no, I didn't think so...

Share this post


Link to post
Share on other sites

This topic is 4866 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this