Another Rectangle per hit
Blitz3D Forums/Blitz3D Beginners Area/Another Rectangle per hit
| ||
I would like to create ANOTHER rectangle (which has a different x location) every time the SPACE bar is hit, while showing the "CLICKS" variable. Everytime I press space, it deletes the old rectangle and replaces it with a new one. How do I keep all the old rectangles on screen? Graphics3D 800,600 boxx#=20 boxy#=50 boxwidth#=10 boxheight#=20 totalclicks=0 While Not KeyDown(1) Rect boxx#, boxy#, boxwidth#, boxheight#, 0 If KeyHit(57) boxx#=boxx#+10 totalclicks=totalclicks+1 EndIf Locate 20,20 Print "Current clicks=" + totalclicks Flip Cls Wend End |
| ||
If I was you I'd try using types.What your currently doing only adds +10 to X on your current box so its not even really "delteing it" its just moving it. |
| ||
SeedRnd Millisecs() Graphics 800,600 SetBuffer BackBuffer() Color 255,255,255 Type BoxObject Field X,Y,Width,Height End Type While Not KeyDown(1) CLS For Box.BoxObject=each BoxObject Rect Box\X,Box\Y,Box\Width,Box\Height,0 next If KeyHit(57) Box.BoxObject=new BoxObject Box\X=Rand(GraphicsWidth()) Box\Y=Rand(GraphicsHeight()) Box\Width=Rand(10,20) Box\Height=Rand(10,20) EndIf TEXT 0,0,"Current Clicks = " + totalclicks VWait:Flip False Wend Delete each BoxObject End Try something like that |