/* 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 ^ - - * clean up code! - */ View.Set ("graphics:225,262;offscreenonly;title:Pooyan;position:center,center;nocursor") % Declares the pictures, fonts var arrow : int := Pic.FileNew ("pic1.jpg") var titleScreen : int := Pic.FileNew ("title.jpg") var chars : array char of boolean var tahomaLarge : int := Font.New ("tahoma:12:bold") var serifLarge : int := Font.New ("serif:12:bold") var serifMed : int := Font.New ("serif:10:bold") % --------------------------- PROCEDURE DECLARATIONS ------------------------------ proc Intro Pic.Draw (titleScreen, 0, 0, picCopy) loop exit when hasch delay (20) end loop end Intro proc drawScreen drawfillbox (0, 0, maxx, maxy, 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 drawline (165, 45, 165, 200, 114) drawfillbox (0, 220, maxx, maxy, black) Font.Draw ("Score: 0", 0, 230, tahomaLarge, white) View.Update end drawScreen proc difficulty (var diff : int) drawfillbox (0, 0, maxx, maxy, blue) Font.Draw ("Select Difficulty:", 65, 225, serifLarge, yellow) Font.Draw ("1. Child's Play", 65, 210, serifMed, yellow) Font.Draw ("2. Mediocre", 75, 195, serifMed, yellow) Font.Draw ("3. Madness", 77, 180, serifMed, yellow) Font.Draw ("4. Better off using your time for ", 30, 165, serifMed, yellow) Font.Draw (" perpetual motion devices...", 40, 150, serifMed, yellow) View.Update loop Input.KeyDown (chars) if chars ('1') then diff := 1 elsif chars ('2') then diff := 2 elsif chars ('3') then diff := 3 elsif chars ('4') then diff := 4 end if if diff > 0 then drawScreen View.Update exit end if end loop drawScreen end difficulty proc endGame (var loseGame : boolean) loseGame := true cls end endGame proc refreshScreen (charY : int, wolfFallCount : int) drawline (200, 35, 200, 240, 114) drawline (180, 35, 180, 240, 114) drawfillbox (160, charY, 170, charY + 20, blue) for i : 1 .. wolfFallCount drawfilloval (190, 30 + (i * 20), 7, 7, green) end for end refreshScreen proc moveChar (var y : int) 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) drawline (165, 45, 165, 200, 114) drawfillbox (160, y, 170, y + 20, red) end moveChar proc dropWolf (var wx, wy, tempX, moveStage, wolfFallCount : int, var wolfFallFlag, deadWolf, loseGame : boolean) if wolfFallFlag = false and moveStage = 1 then tempX := 0 randint (wx, 0, 140) wolfFallFlag := true wy := 210 moveStage := 2 end if if wolfFallFlag = true and moveStage = 2 and tempX < wx - 4 then drawfilloval (tempX, 210, 7, 7, blue) delay (10) tempX += 4 drawfilloval (tempX, 210, 7, 7, green) elsif wolfFallFlag = true and moveStage = 2 and tempX >= (wx - 4) then drawfilloval (tempX, 210, 7, 7, blue) 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) end if if wolfFallFlag = true and moveStage = 3 and wy < 50 then drawfillbox (0, 36, maxx - 50, 60, blue) wolfFallFlag := false tempX := 0 moveStage := 1 if deadWolf = false then wolfFallCount += 1 end if 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) end if if deadWolf = true and wy < 50 then drawfilloval (wx, wy, 7, 7, blue) deadWolf := false wolfFallFlag := false tempX := 0 moveStage := 1 end if if wolfFallCount > 5 then endGame (loseGame) end if end dropWolf 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 := 140 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 hudUpdate (var score : int) drawfillbox (0, 220, maxx, maxy, black) Font.Draw ("Score: " + intstr (score), 0, 230, tahomaLarge, white) end hudUpdate 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) hudUpdate (score) end if end hitWolf % ---------------------------- BEGIN MAIN PROGRAM LOOP ------------------------------- var charY : int := 100 var mx, my, mb : int var wx, wy, ax, ay : int := 1 var arrowShot, deadWolf, wolfFallFlag, loseGame : boolean := false var score, wolfFallCount := 0 var tempX : int := 10 var moveStage : int := 1 var diff : int := 0 Intro difficulty (diff) drawScreen loop mousewhere (mx, my, mb) refreshScreen (charY, wolfFallCount) moveChar (charY) dropWolf (wx, wy, tempX, moveStage, wolfFallCount, wolfFallFlag, deadWolf, loseGame) arrowShoot (ax, ay, charY, arrowShot) hitWolf (ax, ay, wx, wy, score, deadWolf, wolfFallFlag, arrowShot) exit when loseGame = true View.Update end loop