Implementing beams for space shooter

Started by
3 comments, last by phirekid718 10 years, 8 months ago

-first ten seconds

What is the idea behind both kinds of beams on the player?

Two approaches come to mind. The first one seems like a long, animated sprite that is drawn on top of a ray cast and cropped off at the first collision.

The side beams look like a chain of small images where the each link moves slightly slower than the one behind it.

I am not sure though so any insight will be very much appreciated.

Please and thank you.

Advertisement

It's even simpler than that actually: the beam is made out of many tiny objects (each its own sprite). When an object is shot, first it checks if there's a collision, and if not, it spawns another object right after it (making a trail), and so on until they go off-screen.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Is that both of them (blue and green)? I can't see the individual sprites in the blue beam. And what is the logic behind the sprites in the green beam? Does each sprite follow the one preceding it? And how is it that both beams keep their stream-like fashion no matter how the player moves? Thanks again.

Is that both of them (blue and green)?

I suppose you mean the large beam and the side ones? I didn't watch the whole video.

I can't see the individual sprites in the blue beam.

The big beam could be just an animated, moving axis-aligned rectangle. Technically, there are multiple approaches that would look identical, for example one big texture mapped rectangle with animated texture coordinates or several perfectly tiled and moving replicas (maybe a triangle strip) of a large sprite containing one "wave".

And what is the logic behind the sprites in the green beam? Does each sprite follow the one preceding it? And how is it that both beams keep their stream-like fashion no matter how the player moves? Thanks again.

The small "beams" contain very fast large sprites which appear to be aimed at a point about one screen height ahead of the player's ship, fixed speed and not guided; they form streams because they are emitted so fast that the player cannot move far enough for consecutive ones to lose overlap. Compare to the bursts of fast and straight projectiles shot by some of the bosses in the video: with larger sprites they would look like beams too.

Omae Wa Mou Shindeiru

Thanks a trillion. I implemented the beam as a long animated texture that gets "cropped" based on a ray cast. If the ray cast intersects with a fixture then it renders a explosion sprite on top of it. The green projectiles are simply bullets shot at a fast speed as said earlier. However, the orbs (the white things that shoot the green projectiles) get their position from the player's position some x frames before.

Some pseudocode:

const int delay = 10;

//orbPosition is playerPosition at ten frames before player's currentPosition

VectorClass pastPositions [delay];

//update index once per frame

int index = 0;

orbPosition = pastPositions[index] + offset;

pastPositions[index] = currentPlayerPosition;

This topic is closed to new replies.

Advertisement