View.Set ("offscreenonly")
var x, y : int
x := 0
y := 0
var keys : array char of boolean
var jump := false %boolean. since it's declared as false turing knows its boolean
var x1, y1, vy : real %vy = velocity in the y plane. aka, the upwards velocity of the player.
x1 := 0
y1 := 0
const gravity := 0.1
var size := 35
var enemy : int := Pic.FileNew ("enemy1.bmp")
var player : int := Pic.FileNew ("player.jpg")
drawline (0, 4, maxx, 4, 17)
loop
cls
drawline (0, 4, maxx, 4, 17)
Input.KeyDown (keys)
if keys (KEY_UP_ARROW) and not jump then %"and not jump" is the same as "and jump = false"
jump := true
vy := 4
end if
if jump then %"if jump then" is the same as "if jump = true then"
y1 += vy % same as y := y + vy
vy -= gravity % same as vy := vy - gravity
if y1 <= 5 then
jump := false
end if
end if
View.Set ("offscreenonly") %Stops the pictures from flickering
%Pic.ScreenLoad ("player.jpg", round (x1), round (y1 + 5), picCopy)
Pic.Draw (player, round (x1), round (y1 + 5), picCopy)
drawbox (399, 25, 430, 50, 17)
Pic.Draw (enemy, 400, 30, picCopy)
delay (10)
%Makes the Player Move.
var chars : array char of boolean
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x1 += 3
end if
if chars (KEY_LEFT_ARROW) then
x1 -= 3
end if
if chars (KEY_UP_ARROW) then
y1 += 3
end if
if chars (KEY_DOWN_ARROW) then
y1 -= 3
end if
if chars (' ') then
var bullet := Pic.FileNew ("bullet2.jpg")
for x2 : x .. x + 50
Pic.Draw (bullet, x1 + x2, y1 + 30, picMerge)
Pic.Draw (player, round (x1), round (y1 + 5), picCopy)
View.Update
end for
end if
View.Update
end loop
|