game just exits

Started by
3 comments, last by da_cobra 22 years ago
I'm trying to create a breakout clone and for the moment I'm stuck at the multiball part first I started with a structure for my ball

struct position
{
	float iPosX ;
	float iPosY ;
	float iVelX ;
	float iVelY ;
	float iWidth ;
	float iHeight ;
	bool bState ;
} ;
  
then I declared it : position ball ; so I could use it this way : ball.iPosX, ball iPosY, ...... so I started on the multiball code, and I thought why not just declare it as an array and check if the ball is still alive or not? so : position ball[4] ; and for the begining only ball[0].bState is true, so I just have 1 ball when the multiball mode is activated I set all the states to true and process all my balls now the problems start my game just exits without an error and since I only added the multiball part I guess it has something to do with me declarng an array for my balls position ball[4] ; after I bit of searching I found out that my program only exits when I try to use that array for example :

// Blit the balls
	for (int b; b<4; b++)
	{
		if (ball.bState == true)
		{
			// make the current copy position for the source 
			SetRect(&src, 0, 0, 16, 16) ; // SetRect( &src, left, top, right, bottom );
			// make the current paste position for the destination 
			SetRect(&dest, (int)ball.iPosX, (int)ball.iPosY, (int)(ball.iPosX+ball.iHeight), (int)(ball.iPosY+ball.iHeight)) ;
		} // end of if
	} // end of for b
	// now just blit the source cube to the destination cube
 </pre> 

can some1 pls help me

thanx in advance

<SPAN CLASS=editedby>[edited by - da_cobra on April 5, 2002 1:28:22 PM]</SPAN> </b>    
Advertisement
without seeing the rest of your code this is tough. stupid question, but are you sure you aren't doing something like trying to access:

ball[4];

ball[3] being the last good value for that array.

or at this point do you only have the varaible decleration in place with no logic there trying to access the array items?

if the latter can't suggest anything else w/out more code

-me

[edited by - Palidine on April 5, 2002 1:29:44 PM]
[EDIT:: Removed, because you had answered it while I was posting]

John B

[edited by - JohnBSmall on April 5, 2002 1:32:22 PM]
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
aaarrrrggggghhhh damn

by editing my first post and then looking at it I found my mistake

and yes Palidine you were right

for ever1 that doesn''t see the mistake :

for (int b; b<4; b++)

stupid me !!!!!!!!
nice inclusion of code:

correct me if i''m wrong but i don''t think you can say:

for (int b; ...

i''m pretty sure you always have to say:

for (int b = 0; ...


i don;t think you are guaranteed that b will be zero if you don''t initialize it as such.

so looks like you end up just trying to access some random position of the array that is more likely than not to be outside the boundaries of the array

-me

This topic is closed to new replies.

Advertisement