# Hyper

Member Since 13 Mar 2009
Offline Last Active Apr 04 2013 07:58 AM

### In Topic: How do i implement bullets?

04 April 2013 - 07:52 AM

fireside, on 28 February 2013 - 11:22 PM, said:

For a vector in c++ you use erase. I meant iterate through and delete one bullet that's off screen each loop.

int found = -1;
for(int i =0; i < bullets.size;i++)
{
if(bullets[i].y<500) // move code;
else found = i;
}
if(found > -1) bullets[found].erase;


or make it invisible or whatever.
Otherwise you could put the off screen bullets at the front and iterate at a higher starting number each time one went off screen, or at the back an stop iterating earlier. For that matter, there's about a million ways you could do it and why am I suggesting anything?
Pardon me, but that's an odd way to solve the problem, I think!

This is more or less how I solved it (in English):
I created a self-contained entity (a "bullet"), and assigned that to a "gun," and assigned that to a "player."
The gun can fire a bullet (if it contains any). The bullet will update it's own position. The bullet knows when it has been "fired."
The bullet also knows when to quit updating itself (due to an 'out-of-range' issue). That's about it!

An example of this (horray YouTube) in action:

Of course: The specifics of what library (if any) that you're using don't really apply here.
I figure if you're going to use C++: Why not do it in a C++-fashion (with objects)?

Yes! I am implying C++ should be more object-oriented. It's a beautiful feature for solving these type problems.

From a pure coding point, this is all that exists in the code that carries any real weight:
player.at(3).gun.loadRound(99);

Player "3" is the yellow box.

### In Topic: Space Retards

25 January 2013 - 05:29 AM

touch_the_sky, on 14 January 2013 - 06:57 PM, said:

A short gameplay vid:

Also, the points normally don't go up this fast
I can't help but notice: That looks like a very retarded game.

Can't wait to see the student faculty (anti) power-ups, and other bits to come to life!