peter
26-02-2014, 19:07
Hi,
A little bit ping-pong.
It is only an idea for a better ping-pong, later.
Uses "ui"
#INCLUDE "gdip.inc"
OpenWindow 320, 240
Canvas_Font "courier",16, %CANVAS_FONTSTYLE_BOLD
Long x, y, x2, y2, pspeed, xadj, yadj, delay, score
x=50 : y=50 : x2=130 : y2=150 : pspeed=4
xadj=2 : yadj=2 : delay=1
Long haha = LoadWav "wav/haha.wav"
Long pong = LoadWav "wav/pong.wav"
SetSmoothMode %SmoothingModeAntiAlias
While IsWindow(hwnd) And KeyDown(27)=0
ClsColor ARGB(50,0,0,0)
FillEllipse x,y,8,8,ARGB(255,255,255,255)
FillBox x2,y2,30, 4,ARGB(255,255,255,255)
DrawBox 20,20,290,160,2,ARGB(255,255,255,0)
DrawText 10,0,"SCORE: " + score,Rgb(255,0,0)
If y <=20 Then
yadj = 2
PlayWav pong
End If
If y >=180 Then
yadj = -2
PlayWav pong
End If
If x >=300 Then
xadj = -2
PlayWav pong
End If
If x <=20 Then
xadj = 2
PlayWav pong
End If
If KeyDown(37) And x2 > 18 Then x2=x2-pspeed
If KeyDown(39) And x2 <270 Then x2=x2+pspeed
x = x + xadj
y = y + yadj
If y > y2-7 And y2 < y2+2 And x < x2+30 And x > x2 Then
yadj = -2
score +=1
End If
If y > y2+10 Then
DrawText 100,200,"GAME OVER!",Rgb(0,255,55)
Playwav haha
Canvas_Redraw
Canvas_WaitKey(32)
score=0
x=50 : y=50 : x2=130 : y2=150 : pspeed=4
xadj=2 : yadj=2 : delay=1
End If
Canvas_Redraw
Sleep 10
Wend
Canvas_Window End
A little bit ping-pong.
It is only an idea for a better ping-pong, later.
Uses "ui"
#INCLUDE "gdip.inc"
OpenWindow 320, 240
Canvas_Font "courier",16, %CANVAS_FONTSTYLE_BOLD
Long x, y, x2, y2, pspeed, xadj, yadj, delay, score
x=50 : y=50 : x2=130 : y2=150 : pspeed=4
xadj=2 : yadj=2 : delay=1
Long haha = LoadWav "wav/haha.wav"
Long pong = LoadWav "wav/pong.wav"
SetSmoothMode %SmoothingModeAntiAlias
While IsWindow(hwnd) And KeyDown(27)=0
ClsColor ARGB(50,0,0,0)
FillEllipse x,y,8,8,ARGB(255,255,255,255)
FillBox x2,y2,30, 4,ARGB(255,255,255,255)
DrawBox 20,20,290,160,2,ARGB(255,255,255,0)
DrawText 10,0,"SCORE: " + score,Rgb(255,0,0)
If y <=20 Then
yadj = 2
PlayWav pong
End If
If y >=180 Then
yadj = -2
PlayWav pong
End If
If x >=300 Then
xadj = -2
PlayWav pong
End If
If x <=20 Then
xadj = 2
PlayWav pong
End If
If KeyDown(37) And x2 > 18 Then x2=x2-pspeed
If KeyDown(39) And x2 <270 Then x2=x2+pspeed
x = x + xadj
y = y + yadj
If y > y2-7 And y2 < y2+2 And x < x2+30 And x > x2 Then
yadj = -2
score +=1
End If
If y > y2+10 Then
DrawText 100,200,"GAME OVER!",Rgb(0,255,55)
Playwav haha
Canvas_Redraw
Canvas_WaitKey(32)
score=0
x=50 : y=50 : x2=130 : y2=150 : pspeed=4
xadj=2 : yadj=2 : delay=1
End If
Canvas_Redraw
Sleep 10
Wend
Canvas_Window End