peter
18-10-2012, 13:49
Hi,
Uses "ui","math"
DWord hdc,hwin
hwin=Canvas_Window("Newton",1,1,300,310)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)
Single yacc, yvel, xvel, x, y, r
yacc=.98: yvel=-10: xvel=10: x=20: y=100: r=20
While IsWindow(hwin)
Canvas_Clear(Rgb(0,0,255))
yvel=yvel+yacc
y=y+yvel
x=x+xvel
If y >289 Then
yvel = -0.9*yvel
y=289
xvel=xvel*0.9
End If
If x >285 Then
xvel = -xvel
x =285
End If
If x<10 Then
xvel = -xvel
x = 10
End If
Canvas_Circle(x,y,r,0,&hF9CAFD)
If xvel*xvel <0.0001 Then Exit While
SetText(40,8,"Newton Let's Go!",Rgb(255,255,255),&hFF0000)
Canvas_Redraw
Sleep 10
Wend
SetText(80,100,"HIT ESCAPE",Rgb(255,255,255),&hFF0000)
Canvas_Redraw
While IsWindow(hwin)
If GetAsyncKeyState(27) Then Exit While
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
Uses "ui","math"
DWord hdc,hwin
hwin=Canvas_Window("Newton",1,1,300,310)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)
Single yacc, yvel, xvel, x, y, r
yacc=.98: yvel=-10: xvel=10: x=20: y=100: r=20
While IsWindow(hwin)
Canvas_Clear(Rgb(0,0,255))
yvel=yvel+yacc
y=y+yvel
x=x+xvel
If y >289 Then
yvel = -0.9*yvel
y=289
xvel=xvel*0.9
End If
If x >285 Then
xvel = -xvel
x =285
End If
If x<10 Then
xvel = -xvel
x = 10
End If
Canvas_Circle(x,y,r,0,&hF9CAFD)
If xvel*xvel <0.0001 Then Exit While
SetText(40,8,"Newton Let's Go!",Rgb(255,255,255),&hFF0000)
Canvas_Redraw
Sleep 10
Wend
SetText(80,100,"HIT ESCAPE",Rgb(255,255,255),&hFF0000)
Canvas_Redraw
While IsWindow(hwin)
If GetAsyncKeyState(27) Then Exit While
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