Re: bgt, having trouble with classes, again
It looks like you aren't storing the walls you're creating. If I understand the code correctly, the newgame function does this:
assign shipx, shipy, and speed (global variables)
play the engine sound, and assign its slot number to the global variable engine
Create a local variable i, initialize it to 0
Since i is less than 6500, do the following:
create a local variable called barrier, that is a wall with random parameters.
delete barrier, since this iteration of hte loop is complete.
increment i.
repeat the last 4 lines until i is 6500 (Incidentally, that is a lot of objects and the sound pool will probably explode.)
delete i, since the loop is complete.
Create a local wall variable.
Call gameloop.
Delete barrier
The barrier variable created inside newgame (or inside the loop) cannot be accessed by any other functions. You probably want a global variable--in this case, probably an array or dictiona
ry--to hold all the walls created in the loop.
Try taking the line
wall barrier(50, 350, 0);
And either putting it outside the function, putting it at the start of gameloop, or splitting it into three lines:
wall@ barrier; //outside of any functions or classes.
// inside newgame:
wall temp(50, 350, 0);
@barrier=temp;
I think BGT will complain about the last one, because something something constructors. It'd be easier just to move wall barrier(50, 350, 0); into a different scope.
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector