Do you mean something like this:
Graphics 320,240,16,2
Global thebuffer=BackBuffer()
SetBuffer thebuffer
AutoMidHandle True
Type dkey
Field kx#
Field ky#
Field v#
Field age
End Type
Global drop.dkey
Function DropKey(x#,y#) ;pay attention to this here too
drop.dkey=New dkey
drop\kx#=x#
drop\ky#=y#-180
drop\v#=0
drop\age=y#
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\age
;I rewrote your whole routine added another variable (v#) to the type
; age = location of shadow
; kx = X location on screen
; ky = current Y location on screen
; v = vector amount object is to fall
drop\ky#=drop\ky#+drop\v#
If drop\ky#>drop\age Then
drop\v#=(drop\v#)*-.3 ;change this number for more/less bounceing
drop\ky#=drop\age
Else
drop\v=drop\v+.1
End If
DrawImage chest_keys,drop\kx#,drop\ky#
Next
End Function
Change that -.3 to something else between -1 and 0 for different bounce hieghts and such.
|