Computer Science Canada

i need help with a game

Author:  Womble [ Mon Jan 15, 2018 2:34 pm ]
Post subject:  i need help with a game

so im trying to make a simple game where you doge objects coming towards you. How could i make it show multiple objects coming at me at once and how could i make it detect that i got hit if anyone could help that would be great Very Happy

code:

setscreen ("graphics:800;600")
var chars : array char of boolean
var x, y : int
var enemyy1, enemyy2 : int
var enemyx1, enemyx2: int := 0
enemyy1 := Rand.Int (20, 600)
enemyy2 := Rand.Int (20, 600)
x := 700
y := 300

loop
    Input.KeyDown (chars)
    % move character
    if chars (KEY_RIGHT_ARROW) then
        y := y + 5
    end if
    if chars (KEY_LEFT_ARROW) then
        y := y - 5
    end if
    %character
    drawoval (x, y, 10, 10, red)
    %enemy
    drawoval (enemyx1, enemyy1, 10, 10, blue)
    drawoval (enemyx2, enemyy2, 10, 10, black)
    delay (20)
    cls
    enemyx1 := enemyx1 + 3
    enemyx2 := enemyx2 + 3
    put enemyx1
    put enemyx2

end loop

Author:  TokenHerbz [ Tue Jan 16, 2018 9:48 pm ]
Post subject:  RE:i need help with a game

i meant to click the other post, i'll revisit this, dont see a delete,

**Okay so i read your question, and the simple answer is arrays. take a look here to learn more!! --> http://compsci.ca/v3/viewtopic.php?t=14333

and check out this post on collisition detection!! http://compsci.ca/v3/viewtopic.php?t=13661


: