
-----------------------------------
TheXploder
Tue Jan 20, 2004 5:40 pm

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.  :P

-----------------------------------
Cervantes
Tue Jan 20, 2004 5:58 pm


-----------------------------------
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
Tue Jan 20, 2004 6:23 pm


-----------------------------------
huh? well I didn't post an .exe file...

The image is 60x60 pixels, you'll need that aswell.


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

        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

