View.Set ("graphics:200;250,nobuttonbar")
var xmouse, ymouse, button : int
var xp := 60.0
var yp := 60.0
var xbg, ybg : int := 0
%draw the player
proc player
Draw.ThickLine (round (xp) + 9, round (yp) + 3, round (xp) + 10, round (yp), 3, 22) %left hand
Draw.ThickLine (round (xp) + 4, round (yp) - 3, round (xp) + 22, round (yp) - 4, 5, darkgrey) %gun
drawbox (round (xp) + 4, round (yp) - 6, round (xp) + 24, round (yp) - 2, black) %gun outline
Draw.ThickLine (round (xp) + 8, round (yp) - 8, round (xp) + 10, round (yp) - 5, 3, 22) %right hand
Draw.ThickLine (round (xp), round (yp) + 8, round (xp) + 9, round (yp) + 3, 4, brightblue) %left arm
Draw.FillOval (round (xp) + 3, round (yp) - 9, 6, 3, brightblue) %right arm
Draw.FillOval (round (xp), round (yp), 6, 11, 22) %body
Draw.Oval (round (xp), round (yp), 6, 11, black) %body outine
Draw.FillOval (round (xp) - 1, round (yp), 5, 3, 91) %head
Draw.Oval (round (xp) - 1, round (yp), 5, 4, black) %head outline
Draw.Line (round (xp) + 1, round (yp) - 3, round (xp) + 1, round (yp) + 3, black)
drawfill (round (xp), round (yp), blue, black)
end player
player
var copy1 := Pic.New (50, 45, 82, 75)
var pic1 : int := Pic.Rotate (copy1, 90, -1, -1)
Pic.Free (copy1)
%create the rotated player pictures
var picRot : array 0 .. 35 of int
for rep : 0 .. 35
picRot (rep) := Pic.Rotate (pic1, rep * 10, Pic.Width (pic1) div 2 + 7, Pic.Height (pic1) div 2 + 5)
end for
var pictmp := picRot (0)
var counter := 0
var keys : array char of boolean
proc control
if keys (KEY_UP_ARROW) then
xp += cosd ((counter mod 36) * 10 + 90) * 5
yp += sind ((counter mod 36) * 10 + 90) * 5
end if
if keys (KEY_DOWN_ARROW) then
xp -= cosd ((counter mod 36) * 10 + 90) * 5
yp -= sind ((counter mod 36) * 10 + 90) * 5
end if
if keys (KEY_LEFT_ARROW) then
counter += 1
pictmp := picRot (counter mod 36)
end if
if keys (KEY_RIGHT_ARROW) then
counter -= 1
pictmp := picRot (counter mod 36)
end if
end control
proc boundry
if xp <= 35 then
xp := 36
xbg += 3
elsif xp >= 120 then
xp := 119
xbg -= 3
elsif yp <= 35 then
yp := 36
ybg += 3
elsif yp >= 120 then
yp := 119
ybg -= 3
end if
end boundry
setscreen ("offscreenonly")
loop
cls
colourback (black)
mousewhere (xmouse, ymouse, button)
Input.KeyDown (keys)
boundry
drawfillbox (xbg,ybg,xbg+640,ybg+480,grey)
drawfilloval (xbg+70,ybg+100,10,10,green)
control
Pic.Draw (pictmp, round (xp), round (yp + 50), picMerge)
delay (50)
View.Update
end loop |