Jump to content

  • Log In with Google      Sign In   
  • Create Account

Implementing beams for space shooter


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ElDuro   Members   -  Reputation: 560

Like
0Likes
Like

Posted 30 June 2013 - 03:02 PM

-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.



Sponsor:

#2 Sik_the_hedgehog   Crossbones+   -  Reputation: 1833

Like
0Likes
Like

Posted 30 June 2013 - 03:39 PM

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.

#3 ElDuro   Members   -  Reputation: 560

Like
0Likes
Like

Posted 30 June 2013 - 06:44 PM

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.



#4 LorenzoGatti   Crossbones+   -  Reputation: 2763

Like
0Likes
Like

Posted 01 July 2013 - 02:00 AM

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.
Produci, consuma, crepa

#5 ElDuro   Members   -  Reputation: 560

Like
0Likes
Like

Posted 23 July 2013 - 04:12 PM

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;






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS