I am currently developing a simple game and have a question about pointers.
I have created the following struct which contains information about the sprites I am using:
typedef struct SPRITE
{
CGapiSurface *surface;
signed int xpos;
signed int ypos;
DWORD direction;
DWORD speed;
} SPRITE;
I then use this struct in an array of size 10.
In the processnextframe function I have 2 game states. In the first state I want to draw the first 5 sprites from the array - so I have used a for loop from i=0 to i<5.
In the second state I want to draw the last 5 sprites so I have used a for loop from i=5 to i<10.
Initially this appears to work fine, when I move from state 1 to state 2. However when I move back from state 2 to state 1 my game exits - I assume this is a null pointer exception of some sort but I don't know why.
Any advice would be greatly appreciated.
Thanks.
I have created the following struct which contains information about the sprites I am using:
typedef struct SPRITE
{
CGapiSurface *surface;
signed int xpos;
signed int ypos;
DWORD direction;
DWORD speed;
} SPRITE;
I then use this struct in an array of size 10.
In the processnextframe function I have 2 game states. In the first state I want to draw the first 5 sprites from the array - so I have used a for loop from i=0 to i<5.
In the second state I want to draw the last 5 sprites so I have used a for loop from i=5 to i<10.
Initially this appears to work fine, when I move from state 1 to state 2. However when I move back from state 2 to state 1 my game exits - I assume this is a null pointer exception of some sort but I don't know why.
Any advice would be greatly appreciated.
Thanks.