Computer Science Canada colision with walls |
Author: | magicman [ Tue Apr 06, 2004 9:40 am ] |
Post subject: | colision with walls |
i'm making pong and i need to make the ball go off the wall. How can i do that? here's my code: [code] View.Set ("graphics") drawfill (0, 0, 17, 17) var x : int := 15 %Player 1 var y : int := 160 %Player 1 var x1 : int := 630 %Player 2 var y1 : int := 160 %Player 2 var z : int := maxx div 2 %Ball var a : int := maxy div 2 %Ball var changex := 5 var changey := 5 var chars : array char of boolean loop View.Set ("offscreenonly") View.Update cls %player 1 Draw.ThickLine (x, y, 15, y + 100, 3, 0) delay (10) %Player 2 Draw.ThickLine (x1, y1, 630, y1 + 100, 3, 0) Input.KeyDown (chars) %Player 1 if chars ('w') then y := y + 10 end if if chars ('s') then y := y - 10 end if %Player 2 if chars (KEY_UP_ARROW) then y1 := y1 + 10 end if if chars (KEY_DOWN_ARROW) then y1 := y1 - 10 end if %Ball drawfilloval (z, a, 10, 10, 0) drawfill (z, a, 0, 0) delay(10) drawfilloval (z, a, 10, 10, 0) drawfill (z, a, 0, 0) %Side Lines drawline (0, 3, maxx, 3, 0) drawline (0, maxy - 3, maxx, maxy - 3, 0) end loop thanks. |
Author: | TheFerret [ Tue Apr 06, 2004 2:01 pm ] | ||
Post subject: | |||
You would need this before the part where x and y change...
You would do the same for y... |