sprite movement (paths)

hello there! I’m finishing a simple space game. I wanna add different movements for my aliens. Today they are moviming in a very simple way: like space invaders… I was thinking to change this behaviour to make aliens move along a sine or bezier curves… what do u think? any tips? code?

The game is top-down scroller

Is this a top down scroller where the enemy ships will fly on past you if not destroyed? Can the ships turn around? Do you want to program preplanned flight paths, randomize it, or give them some ai?

A lot of games will give an enemy some kind of velocity factor and then adjust the left/right movement as it travels. It could make those more interesting if you threw some trig in there, but I wouldn’t think it would be necessary. Assuming the ships have a constant velocity you could slide it right +1 for 10 frames then slide it back -1 for the next 10 frames and so on.

A couple other random thoughts: You could try giving each type of a ship an aggression level and then use that to determine how close the ship will attempt to fly to the player. It’s also pretty common to see ships paired up where one fly downs on one side and the other uses a similar inverted path on the other side.

(But now I’m talking ships and youre talking aliens so maybe I didn’t catch the drift of your game)

[quote]Is this a top down scroller where the enemy ships will fly on past you if not destroyed? Can the ships turn around? Do you want to program preplanned flight paths, randomize it, or give them some ai?]
[/quote]
Yes the aliens fly on and cannot turn around. And yes I was planning to make some preplanned flight paths, initially, but after I will try to add some AI. How could I add some preplanned flight paths?

[quote](But now I’m talking ships and youre talking aliens so maybe I didn’t catch the drift of your game)
[/quote]
No problem, they are great ideas, but first I wanna do some simple things.

[quote]Yes the aliens fly on and cannot turn around. And yes I was planning to make some preplanned flight paths, initially, but after I will try to add some AI. How could I add some preplanned flight paths?
[/quote]
Most shoot’em ups (with Galaga being a prime example) use a state machine for the purpose of AI. How it works is that the character entity has a state associated with it, then behaves differently based on the state.

Let’s use Galaga as an example. Each ship has three states, with one optional, extra state for the crab ships:

PATH
FORMATION
DIVING
TRACTOR (optional)

When the ships first fly onto the screen, they are in the PATH state. In this state, they follow whatever path is laid out for them. (This path could even be precalculated.) Once they reach the end of the path, they automatically switch to FORMATION state and take their respective places.

From there, some sort of algorithm (whether it be pre-planned or random) decides to occasionally place ships in the DIVING or TRACTOR state. If a ship receives the state DIVING, it begins a dive manuver aimed at the player. This might be as simple as incrementing X and Y until the ship reaches the player, or it might be a curved trajectory designed to confuse the player.

If a crab ship receives the TRACTOR state, it makes a descent and activates its tractor beam. Once the TRACTOR or DIVING state is complete, the ship returns to FORMATION state and makes its way back to the FORMATION at the top of the screen.

Sounds like the concept of states would be a great way to go. I haven’t really worked with that idea before but you could put together a wide variety of scripts. At some point in time you tell that enemy to begin script x,y, or z.

So you’d have scripts like:
Suicide run,
Shoot then Dive,
Shoot and move on,
Enclose (fly next to but not into player),
Random flight,
etc

This would be a lot easier to design than giving ships ai. And you wouldn’t need to create precalculated flight paths since each script is more or less the instructions of what to do.

I’m not sure how that FORMATION state would work. I’m guessing it’s something like if the ship is in formation spot 3 then fly the same flight path as the ship in formation spot 2 and so on.

Hi,

The FORMATION state is when the ship/alien oder in group… SPACE INVADERS has all its aliens in FORMATION state all the time!

Rafael.-

tks a lot jbanes. You cleared my mind. Do u know where can I find some code? I will try something.