- [Axe] Making Pong
- 17 Sep 2012 02:52:57 pm
- Last edited by Charty on 17 Sep 2012 02:54:21 pm; edited 1 time in total
So far in my code it worked fine, until I added the collision with the paddles. Now it won't bounce off the ceiling and floor.
Code:
Code:
.PONG
28->A
28->B
44->X
28->Y
rand^4->D
[COCOCOCOCOCOCOCO]->Pic0
[0303030303030303]->Pic1
[3C7EFFFFFFFF7E3C]->Pic2
Repeat getKey(15)
DispGraphClrDraw
Pt-On(94,A,Pic0)
Pt-On(65530,B,Pic1)
Pt-On(X,Y,Pic2)
Line(0,0,95,0)
Line(0,63,95,63)
[Movement code]
[AI Movement Code]
.Ball Movement
If D=0
X--
Y--
End
If D=1
X--
Y++
End
If D=2
X++
Y--
End
If D=3
X++
Y++
End
If pxl-Test(X,Y+8)=1
If D=1
0->D
Else
2->D
End
End
If pxl-Test(X,Y-1)=1
If D=0
1->D
Else
3->D
End
End
If pxl-Test(X+8,Y+3)=1
If D=3
1->D
Else
0->D
End
End
If pxl-Test(X-1,Y+3)=1
If D=0
2->D
Else
3->D
End
End
[Ball reset code]
Pause 50
End