
-----------------------------------
pj_ladd12
Wed Aug 23, 2006 9:39 pm

Fish game
-----------------------------------
Here is a start to my game, use arrow keys to move



any comments wud be cool thank you!



setscreen ("offscreenonly;graphics:530;330;position:100;100;nobuttonbar") %settings
var swim : array char of boolean
var xpos, ypos : real := 200
var bodyxsize : int := 30
var bodyysize : int := 18
var shadowx : real
var shadowxsize : real
var speed : real := 0
var die : int := 0
var sidespeed : real := 0
var bubblex, bubbley, bubbler : array 1 .. 5 of real
var grassx, grassy : array 0 .. 20 of int
shadowxsize := 40
for i : 1 .. 5 %5 random bubbles
    bubblex (i) := Rand.Int (round (xpos + 15), round (xpos + 28))
    bubbley (i) := Rand.Int (round (ypos - 10), round (ypos + 10))
    bubbler (i) := Rand.Int (1, 3)
end for
for i : 0 .. 20
    grassx (i) := 0 %weeds
    grassy (i) := 0
end for
%%
procedure background
    for i : 0 .. 20 %weeds
        Draw.ThickLine (grassx (i) + i * 50 + 16, grassy (i) + 40, grassx (i) + i * 50, grassy (i), 3, 190)
        Draw.ThickLine (grassx (i) + i * 50 + 10, grassy (i) + 64, grassx (i) + i * 50, grassy (i), 3, green)
        Draw.ThickLine (grassx (i) + i * 50 + 20, grassy (i) + 50, grassx (i) + i * 50 + 25, grassy (i), 3, 190)
        Draw.ThickLine (grassx (i) + i * 50 + 12, grassy (i) + 40, grassx (i) + i * 50 + 18, grassy (i), 3, 7)
        Draw.ThickLine (grassx (i) + i * 50 + 32, grassy (i) + 53, grassx (i) + i * 50 + 28, grassy (i), 3, green)
        Draw.ThickLine (grassx (i) + i * 50 + 38, grassy (i) + 40, grassx (i) + i * 50 + 35, grassy (i), 3, 7)
        Draw.ThickLine (grassx (i) + i * 50 + 48, grassy (i) + 50, grassx (i) + i * 50 + 35, grassy (i), 3, 190)
        Draw.ThickLine (grassx (i) + i * 50 + 48, grassy (i) + 60, grassx (i) + i * 50 + 45, grassy (i), 3, green)
    end for
end background
%%
procedure fish
    shadowx := xpos %shadow
    Input.KeyDown (swim)
    drawfilloval (round (xpos), round (ypos), bodyxsize, bodyysize, blue) %fishs' body
    drawfilloval (round (xpos + 10), round (ypos + 8), 6, 6, 7)
    drawfilloval (round (xpos + 13), round (ypos + 5), 1, 1, 0)
    drawfilloval (round (shadowx), 5, round (shadowxsize - 8), bodyysize - 22, 7) %shadow
    Draw.ThickLine (round (xpos - 50), round (ypos + 3), round (xpos - bodyxsize), round (ypos), 3, 7) %tail
    Draw.ThickLine (round (xpos - 53), round (ypos + 7), round (xpos - bodyxsize), round (ypos + 3), 2, 7)
    Draw.ThickLine (round (xpos - 53), round (ypos - 7), round (xpos - bodyxsize), round (ypos - 3), 2, 7)
    Draw.ThickLine (round (xpos - 53), round (ypos - 2), round (xpos - bodyxsize), round (ypos - 1), 3, 7)
    %controls
    if swim (KEY_UP_ARROW) then
        speed += 0.01 %speed increase
    end if
    if swim (KEY_DOWN_ARROW) then
        speed -= 0.01 %decrease
    end if
    if swim (KEY_LEFT_ARROW) then
        sidespeed -= 0.01 %""
    end if
    if swim (KEY_RIGHT_ARROW) then
        sidespeed += 0.01  %""
    end if
    %controls
    %speed
    xpos += sidespeed %speed
    ypos += speed %""
    %speed
    %boundries
    if xpos > maxx + bodyxsize + 24 then
        xpos := 0 - bodyxsize %boundries
    end if
    if xpos < 0 - bodyxsize then
        xpos := maxx + bodyxsize + 24
    end if
    if ypos > maxy + bodyysize then
        ypos := 0 - bodyysize
    end if
    if ypos < 0 - bodyysize then
        ypos := maxy + bodyysize
    end if
    %boundries
    %limit speed
    if speed > 2 then
        speed := 2 %stops at 2
    end if
    if speed < -2 then
        speed := -2
    end if
    if sidespeed > 2 then
        sidespeed := 2
    end if
    if sidespeed < -2 then
        sidespeed := -2
    end if
    %limit speed
    %shadow settings
    if speed >= 0.1 then
        shadowxsize += 0.1 %shadow increases if fish swims upward
    elsif speed = maxy + bodyysize then %fish is at top
        shadowxsize := 40
    end if
    if ypos  maxy + 10 then %if get to top
            bubblex (i) := Rand.Int (round (xpos + 15), round (xpos + 28))
            bubbley (i) := Rand.Int (round (ypos - 10), round (ypos + 10))
            bubbler (i) := Rand.Int (1, 3)
        end if
    end for
end bubbles
%%
type otherfish :
    record
        fishx : int
        fishy : int
        fishradius : int
    end record
var bad : array 1 .. 6 of otherfish
for i : 1 .. 6
    randint (bad (i).fishx, maxx, maxx + 200)
    randint (bad (i).fishy, 30, maxy - 30)
    randint (bad (i).fishradius, 6, 25)
end for
procedure enemies
    for i : 1 .. 6
        Draw.ThickLine (bad (i).fishx, bad (i).fishy, bad (i).fishx + 55, bad (i).fishy + 6, 2, 7)
        Draw.ThickLine (bad (i).fishx, bad (i).fishy, bad (i).fishx + 45, bad (i).fishy + 8, 2, 7)
        Draw.ThickLine (bad (i).fishx, bad (i).fishy, bad (i).fishx + 55, bad (i).fishy - 2, 2, 7)
        Draw.ThickLine (bad (i).fishx, bad (i).fishy, bad (i).fishx + 45, bad (i).fishy - 8, 2, 7)
        drawfilloval (bad (i).fishx, bad (i).fishy, bad (i).fishradius, bad (i).fishradius, 56)

        bad (i).fishx -= 1
        if bad (i).fishx < -30 then
            randint (bad (i).fishx, maxx, maxx + 200)
            randint (bad (i).fishy, 30, maxy - 30)
            randint (bad (i).fishradius, 6, 25)
        end if
    end for
end enemies
%%
procedure hit
    drawfilloval (round (xpos), round (ypos), bodyxsize, bodyysize, blue)     %fishs' body
    for i : 1 .. 1
        if Math.Distance (xpos, ypos, bad (i).fishx, bad (i).fishy) < bodyxsize + bad (i).fishradius then
            if bodyxsize >= 30 and bodyysize >= bad (i).fishradius then
                randint (bad (i).fishx, maxx, maxx + 200)
                randint (bad (i).fishy, 30, maxy - 30)
                randint (bad (i).fishradius, 6, 25)
            elsif bodyxsize = 30 and bodyysize >= bad (i).fishradius then
                randint (bad (i).fishx, maxx, maxx + 200)
                randint (bad (i).fishy, 30, maxy - 30)
                randint (bad (i).fishradius, 6, 25)
            elsif bodyxsize 