Computer Science Canada how do i move a paddle |
Author: | Doug101 [ Fri Apr 04, 2008 7:13 pm ] |
Post subject: | how do i move a paddle |
im having trouble making the paddle move. can someone show me wat im doing wrong!! var Key : array char of boolean var paddlex : int paddlex := 240 drawfillbox (paddlex-20, 20, paddlex + 140, 10, 9) loop Input.KeyDown (Key) if Key (KEY_LEFT_ARROW) then paddlex := paddlex - 5 end if if Key (KEY_RIGHT_ARROW) then paddlex := paddlex +5 end if end loop |
Author: | Nick [ Fri Apr 04, 2008 7:16 pm ] |
Post subject: | RE:how do i move a paddle |
you only draw the paddle once, move the draw inside the loop |
Author: | Doug101 [ Fri Apr 04, 2008 7:18 pm ] |
Post subject: | Re: how do i move a paddle |
i thought i did that thanks |
Author: | Doug101 [ Fri Apr 04, 2008 7:25 pm ] |
Post subject: | Re: how do i move a paddle |
when i put the code in my game it doesnt work!!! var Key : array char of boolean var ballx, bally, paddlex : int ballx := 320 bally := 200 paddlex := 260 drawbox (20,20,619,379,255) drawfill (1,1,255,255) drawfillbox (paddlex - 20, 20, paddlex + 140, 10, 9) put "score: " loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx += 1 bally += 1 exit when bally = 368 end loop loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx += 1 bally -= 1 exit when ballx = 608 end loop loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx -= 1 bally -= 1 exit when bally = 31 end loop loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx -= 1 bally += 1 exit when bally = 368 end loop loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx -= 1 bally -= 1 exit when ballx = 31 end loop loop drawfilloval (ballx, bally, 10, 10, 9) delay (5) drawfilloval (ballx, bally, 10, 10, 0) ballx += 1 bally -= 1 exit when bally = 31 end loop loop drawfillbox (paddlex-20, 20, paddlex + 140, 10, 9) delay(5) drawfillbox (paddlex-20, 20, paddlex + 140, 10, 255) Input.KeyDown (Key) if Key (KEY_LEFT_ARROW) then paddlex := paddlex - 5 end if if Key (KEY_RIGHT_ARROW) then paddlex := paddlex +5 end if end loop |
Author: | SIXAXIS [ Fri Apr 04, 2008 8:28 pm ] | ||||
Post subject: | Re: how do i move a paddle | ||||
First of all, your code is extremely messy. Try to keep it clean. Group things, comment on what everything is, put it in order. Secondly, you need to have one main loop. If you have many loops, then it will never finish the first loop so it can't go to the second one. So put all of your code in one loop and clean it up. P.S. You may have flickering. If you do, then add this at the beginning of your code:
The graphics part tells the computer that it's in graphics mode, the 800;600 sets the window size (in pixels), and the offscreenonly is the important part. It tells the computer to draw everything offscreen. Add this at the end of your main loop. This is what makes the computer draw everything it made offscreen all at once so there is no flickering.
Look up setscreen in the F10 help and you'll see you can do a lot more than just this. |