It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming C and C++ Forum

Projectiles

Projectiles

Postby instinct46 on Sun Aug 16, 2009 3:29 pm

I'm in the middle of creating projectiles in a few games, and as far I can tell it should be working but its not :(

I've created a two dimensional int array, with 5 colomns and 100rows more than enough for what I want.
col 1 = is it use or not
col 2 = x location
col 3 = y location
col 4 = x movement, this can be a minus or positive number
col 5 = y movement, same as above

Right when my player presses the space key, the program loop and checks array[loop][0]
and check for the first one which is equal to zero (not in use).

Once a projectile collides with something or goes of the screen I zero it attributes, to make it well not in use.

Yet for some reason after its fired to what I can only presume to be 100 due its max, it either doesn't work or sometimes works but sends the projectiles on a random reappearing act on the screen =/

I suppose what my question really is, am I using the two dimensional array for something it will never be able to handle?? and has anyone got any ideas on how to create an alternative table??

O just to note as well have created a two dimensional pointer array and that never worked either =/
User avatar
instinct46
50+ Club
 
Posts: 90
Joined: Tue Mar 27, 2007 1:07 pm
Location: St Helens, England

Re: Projectiles

Postby instinct46 on Mon Aug 17, 2009 5:22 pm

I have worked my little problem above, and am just writing just post how I did it just encase anyone else gets a similar problem.

Instead of using a two dimensional array:

int myArray[50][50];

I created an array of a structure I built:

struct projectiles{
int onoff;
int x;
int y;
int xm
int ym;
int width;
int height;
} everyProjectile[MAX_BULLETS];


So them I could still use all my equations, I just had to replace all:
with smallLoop being a int I was using along side my for(loops)

replace: myArray[smallLoop][0]
with : everyProjectile[smallLoop].onoff

I still have no idea why the 2Darray never worked but mneh
User avatar
instinct46
50+ Club
 
Posts: 90
Joined: Tue Mar 27, 2007 1:07 pm
Location: St Helens, England


Who is online

Users browsing this forum: No registered users and 0 guests