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

Username:   Password: 
 RegisterRegister   
 Tank Motion
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheXploder




PostPosted: Tue Jan 20, 2004 5:40 pm   Post subject: Tank Motion

I have a problem with the motion of the tank the only thing that is bothering me is that the point that the tank rotates around doesn't move along with the tank...

Any help is grately appreciated. Razz



TANK_GAME.zip
 Description:

Download
 Filename:  TANK_GAME.zip
 Filesize:  1.72 KB
 Downloaded:  123 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Tue Jan 20, 2004 5:58 pm   Post subject: (No subject)

post the code not the exe.... if you need help its kinda hard to help you without the code to know what you've done.
TheXploder




PostPosted: Tue Jan 20, 2004 6:23 pm   Post subject: (No subject)

huh? well I didn't post an .exe file...

The image is 60x60 pixels, you'll need that aswell.

code:

import GUI in "%oot/lib/GUI"
var amountOfImages : int
amountOfImages := 2

setscreen ("noecho")
setscreen ("nocursor")

var pic : array 1 .. amountOfImages of int
var keyPress : string (1)
var x, y : int := 0
var speed : int := 1
var s : int := 0
var r : int := 0

const pi := 3.14159

Pic.ScreenLoad ("tank2" + ".bmp", 0, 0, picCopy)
pic (1) := Pic.New (0, 0, 60, 60)

proc objTank (x, y, rotation, num : int)
    var rotate : int := Pic.Rotate (pic (num), rotation, 30, 30 /* - rotation Center Point x,y*/)
    Pic.Draw (rotate, x, y, picCopy)
end objTank

process move
    loop
        getch (keyPress)
    end loop
end move

proc Movement
    loop
        objTank (100 + x, 100 + y, r, 1)

        delay (50)

        locate (1, 1)

        put "Rotation: ", r
        put "X:", x
        put "Y:", y

        if keyPress = KEY_UP_ARROW then
            keyPress := ""
            speed := speed - 2
        end if
        if keyPress = KEY_DOWN_ARROW then
            keyPress := ""
            speed := speed + 2
        end if
        if keyPress = KEY_RIGHT_ARROW then
            keyPress := ""
            r := r - 10
            if r <= -360 then
                r := 0
            end if
        end if
        if keyPress = KEY_LEFT_ARROW then
            keyPress := ""
            r := r + 10
            if r >= 360 then
                r := 0
            end if
        end if

        x := round (sin (r * (pi / 180)) * speed)

        y := round (cos (r * (pi / 180)) * speed * -1)

    end loop
end Movement

process rotation
    keyPress := "0"
    loop
        Movement
    end loop
end rotation

fork rotation
fork move
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 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: