All pastes #244238 Raw Edit

jelani3

public text v1 · immutable
#244238 ·published 2006-11-09 15:15 UTC
rendered paste body
View.Set ("graphics:max,max")
setscreen ("nocursor")
setscreen ("offscreenonly")
var x, y : int := 200
var speedx, speedy : int := 0
var ch : string (1) := " "
var one : int := Pic.FileNew ("one.jpg")
var ballx, bally : int := 50
var hit : string := "no"

loop
    cls
    loop
        exit when not hasch
        getch (ch)
    end loop
    Pic.Draw (one, 200, 100, picCopy)
    if ord (ch) = 200 then % up
        speedy := 1
        speedx := 0
    elsif ord (ch) = 203 then % left
        speedy := 0
        speedx := -1
    elsif ord (ch) = 208 then % down
        speedy := -1
        speedx := 0
    elsif ord (ch) = 205 then % right
        speedy := 0
        speedx := 1
    end if
    x += speedx
    y += speedy
    drawfilloval (x, y, 2, 2, red)
    put whatdotcolour (x, y)
    for i : 1 .. 3       % top of ball
        if whatdotcolour (x - 3 + i, y + 3) = black then
            hit := "yes"
            exit
        end if
        if whatdotcolour (x - 3 + i, y - 3) = black then
            hit := "yes"
            exit
        end if
        if whatdotcolour (x + 3, y - 3 + i) = black then
            hit := "yes"
            exit
        end if
        if whatdotcolour (x - 3, y - 3 + i) = black then
            hit := "yes"
            exit
        end if
    end for
    for i : 1 .. 3       % top of ball
        if whatdotcolour (x - 3 + i, y + 3) = 42 then
            hit := "finish"
            exit
        end if
        if whatdotcolour (x - 3 + i, y - 3) = 42 then
            hit := "finish"
            exit
        end if
        if whatdotcolour (x + 3, y - 3 + i) = 42 then
            hit := "finish"
            exit
        end if
        if whatdotcolour (x - 3, y - 3 + i) = 42 then
            hit := "finish"
            exit
        end if
    end for
    View.Update
    exit when hit = "yes"
    exit when hit="finish"
end loop