PDA

View Full Version : jumping Frogs



peter
16-10-2012, 23:28
Hi,


Uses "ui","math"


DWord hdc,hwin
hwin=Canvas_Window("Jumping Frogs",1,1,800,600)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("comic",16,%CANVAS_FONTSTYLE_BOLD)
Randomize Timer


Type pType
x As Long
y As Long
LifeSpan As Long
Xv As Single
Yv As Single
End Type


Long Xstart,Ystart,i,width,height,iMax
width=800:height=600:iMax=600
Dim pc(iMax) As pType


pcInit()
While IsWindow(hwin)
Canvas_Clear(0)
For i=1 To iMax
Canvas_Circle(pc(i).x,pc(i).y,28,&hFFFFFF,Rgb(0,255,0))
Canvas_Circle(pc(i).x-20,pc(i).y-6,14,&hFFFFFF,Rgb(0,128,25))
Canvas_Circle(pc(i).x+20,pc(i).y-6,14,&hFFFFFF,Rgb(0,128,25))
Canvas_Circle(pc(i).x,pc(i).y+12,6,&hFFFFFF,Rgb(255,0,0))
pc(i).x =pc(i).x + pc(i).Xv
pc(i).y =pc(i).y + pc(i).Yv
pc(i).Yv =pc(i).Yv + 1.79
If pc(i).y >= Height Then
pc(i).Yv = -(pc(i).Yv *.66)
pc(i).y = Height
End If
pc(i).LifeSpan = pc(i).LifeSpan -1
If pc(i).LifeSpan <=0 Then
pc(i).LifeSpan = Rnd(1,500)
pc(i).x = Xstart
pc(i).y = Ystart
pc(i).Yv = Rnd(1,4)
pc(i).Xv = Rnd(1,8)
End If
Next
SetText(500,32,"JUMPING FROGS",&hF8C8C8,0)
Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
Sleep 10
Wend
Canvas_Window End


Sub SetText(x,y As Long, txt As String, xkol,ykol As Long)
Canvas_Color(xkol,ykol)
Canvas_SetPos(x,y)
Canvas_Print(txt)
End Sub


Sub pcInit()
Xstart=Width \10
Ystart=Height \10
For i=1 To iMax
pc(i).LifeSpan = Rnd(1,500)
pc(i).x = Xstart
pc(i).y = Ystart
pc(i).Yv = Rnd(1,4)
pc(i).Xv = Rnd(1,8)
Next
End Sub

omarpta
17-10-2012, 16:08
Very Nice and psychedelic!

Petr Schreiber
17-10-2012, 17:50
Ha ha, nice!


Petr