I've cut the code ive got a problem with into this little program:
I Want this image (key) to Bounce as it lands, but when the object hits the ground,
it either dissapears, or moves rigidly up:::why?
My Parabola is perfect (as is proven by this little program):
I Want this image (key) to Bounce as it lands, but when the object hits the ground,
it either dissapears, or moves rigidly up:::why?
Graphics 320,240,16 Global thebuffer=BackBuffer() SetBuffer thebuffer AutoMidHandle True Type dkey Field kx# Field ky# Field age End Type Global drop.dkey Function DropKey(x#,y#,age=-180) drop.dkey=New dkey drop\kx#=x# drop\ky#=y# drop\age=age End Function ;I've replaced the keys with Red Blocks for this (they have blue shadows) global keys_shadow=Createimage(4,3) ;Loadimage("key_shadow.png") setbuffer imagebuffer(keys_shadow) color 0,0,255 rect 0,0,4,3 global chest_keys= Createimage(4,8) ;Loadimage("key.png") setbuffer imagebuffer(chest_keys) color 255,0,0 rect 0,0,4,3 SetBuffer thebuffer const RETURN_key=28 While not keyhit(1) cls ;press Return to Create a key object if keyhit(RETURN_key) DropKey(Rand(20,300),200+Rand(-20,30)) update_Key_items() vwait:flip false wend end Function update_Key_items() For drop.dkey=Each dkey DrawImage keys_shadow,drop\kx#,drop\ky# If drop\age<0 drop\age=drop\age+1 DrawImage chest_keys,drop\kx#,drop\ky#+3*drop\age ElseIf drop\age<60 DrawImage chest_keys,drop\kx#,drop\ky#+(Float#((drop\ky#-60)*(drop\ky#))/45) drop\age=drop\age+1 Else DrawImage chest_keys,drop\kx#,drop\ky# If rectsoverlap(Charx-8,Chary-8,16,16,drop\kx-8,drop\ky-8,16,16) inkeys=inkeys+1 Delete drop.dkey EndIf Next End Function
My Parabola is perfect (as is proven by this little program):
For t=1 To 60 Print ((Float(t)-60)*(Float(t)))/20 Next Input() End