I've been messing about with types, and having quite a bit of fun with them also. The thing is, I decided to make a little 'snow falling from the sky' program using them.
The thing is when the snow gets to the bottom of the screen, the program pops up with a 'Memory access violation' error. I think I figured out where I went wrong. It's the delete particle thing. The problem is all the things I tried with it (moving the code about etc..), it either freezes on me when it hits the bottom, or whole screen goes blank (although the program still runs).
Does anyone have any ideas?
Type snow ;set up type for the snow Field x ;horizontal position of snow Field y ;vertical position of snow Field landed ;if the snow is landed Field collide ;if the snow has collided with another ex-snow on the floor End Type Type count ;set up type to remember where the deleted snow was Field y ;vertical position of deleted snow End Type Graphics 800,600,0,2 SetBuffer BackBuffer() ;usual business While Not KeyDown(1) ;while ESC isn't pressed Cls sparticle.snow= New snow ;make new snow particle sparticle\x=Rnd(0,800) ;at a random place sparticle\y=Rnd(-6,-4) ;just out of the top of screen sparticle\landed=False ;which hasn't landed yet sparticle\collide=False ;or not collided with snow on the floor For sparticle.snow=Each snow ;for each snow particle sparticle\x=sparticle\x+Rnd(-1,1) ;move it left or right sparticle\y=sparticle\y+1 ;move it down If sparticle\y=601 ;if snow particle goes below the screen sparticle\y=sparticle\y-1 ;move it up a bit sparticle\landed=True ;and say it's landed EndIf If sparticle\landed=True ;if it's landed Rect sparticle\x,sparticle\y,2,2,1 ;draw a fake snow particle at it's position memory.count= New count ;make a new holder to store it's y position memory\y=sparticle\y ;store it's y position Delete sparticle ;and delete the particle EndIf If sparticle\collide=False ;if a snow particle isn't collided yet For memory.count=Each count ;double check by checking all the ex-snow postions If memory\y=sparticle\y ;if the snow is in the place of an ex-snow (R.I.P) sparticle\y=sparticle\y-1 ;move it up a bit sparticle\landed=True ;and say it's landed EndIf Next EndIf Rect sparticle\x,sparticle\y,2,2,1 ;draw the particle Next Flip ;and flip the buffer Wend End
The thing is when the snow gets to the bottom of the screen, the program pops up with a 'Memory access violation' error. I think I figured out where I went wrong. It's the delete particle thing. The problem is all the things I tried with it (moving the code about etc..), it either freezes on me when it hits the bottom, or whole screen goes blank (although the program still runs).
Does anyone have any ideas?