View.Set ("graphics:max,max, offscreenonly,nobuttonbar") var x, y, dir, accel, lastdir, stimer, shotcount, eshotcount, tempDec, overheat, maxHeatLimit, starlimit : int var moveFlag, shootFlag, c1, c2, c3, c4, leftOrRight : boolean := false var chars : array char of boolean var shotx, shoty : flexible array 0 .. 0 of int var shotdir : flexible array 0 .. 0 of boolean var starx, stary : flexible array 0 .. 0 of int x := maxx div 2 y := maxy div 2 accel := 0 shotx (0) := -100 shoty (0) := -100 stimer := 0 shotcount := 0 eshotcount := 0 overheat := 0 maxHeatLimit := 100 tempDec := 0 randint (starlimit, 20, 100) new starx, starlimit new stary, starlimit for i : 1 .. starlimit randint (starx (i), 0, maxx) randint (stary (i), 0, maxx) end for proc starBackground for i : 1 .. starlimit drawfilloval (starx (i), stary (i), 3, 3, white) end for end starBackground proc move % Handles Keyboard Input - handles 8 directional movement/drifting. Input.KeyDown (chars) if chars (KEY_UP_ARROW) then c1 := true lastdir := 1 else c1 := false end if if chars (KEY_RIGHT_ARROW) then c2 := true lastdir := 2 leftOrRight := false else c2 := false end if if chars (KEY_LEFT_ARROW) then c3 := true lastdir := 3 leftOrRight := true else c3 := false end if if chars (KEY_DOWN_ARROW) then c4 := true lastdir := 4 else c4 := false end if if chars (KEY_UP_ARROW) and chars (KEY_RIGHT_ARROW) then lastdir := 5 end if if chars (KEY_UP_ARROW) and chars (KEY_LEFT_ARROW) then lastdir := 6 end if if chars (KEY_DOWN_ARROW) and chars (KEY_RIGHT_ARROW) then lastdir := 7 end if if chars (KEY_DOWN_ARROW) and chars (KEY_LEFT_ARROW) then lastdir := 8 end if % Check to see if any button is being pressed if c1 = true or c2 = true or c3 = true or c4 = true then moveFlag := true else moveFlag := false end if % If buttons are held then the spaceship will speed up, or else will slow down. %*Handles speed restricitons change the number to limit the speed. if moveFlag = true then if accel < 50 then %* accel += 2 end if elsif moveFlag = false and accel > 0 then accel -= 1 end if % Moves according to the acceleration If A button is being pressed % *Moves according to the acceleration - handles 8 directional drifting if accel > 0 and moveFlag = true then if c1 = true then y += accel end if if c2 = true then x += accel end if if c3 = true then x -= accel end if if c4 = true then y -= accel end if elsif accel > 0 and moveFlag = false then %* if lastdir = 1 then y += accel elsif lastdir = 2 then x += accel elsif lastdir = 3 then x -= accel elsif lastdir = 4 then y -= accel elsif lastdir = 5 then x += accel y += accel elsif lastdir = 6 then x -= accel y += accel elsif lastdir = 7 then x += accel y -= accel elsif lastdir = 8 then y -= accel x -= accel end if end if end move proc shoot % Test enforced acceleration (eg. for boosts, extreme speed.) if chars (KEY_CTRL) then accel := 50 end if % Space Key to shoot %* Uncomment if automatic fire is desired. if chars (' ') then if stimer = 0 then % and overheat < maxHeatLimit then shotcount += 1 eshotcount += 1 shootFlag := true new shotx, shotcount new shoty, shotcount new shotdir, shotcount shotdir (shotcount) := leftOrRight shotx (shotcount) := x shoty (shotcount) := y overheat += 5 tempDec := 0 end if stimer += 1 %* if stimer >= 1 then stimer := 0 end if else stimer := 0 end if % CoolDown of Gun if overheat > 0 then overheat -= 1 end if % Moves all the shots going on at the time. for i : 1 .. shotcount if shootFlag = true then if shotdir (i) = true then shotx (i) -= 20 elsif shotdir (i) = false then shotx (i) += 20 end if end if drawfilloval (shotx (i), shoty (i), 2, 2, green) end for % Handles if the shot has gone off the screen, if it has then the data is deleted. for i : 1 .. shotcount - 1 if shotx (i) < 0 or shotx (i) > maxx then for k : i .. shotcount - 1 shotx (k) := shotx (k + 1) shoty (k) := shoty (k + 1) shotdir (k) := shotdir (k + 1) end for shotcount -= 1 end if end for end shoot loop move shoot drawfilloval (x, y, 5, 5, red) locate (1, 1) put accel, " ", moveFlag, " ", shootFlag, " ", shotcount, " ", overheat, " " .. View.Update cls delay (75) drawfillbox (0, 0, maxx, maxy, black) starBackground end loop