setscreen ("offscreenonly")
var score1, score2, ballx, ballx2, bally, bally2, xmod, xmod2, ymod, ymod2 : int
var chars : array char of boolean
var slimex, slimey, vy : int
slimex := 200
slimey := 20
vy := 0
ballx := 320
bally := 0
const jumpVelocity := 5
const speedX := 2 %speed of horizontal movement
const gravity := 0.07
var inAir := false
xmod := 1
ymod := 1
xmod2 := 1
ymod2 := 1
score1 := 0
score2 := 0
loop
if Input.hasch then
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and not inAir then
vy := jumpVelocity
inAir := true
end if
if chars (KEY_RIGHT_ARROW) then
slimex += speedX
end if
if chars (KEY_LEFT_ARROW) then
slimex -= speedX
end if
%very basic collision detection. Only detects when the object reaches ground level
if inAir then
slimey += vy
vy -= gravity
if slimey <= 10 then
inAir := false
vy := 0
end if
end if
if chars (KEY_RIGHT_ARROW) then
slimex += 10
end if
if chars (KEY_LEFT_ARROW) then
slimex -= 10
end if
if chars (KEY_DOWN_ARROW) then
slimey -= 10
end if
View.Update
end if
drawfillbox (0, 0, maxx, maxy, 0)
drawfillarc (slimex, slimey, -50, -50, 180, 0, blue)
drawline (0, 126, 107, 126, blue) %|net 1 top
drawline (0, 125, 100, 125, black) %|
drawline (0, 124, 100, 124, black) %|
drawline (0, 123, 100, 123, black) %|
drawline (0, 122, 100, 122, black) %|net 1
drawline (0, 121, 100, 121, black) %|
drawline (0, 120, 100, 120, black) %|
drawline (0, 119, 100, 119, black) %|
%____________________________________________
drawline (100, 0, 100, 125, black) %|net 1
drawline (101, 0, 101, 125, black) %|net 1
drawline (102, 0, 102, 125, black) %|net 1
drawline (103, 0, 103, 125, black) %|net 1
drawline (104, 0, 104, 125, black) %|net 1
drawline (105, 0, 105, 125, black) %|net 1
drawline (106, 0, 106, 125, black) %|net 1
drawline (107, 0, 107, 125, black) %|net 1
%____________________________________________
drawline (0, 110, 100, 110, black) %|net 1
drawline (0, 100, 100, 100, black) %|net 1
drawline (0, 90, 100, 90, black) %|net 1
drawline (0, 80, 100, 80, black) %|net 1
drawline (0, 70, 100, 70, black) %|net 1
drawline (0, 60, 100, 60, black) %|net 1
drawline (0, 50, 100, 50, black) %|net 1
drawline (0, 40, 100, 40, black) %|net 1
drawline (0, 30, 100, 30, black) %|net 1
drawline (0, 20, 100, 20, black) %|net 1
drawline (0, 10, 100, 10, black) %|net 1
%____________________________________________
drawline (90, 0, 90, 119, black) %|net 1
drawline (80, 0, 80, 119, black) %|net 1
drawline (70, 0, 70, 119, black) %|net 1
drawline (60, 0, 60, 119, black) %|net 1
drawline (40, 0, 40, 119, black) %|net 1
drawline (50, 0, 50, 119, red) %|net 1
drawline (28, 0, 28, 119, blue) %|net 1
drawline (20, 0, 20, 119, black) %|net 1
drawline (10, 0, 10, 119, black) %|net 1
%______________________________END OF NET 1________________________________________________________________________________________________
drawline (640, 126, 534, 126, blue) %|net 2 top
drawline (640, 125, 540, 125, black) %|net 2
drawline (640, 124, 540, 124, black) %|net 2
drawline (640, 123, 540, 123, black) %|net 2
drawline (640, 122, 540, 122, black) %|net 2
drawline (640, 121, 540, 121, black) %|net 2
drawline (640, 120, 540, 120, black) %|net 2
drawline (640, 119, 540, 119, black) %|net 2
%____________________________________________
drawline (541, 0, 541, 125, black) %|net 2
drawline (540, 0, 540, 125, black) %|net 2
drawline (539, 0, 539, 125, black) %|net 2
drawline (538, 0, 538, 125, black) %|net 2
drawline (537, 0, 537, 125, black) %|net 2
drawline (536, 0, 536, 125, black) %|net 2
drawline (535, 0, 535, 125, black) %|net 2
drawline (534, 0, 534, 125, black) %|net 2
%____________________________________________
drawline (640, 110, 540, 110, black) %|net 2
drawline (640, 100, 540, 100, black) %|net 2
drawline (640, 90, 540, 90, black) %|net 2
drawline (640, 80, 540, 80, black) %|net 2
drawline (640, 70, 540, 70, black) %|net 2
drawline (640, 60, 540, 60, black) %|net 2
drawline (640, 50, 540, 50, black) %|net 2
drawline (640, 40, 540, 40, black) %|net 2
drawline (640, 30, 540, 30, black) %|net 2
drawline (640, 20, 540, 20, black) %|net 2
drawline (640, 10, 540, 10, black) %|net 2
%____________________________________________
drawline (550, 0, 550, 125, black) %|net 2
drawline (560, 0, 560, 125, black) %|net 2
drawline (570, 0, 570, 125, black) %|net 2
drawline (580, 0, 580, 125, black) %|net 2
drawline (590, 0, 590, 125, black) %|net 2
drawline (600, 0, 600, 119, green) %|net 2
drawline (610, 0, 610, 125, black) %|net 2
drawline (620, 0, 620, 125, black) %|net 2
drawline (630, 0, 630, 125, black) %|net 2
%_________________________________END OF NET 2_____________________________________________________________________________________________
Draw.FillOval (ballx, bally, 10, 10, 12)
ballx += xmod
bally += ymod
if ballx >= maxx then
xmod := -xmod
elsif ballx <= 0 then
xmod := -xmod
end if
if bally >= maxy then
ymod := -ymod
elsif bally <= 0 then
ymod := -ymod
end if
if whatdotcolour (ballx + 11, bally) = blue or whatdotcolour (ballx - 11, bally) = 1 then
xmod := -xmod
end if
if whatdotcolour (ballx, bally + 11) = blue or whatdotcolour (ballx, bally - 11) = 1 then
ymod := -ymod
end if
if whatdotcolour (ballx, bally + 11) = red then
score1 += 1
end if
if whatdotcolour (ballx + 11, bally) = red then
score1 += 1
end if
if score1 <= 1 then
locatexy (0, 400)
put "", score1, ""
elsif score1 >= 1 then
locatexy (0, 400)
put "", score1, ""
end if
View.Update
end loop
|