
-----------------------------------
evan467
Thu Feb 18, 2010 11:15 am

Shoot help
-----------------------------------
Can someone look over this and make the bullets not suck?


setscreen ("graphics: max;max,nobuttonbar")
var boundx1 : int
const maxbullet := 1000
var MaxEnemy : int

var spawnx, spawny : int
var restart : int
var Killcount : int
var movex, movey, x, y, button, personx, persony, personmove : int
var chars : array char of boolean
var run, runcounter, health : int
var shotnum : int
var font : int
var continue : string (1)
font := Font.New ("Arial:20")

var shotcount : int
var cd : int
cd := 0


type Enemy_Type :
    record
        ex, ey, er, ehealth, spawnx, spawny : real
    end record
locate (30, 75)
loop
    put "Enter The Amount of Max Enemies"
    get MaxEnemy
    exit when MaxEnemy > 0
end loop
setscreen ("graphics: max;max,offscreenonly,nobuttonbar")

var Enemy : array 1 .. MaxEnemy of Enemy_Type
type bullet_type :
    record
        xb, yb, yvelocity, xvelocity, angle, shot : real
    end record

var speed : int
speed := 3



var bullet : array 1 .. maxbullet of bullet_type

 Killcount := 0
    personx := 640
    persony := 400
    personmove := 0
    movex := 0
    movey := 0
    run := 1
    runcounter := 0
    shotnum := 1
    health := 100
    shotcount := 0
loop
 
    for i : 1 .. maxbullet
        bullet (i).shot := 0
        bullet (i).xb := maxx div 2
        bullet (i).yb := maxy div 2
    end for

    for i : 1 .. MaxEnemy
        Enemy (i).spawnx := Rand.Int (0, 3839)
        Enemy (i).spawny := Rand.Int (0, 2399)
        %

        %
        Enemy (i).ex := Enemy (i).spawnx
        Enemy (i).ey := Enemy (i).spawny
        Enemy (i).er := 10
        Enemy (i).ehealth := 20
    end for
    loop

        drawfillbox (0, 0, maxx, maxy, grey)
        drawfillbox (640 - movex, 2000 - movey, 740 - movex, 300 - movey, black)

        drawfillbox (3839 - movex, 1199 - movey, (3839 + 150) - movex, (1199 - 150) - movey, black)

        drawfillbox (1 - movex, 1 - movey, 151 - movex, (151) - movey, black) %

        drawfillbox (0 - movex, 2400 - movey, 1200 - movex, 2200 - movey, black)
        drawfillbox (0 - movex, 2400 - movey, 320 - movex, 1800 - movey, black)
        mousewhere (x, y, button)
        Input.KeyDown (chars)
        if button = 1 and cd = 0 then
            if shotcount  maxx div 2 and y > maxy div 2 then
                    bullet (shotcount).angle := arctand (y - maxy div 2 / x - maxx div 2)
                elsif x = maxx div 2 and y > maxy div 2 then
                    bullet (shotcount).angle := 90
                elsif x < maxx div 2 and y > maxy div 2 then
                    bullet (shotcount).angle := arctand (y - maxy div 2 / maxx div 2 - x)
                elsif x < maxx div 2 and y = maxy div 2 then
                    bullet (shotcount).angle := 180
                elsif x < maxx div 2 and y < maxy div 2 then
                    bullet (shotcount).angle := arctand (maxy div 2 - y / maxx div 2 - x)
                elsif x = maxx div 2 and y < maxy div 2 then
                    bullet (shotcount).angle := 270
                elsif x > maxx div 2 and y < maxy div 2 then
                    bullet (shotcount).angle := arctand (y - maxy div 2 / x - maxx div 2)
                elsif x > maxx div 2 and y = maxy div 2 then
                    bullet (shotcount).angle := 0

                    %
                end if
                bullet (shotcount).xvelocity := cosd (bullet (shotcount).angle)

                bullet (shotcount).yvelocity := sind (bullet (shotcount).angle)
                %
            end if
        end if
        for i : 1 .. maxbullet

            if bullet (i).shot = 1 then
                bullet (i).xb += bullet (i).yvelocity
                bullet (i).yb += bullet (i).xvelocity
                if chars (KEY_UP_ARROW) then
                    bullet (i).yb := bullet (i).yb - run
                end if
                if chars (KEY_DOWN_ARROW) then
                    bullet (i).yb := bullet (i).yb + run
                end if
                if chars (KEY_LEFT_ARROW) then
                    bullet (i).xb := bullet (i).xb + run
                end if
                if chars (KEY_RIGHT_ARROW) then
                    bullet (i).xb := bullet (i).xb - run
                end if
                drawfilloval (round (bullet (i).xb), round (bullet (i).yb), 1, 1, black)

            end if




            if bullet (i).xb < 0 or bullet (i).xb > maxx or bullet (i).yb > maxy or bullet (i).yb < 0 then
                bullet (i).shot := 0
                bullet (i).xb := maxx div 2
                bullet (i).yb := maxy div 2
                shotcount -= 1
            end if
        end for
        for i : 1 .. MaxEnemy
            if Enemy (i).ex > maxx div 2 then
                Enemy (i).ex := Enemy (i).ex - Rand.Int (0, 5)
            elsif Enemy (i).ex = maxx div 2 then
                Enemy (i).ex := Enemy (i).ex
            else
                Enemy (i).ex := Enemy (i).ex + Rand.Int (0, 5)
            end if
            if Enemy (i).ey > maxy div 2 then
                Enemy (i).ey := Enemy (i).ey - Rand.Int (0, 5)
            elsif Enemy (i).ey = maxy div 2 then
                Enemy (i).ey := Enemy (i).ey
            else
                Enemy (i).ey := Enemy (i).ey + Rand.Int (0, 5)
            end if

            if chars (KEY_UP_ARROW) then
                Enemy (i).ey := Enemy (i).ey - run
            end if
            if chars (KEY_DOWN_ARROW) then
                Enemy (i).ey := Enemy (i).ey + run
            end if
            if chars (KEY_LEFT_ARROW) then
                Enemy (i).ex := Enemy (i).ex + run
            end if
            if chars (KEY_RIGHT_ARROW) then
                Enemy (i).ex := Enemy (i).ex - run
            end if
            drawfilloval (round (Enemy (i).ex), round (Enemy (i).ey), round (Enemy (i).er), round (Enemy (i).er), red)
            if Enemy (i).ex < maxx div 2 + 10 and Enemy (i).ex > maxx div 2 - 10 and Enemy (i).ey > maxy div 2 - 10 and Enemy (i).ey < maxy div 2 then
                health := health - 1
                Font.Draw ("NOM NOM", 640, 420, font, black)
            end if
            if Enemy (i).ex = maxx div 2 and Enemy (i).ey = maxy div 2 then
                health := health - 1
                Font.Draw ("NOM NOM", 640, 420, font, black)
            end if
            for I : 1 .. maxbullet
                if bullet (I).shot = 1 and bullet (I).xb < Enemy (i).ex + 10 and bullet (I).xb > Enemy (i).ex - 10 and bullet (I).yb > Enemy (i).ey - 10 and bullet (I).yb < Enemy (i).ey + 10 then
                    Enemy (i).ehealth := Enemy (i).ehealth - 10
                    bullet (I).shot := 0
                end if
            end for

            if Enemy (i).ehealth  100 then
                run := 0
                runcounter := runcounter - 2
            end if
        else
            run := 2
        end if
        locate (1, 1)
        if runcounter > 80 then
            run := 1
        end if
        if maxy * 3 < 1 + movey then
            run := 0
            movey := movey - 1


        end if
        if maxx div 2 < 1 - movex then
            run := 0
            movex := movex + 1
        end if
        if maxy div 2 < 1 - movey then
            run := 0
            movey := movey + 1
        end if

        drawfillbox (0, maxy, 200, maxy - 20, white)
        Font.Draw (intstr (runcounter), 0, maxy - 20, font, red)
        drawfillbox (50, maxy - 20, 50 + health, maxy, green)
        Font.Draw (intstr (Killcount), 150, maxy - 20, font, red)
        drawoval (x, y, 10, 10, brightred)
        drawline (x + 10, y, x - 10, y, black)
        drawline (x, y + 10, x, y - 10, black)
        drawfilloval (maxx div 2, maxy div 2, 10, 10, green)

        exit when health 