Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Need help with my Tank Game
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dragoon




PostPosted: Sun May 25, 2003 6:51 am   Post subject: (No subject)

Okay, thank you.
Sponsor
Sponsor
Sponsor
sponsor
Dragoon




PostPosted: Sun May 25, 2003 7:21 am   Post subject: (No subject)

I have one more question. How do i get my bullet to start where my tank is? Because each time i fire it fires where my tank started which is in the middle.
Tony




PostPosted: Sun May 25, 2003 11:05 am   Post subject: (No subject)

bulletX = tank's Curren Position X
bulletY = tank's Curren Position Y

but you do that only when the bullet is just fired
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dragoon




PostPosted: Sun May 25, 2003 11:22 am   Post subject: (No subject)

Do i have to do bulletX += TankX and bulletY += TankY? And i tried putting it under my Pic.Draw Bullet but nothing worked.

code:
setscreen ("graphics:800;500")
setscreen ("nocursor")
var Bullet : int
var Game : int
var Tank : int
var Tankx : int := 320
var Tanky : int := -230
var x : int := 0
var y : int := 1
var Tank2 : int
var bulletX : int := 80
var movementX : int := 0
var movementY : int := 1
var bulletY : int := -170
var bulletflag : boolean := false
var chars : array char of boolean

Game := Pic.FileNew ("Game2.bmp") %Locates the picture
Pic.Draw (Game, 0, 0, 2) %Draws the picture
Tank := Pic.FileNew ("Tank.bmp") %Locates the picture
Pic.Draw (Tank, Tankx, Tanky, 2) %Draws the picture
Bullet := Pic.FileNew ("bullet.bmp") %Locates the picture
Tank2 := Pic.FileNew ("Tank2.bmp") %Locates the picture
Pic.Draw (Tank2, 240, 220, 2) %Draws the picture


procedure moveBullet
    bulletX += movementX
    bulletY += movementY
    Pic.Draw (Bullet, bulletX, bulletY, 2)  %Draws the picture
    if bulletY >= 220 then
        bulletflag := false
        cls
        locate (20, 10)
        put "YOU WON!"
    end if

end moveBullet


loop
    Input.KeyDown (chars)
    if chars (KEY_ENTER) then
        bulletflag := true
    end if
    if bulletflag = true then
        moveBullet
    end if
    if chars (KEY_RIGHT_ARROW) then
        Pic.Draw (Game, 0, 0, 2)
        Pic.Draw (Tank, Tankx + x, Tanky, 2) %Draws the picture
        Pic.Draw (Tank2, 240, 220, 2) %Draws the picture
        x := x + 12


    end if
    if chars (KEY_LEFT_ARROW) then
        Pic.Draw (Game, 0, 0, 2)
        Pic.Draw (Tank, Tankx + x, Tanky, 2) %Draws the picture
        Pic.Draw (Tank2, 240, 220, 2) %Draws the picture
        x := x - 12

    end if

end loop

Tony




PostPosted: Sun May 25, 2003 11:24 am   Post subject: (No subject)

no...

code:

if chars (KEY_ENTER) then
        bulletflag := true
        bulletX = tankX
        bulletY = tankY
end if
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 20 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: