/* Pooyan Game... ---------------- POOYAN -------------------- - TODO: - - * passes level one when x wolves killed - - * fails level when x wolves reach bottom - - * add a splash screen, restart option - - * add difficulty levels - - * make the wolves move up the screen and - - attack you - - * add a second level, when wolves move ^ - */ View.Set ("graphics:225,256;offscreenonly;title:Pooyan;position:center,center;nocursor") % Declares the pictures, fonts var arrow : int := Pic.FileNew ("pic1.jpg") var chars : array char of boolean var tahomaLarge : int := Font.New ("tahoma:12:bold") proc refreshScreen (charY : int) drawline (200, 35, 200, 240, 114) drawline (180, 35, 180, 240, 114) drawfillbox (185, charY, 195, charY + 20, blue) for y : 50 .. 240 by 15 drawline (180, y, 200, y, 114) end for end refreshScreen proc moveChar (var y : int) refreshScreen (y) Input.KeyDown (chars) if chars (KEY_UP_ARROW) and y < 220 then y += 5 elsif chars (KEY_DOWN_ARROW) and y > 57 then y -= 5 end if delay (10) drawfillbox (185, y, 195, y + 20, red) end moveChar proc drawScreen drawfill (0, 0, blue, blue) drawfillbox (0, 0, maxx, 30, 114) drawfillbox (0, 30, maxx, 35, green) drawline (200, 35, 200, 240, 114) drawline (180, 35, 180, 240, 114) for y : 50 .. 240 by 15 drawline (180, y, 200, y, 114) end for end drawScreen proc arrowShoot (var ax, ay : int, charY : int, var arrowShot : boolean) var y : int Input.KeyDown (chars) if chars (KEY_CTRL) and arrowShot = false then arrowShot := true ax := 180 ay := charY end if if arrowShot = true and ax > 0 then drawfillbox (ax, ay, ax + 30, ay + 14, blue) ax -= 10 Pic.Draw (arrow, ax, ay, picMerge) elsif arrowShot = true and ax < 5 then arrowShot := false drawfillbox (ax, ay, ax + 30, ay + 14, blue) end if end arrowShoot proc dropWolf (var wx, wy, tempX, moveStage : int, var wolfFallFlag, deadWolf : boolean) if wolfFallFlag = false and moveStage = 1 then randint (wx, 0, 150) wolfFallFlag := true wy := 215 tempX := 0 moveStage := 2 end if if wolfFallFlag = false and moveStage not= 1 then moveStage := 1 end if if wolfFallFlag = true and moveStage = 2 and tempX < wx - 4 then drawfilloval (tempX, 215, 7, 7, blue) delay (10) tempX += 4 drawfilloval (tempX, 215, 7, 7, green) elsif wolfFallFlag = true and moveStage = 2 and tempX >= (wx - 4) then moveStage := 3 end if if wolfFallFlag = true and moveStage = 3 and wy > 45 then drawfilloval (wx, wy, 7, 7, blue) wy -= 5 delay (20) drawfilloval (wx, wy, 7, 7, green) elsif wolfFallFlag = true and wy < 45 and moveStage = 3 then drawfillbox (0, 36, maxx - 50, 60, blue) wolfFallFlag := false end if if deadWolf = true and wolfFallFlag = true and wy > 45 then drawfilloval (wx, wy, 7, 7, blue) wy -= 2 delay (20) drawfilloval (wx, wy, 7, 7, red) elsif deadWolf = true and wy < 50 then drawfilloval (wx, wy, 7, 7, blue) deadWolf := false wolfFallFlag := false end if end dropWolf proc hitWolf (ax, ay, wx, wy : int, var score : int, var deadWolf, wolfFallFlag, arrowShot : boolean) if ax - 7 <= wx + 10 and ax - 7 >= wx - 10 and ay + 7 <= wy + 10 and ay + 7 >= wy - 10 and deadWolf = false then deadWolf := true arrowShot := false score += 1 drawfillbox (ax, ay, ax + 30, ay + 14, blue) end if end hitWolf proc hudUpdate (var score : int) drawfillbox (0, 220, maxx, maxy, black) Font.Draw ("Score: " + intstr (score), 0, 230, tahomaLarge, white) end hudUpdate % --------- Main Program var charY : int := 100 var mx, my, mb : int var wx, wy, ax, ay : int := 1 var arrowShot, deadWolf, wolfFallFlag : boolean := false var score := 0 var tempX : int := 10 var moveStage : int := 1 drawScreen loop mousewhere (mx, my, mb) refreshScreen (charY) hudUpdate (score) moveChar (charY) dropWolf (wx, wy, tempX, moveStage, wolfFallFlag, deadWolf) arrowShoot (ax, ay, charY, arrowShot) hitWolf (ax, ay, wx, wy, score, deadWolf, wolfFallFlag, arrowShot) View.Update locate (9, 12) put moveStage end loop