Okay, so I'm working on a pong game and I've got a pretty good start so far, so here's how this special version of pong works:
The ball is served up every time, the user, the only user has to try and move their paddle to make sure the ball doesn't get passed it. If it does, it's game over, if not, then it serves again and the game keeps going.
Now, here are the problems I've been having:
I just added in the ball, it works fine… Kind of, now whenever I press the left or right arrow keys to move my paddle, I get err:domain for some reason. Also, even though which direction the ball goes isn't randomized at all, the speed it goes up isn't even randomized, sometimes the ball will mysteriously move down instead of up. Here's my code:
AxesOff Lbl B ClrDraw 1->Q //This variable makes the ball go faster or slower 31->X //starting X coord of ball 47->Y //starting Y coord of ball (rand-0.5)*3->T //This is the angle at which the ball moves every frame, for instance, if this number were to come out as 2, the ball would move 2 pixels on the X axis every frame 0->E //Paddle velocity -1->A //Paddle X position -1->w //Old paddle x position Lbl A A+(E/3)->A X+(T/Q)->X Y+(1/Q)->Y If abs(abs(a)-abs(w))>0.3 Then ClrDraw a->w End If not(e=0) Then e/2->e End getKey->U If U=26 and E<4 Then E+2->E End If U=24 and E>-4 Then E-2->E End Pxl-Off(round(X-(T/Q),0),round(Y-(1/Q),0) Pxl-On(round(X,0),round(y,0)) Line(A,10,A+2,10) Goto A