
-----------------------------------
BPhelmet
Mon Dec 20, 2004 9:42 pm

my school project, come in and help me out
-----------------------------------
this is my program, it is big because of the map.

it is a fighter plane game, my problem is i don't know how to make the plane shoot mutiple bullets and moving while shooting.

can anyone help me out?


Why can't i upload stuff???[/b]

-----------------------------------
BPhelmet
Mon Dec 20, 2004 9:45 pm


-----------------------------------
it says "Upload Error: Could not upload Attachment to ./../bbs/files/ace.zip."

what can i do?

-----------------------------------
Tony
Tue Dec 21, 2004 11:43 am


-----------------------------------
how big is the file in size? that could be an issue..

as to shooting and movement: you got to make your spaceship and missiles separate objects, independant of each other. This way during each loop pass, you can move one, then the other.

keep in mind that you move each by 1 unit. You do not have an internal loop dedicated to just one object.

-----------------------------------
BPhelmet
Tue Dec 21, 2004 12:18 pm


-----------------------------------
it is only 2.5MB 

here's how i did it

setscreen ("offscreenonly")
setscreen ("nocursor")
setscreen ("graphics:vga")

%variable for background, the plane and the bullet
var background, realP_51, bullet : int

%give backfround a value
background := Pic.FileNew ("level1background.jpg")

%give the plane a value
realP_51 := Pic.FileNew ("P-51D.bmp")

%give bullet a value
bullet := Pic.FileNew ("bullet.jpg")

%variable for the control of the plane
var move : string (1)

%variable for bullets to move
var xb1, yb1, xb2, yb2 : int


%variables for the background to move
var x2, y2 : int
x2 := 150
y2 := 0

%variables for P-51D to move
var x1Mustang, x2Mustang, y1Mustang, y2Mustang : int
x1Mustang := 400
x2Mustang := 480
y1Mustang := 0
y2Mustang := 80

%variables for enemy planes
%set how many plane will there be
var EnemyPlaneCounter := 80             %the number will start at 80 and will increase by level

%setting up the picture
var EnemyPlane : int

EnemyPlane := Pic.FileNew ("Me-109.bmp")

%loop so the back ground moves
for i : 1 .. 2633

    %x's and y's for enemy plane
    var EnemyPlaneX, EnemyPlaneY : array 1 .. EnemyPlaneCounter of int

    %to see if the plane is alive
    var EnemyPlaneAlive : array 1 .. EnemyPlaneCounter of boolean

    %initialize the enemy planes
    for a : 1 .. EnemyPlaneCounter
        randint (EnemyPlaneX (a), 150, 850)
        randint (EnemyPlaneY (a), 700, 1000)
        Pic.Draw (EnemyPlane, EnemyPlaneX (a), EnemyPlaneY (a), picMerge)
        EnemyPlaneX (a) := EnemyPlaneX (a)
        EnemyPlaneY (a) := EnemyPlaneY (a) - 10
    end for
    %variable to keep track fo the score
    var score : int := 0

    %variable to keep track of player's health
    var health : int := 200

    cls
    drawfillbox (0, 0, maxx, maxy, black)
    Pic.Draw (background, x2, y2, picMerge)
    Pic.Draw (realP_51, x1Mustang, y1Mustang, picMerge)

    y2 := y2 - 3
    
    %counter for bullets
    var bulletCounter := 1

    xb1  := x1Mustang + 30
    yb1  := y1Mustang + 60
    xb2  := x1Mustang + 48
    yb2  := y1Mustang + 60

    View.Update

    if hasch then
        getch (move)
        case move of
            label chr (200) :
                y1Mustang := y1Mustang + 15
                if y1Mustang > 620 then
                    y1Mustang := 620
                end if
            label chr (208) :
                y1Mustang := y1Mustang - 15
                if y1Mustang < 0 then
                    y1Mustang := 0
                end if
            label chr (205) :
                x1Mustang := x1Mustang + 35
                if x1Mustang > 770 then
                    x1Mustang := 770
                end if
            label chr (203) :
                x1Mustang := x1Mustang - 35
                if x1Mustang < 150 then
                    x1Mustang := 150
                end if
            label chr (32) :
                fork fireP_51D
                for a : 1 .. 15
                    Pic.Draw (background, x2, y2, picMerge)
                    Pic.Draw (realP_51, x1Mustang, y1Mustang, picMerge)
                    y2 := y2 - 3 
                    yb1  := yb1  + 50
                    yb2  := yb2  + 50
                    Pic.Draw (bullet, xb1 , yb1 , picCopy)
                    Pic.Draw (bullet, xb2 , yb2 , picCopy)
                    View.Update
                end for
                Music.PlayFileStop
            label "q" :
                ex2 := true
                Window.Close (winID)
            label :
        end case
    end if
end for

-----------------------------------
BPhelmet
Tue Dec 21, 2004 12:20 pm


-----------------------------------
that is only part of the program

my friend is on his way to send the whole pakage

-----------------------------------
Yenan
Tue Dec 21, 2004 12:27 pm


-----------------------------------
Here's the background

-----------------------------------
BPhelmet
Tue Dec 21, 2004 12:28 pm


-----------------------------------
and you can ignore the enemy plane part, i haven't got that far yet.

well, i still have problem getting the computer to draw the enemy planes

-----------------------------------
BPhelmet
Tue Dec 21, 2004 12:48 pm


-----------------------------------
there it is

-----------------------------------
Cervantes
Tue Dec 21, 2004 3:09 pm


-----------------------------------
You have an upload capacity of 2.0mb, which is why you couldn't upload it.

As to your question:
Read up on [url=http://www.compsci.ca/v2/viewtopic.php?t=6723]Flexible Arrays.  They will allow you to create an object (a bullet) whenever you hit the fire button on the keyboard.  You can keep track of various aspects of that object (the bullet) as the rest of the program is running.  Don't skip over the dueling game at the end of the first post, it's pretty much exactly what you are looking for.

-----------------------------------
BPhelmet
Tue Dec 21, 2004 7:28 pm


-----------------------------------
thanx

-----------------------------------
BPhelmet
Tue Dec 21, 2004 9:16 pm


-----------------------------------
You have an upload capacity of 2.0mb, which is why you couldn't upload it.

As to your question:
Read up on 

i don't quite understand you program, is it possible to just put all the couunting and drawing together, is there any other way to do this exept yours.

-----------------------------------
Cervantes
Tue Dec 21, 2004 9:36 pm


-----------------------------------

i don't quite understand you program, is it possible to just put all the couunting and drawing together, is there any other way to do this exept yours.
what do you mean, the counting and drawing?  I think I put all the drawing at the end, and everything else (input and manipulation) before it.

You could use processes.  But, no.  Do not do that.  This is the best way to do it.  Trust me.

-----------------------------------
BPhelmet
Tue Dec 21, 2004 10:06 pm


-----------------------------------
what's that += suppose to mean?

-----------------------------------
BPhelmet
Tue Dec 21, 2004 10:11 pm


-----------------------------------
o man,

i still don't get it, can you just download my program and help me fix it?

please

-----------------------------------
Neo
Tue Dec 21, 2004 10:15 pm


-----------------------------------
what's that += suppose to mean?

+= means to increment. Like x+=1, increases x by 1, same as x:=x+1 but shorter.

-----------------------------------
Cervantes
Tue Dec 21, 2004 10:19 pm


-----------------------------------
Tell us your problem.  Be specific.  Tell us the gory details.

-----------------------------------
Neo
Tue Dec 21, 2004 10:46 pm

Re: my school project, come in and help me out
-----------------------------------
this is my program, it is big because of the map.

it is a fighter plane game, my problem is i don't know how to make the plane shoot mutiple bullets and moving while shooting. 

OK, this example may help you out a bit.


var keys : array char of boolean
var x, y := 100
var bulletmax := 5
var shotX, shotY : array 1 .. bulletmax of int
var shoot : array 1 .. bulletmax of boolean
for num : 1 .. bulletmax
    shoot (num) := false
end for

setscreen ("offscreenonly")
colourback (black)
loop
    Input.KeyDown (keys)
    if keys (KEY_RIGHT_ARROW) then
        x += 2
    elsif keys (KEY_LEFT_ARROW) then
        x -= 2
    elsif keys (KEY_UP_ARROW) then
        y += 2
    elsif keys (KEY_DOWN_ARROW) then
        y -= 2
    end if
    if keys (KEY_SHIFT) and shoot (1) = false then
        shoot (1) := true
    end if
    
    if shoot (1) = true then
        for num : 2 .. bulletmax
            if shoot (num - 1) = true and Math.Distance (shotX (num - 1), shotY (num - 1), x, y) >= 75 and keys (KEY_SHIFT) and shoot (num) = false then
                shoot (num) := true
            end if
            if shotY (num - 1) >= maxy + 20 then
                shoot (num - 1) := false
            end if
        end for
    end if
    for num : 1 .. bulletmax
        if shoot (num) = true then
            shotY (num) += 3
            drawfilloval (round (shotX (num)), round (shotY (num)), 3, 3, brightred)
        elsif shoot (num) = false then
            shotX (num) := x
            shotY (num) := y
        end if
    end for

    drawfilloval (x, y, 10, 10, blue)

    delay (10)
    View.Update
    cls
end loop
