
-----------------------------------
Drean Grott
Mon Jan 23, 2006 12:32 am

Please Help my ship turn
-----------------------------------
Hi i'm very new and i'm having a problem i cant make my program turn very well. as you will see. I was woundering if some one could show me is there was a drawbox rotate or something like that. 

 setscreen ("graphics: 1010;700, nobuttonbar,nocursor")
View.Set ("offscreenonly")
colorback (blue)
cls
var x, x2, ix, ox, y, y2, w, w2, w3, d, d2, d3, d4, rep, a, a2, side : int
var xh, yh : int
var chars : array char of boolean
x := 300
y := 50
const xh2 := 33
const yh2 := 46
xh := 33
yh := 46
side := 0
ix := 0
ox := 0
d := 5
d2 := 5
d3 := 5
d4 := 5
rep := 0
a := 0
a2 := 0

process move
    Input.Pause
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) and side = 0 then
        y := y + 1
    elsif chars (KEY_UP_ARROW) and side = 1 then
        x := x + 1
    elsif chars (KEY_UP_ARROW) and side = 3 then
        x := x - 1
    elsif chars (KEY_UP_ARROW) and side = 2 then
        y := y - 1
    elsif chars (KEY_RIGHT_ARROW) and side = 0 then
        xh := yh2
        yh := xh2
        side := 1
    elsif chars (KEY_RIGHT_ARROW) and side = 1 then
        xh := xh2
        yh := yh2
        side := 2
    elsif chars (KEY_RIGHT_ARROW) and side = 2 then
        xh := yh2
        yh := xh2
        side := 3
    elsif chars (KEY_RIGHT_ARROW) and side = 3 then
        xh := xh2
        yh := yh2
        side := 0
         elsif chars (KEY_LEFT_ARROW) and side = 0 then
        xh := yh2
        yh := xh2
        side := 3
    elsif chars (KEY_LEFT_ARROW) and side = 1 then
        xh := xh2
        yh := yh2
        side := 0
    elsif chars (KEY_LEFT_ARROW) and side = 2 then
        xh := yh2
        yh := xh2
        side := 1
    elsif chars (KEY_LEFT_ARROW) and side = 3 then
        xh := xh2
        yh := yh2
        side :=2
    end if
end move

process drawship

    randint (w, 3, 5)
    if w > 3 then
        randint (w2, 3, 6)
        randint (w3, 3, 6)
    else
        randint (w2, 1, 3)
        randint (w3, 1, 3)
    end if
    loop

        if rep = 6 then
            randint (w, 3, 5)
            if w > 3 then
                randint (w2, 3, 6)
                randint (w3, 3, 6)
            else
                randint (w2, 1, 3)
                randint (w3, 1, 3)
            end if
            rep := 0
        end if
        rep := rep + 1

        cls
        drawline (x - xh, y - yh, x - xh, y + yh, 7)
        drawline (x - xh, y - yh, x + xh, y - yh, 7)
        drawline (x - xh, y + yh, x + xh, y + yh, 7)
        drawline (x + xh, y - yh, x + xh, y + yh, 7)
        drawfill (x - (xh - 2), y - (yh - 2), 185, 7)

        if side = 0 then
            %boaw
            drawarc (x + 39, y - 267, 115, 400, 110, 129, 7)
            drawarc (x - 41, y - 267, 119, 400, 51, 70, 7)
            drawfill (x, y + (yh + 1), 185, 7)

            %stiars
            for decreasing j : 35 .. 20 by 2
                drawline (x - 26, y - 22, x - 26, y - 35, 7)
                drawline (x - 32, y - j, x - 26, y - j, 7)
            end for
            %backmass
            drawarc (x, y - 25, 23, w + 1, 0, 180, 7)
            drawfillarc (x, y - 26, 23, w, 0, 180, 93)
            drawbox (x - 23, y - 33, x + 23, y - 27, 7)
            drawfill (x - 22, y - 30, 187, 7)
            drawoval (x, y - 30, 6, 6, 7)
            drawfilloval (x, y - 30, 5, 5, 187)

            %mainmass
            drawarc (x, y + 1, 25, w2 + 1, 0, 180, 7)
            drawfillarc (x, y + 1, 25, w2, 0, 180, 93)
            drawbox (x - 25, y - 7, x + 25, y - 1, 7)
            drawline (x - 25, y - 7, x - 25, y - 1, 7)
            drawline (x - 25, y - 7, x + 25, y - 7, 7)
            drawfill (x - 24, y - 3, 187, 7)
            drawoval (x, y - 3, 6, 6, 7)
            drawfilloval (x, y - 3, 5, 5, 187)

            %Frontmass
            drawarc (x, y + 27, 23, w3 + 1, 0, 180, 7)
            drawfillarc (x, y + 27, 23, w3, 0, 180, 93)
            drawbox (x - 27, y + 19, x + 27, y + 25, 7)
            drawfill (x - 26, y + 20, 187, 7)
            drawoval (x, y + 22, 6, 6, 7)
            drawfilloval (x, y + 22, 5, 5, 187)

        elsif side = 1 then
            %boaw
            drawarc (x - 266, y - 39, 400, 115, 20, 39, 7)
            drawarc (x - 267, y + 41, 400, 119, 321, 340, 7)
            drawfill (x + (xh + 1), y, 185, 7)

            %stiars
            for decreasing j : 35 .. 20 by 2
                drawline (x - 22, y + 26, x - 35, y + 26, 7)
                drawline (x - j, y + 32, x - j, y + 26, 7)
            end for

            %backmass
            drawarc (x - 25, y, w + 1, 23, 270, 90, 7)
            drawfillarc (x - 24, y, w, 23, 270, 90, 93)
            drawbox (x - 33, y - 23, x - 27, y + 23, 7)
            drawfill (x - 32, y - 22, 187, 7)
            drawoval (x - 30, y, 6, 6, 7)
            drawfilloval (x - 30, y, 5, 5, 187)

            %mainmass
            drawarc (x + 1, y, w2 + 1, 25, 270, 90, 7)
            drawfillarc (x + 1, y, w2, 25, 270, 90, 93)
            drawbox (x - 7, y - 25, x - 1, y + 25, 7)
            drawfill (x - 6, y - 24, 187, 7)
            drawoval (x - 3, y, 6, 6, 7)
            drawfilloval (x - 3, y, 5, 5, 187)

            %Frontmass
            drawarc (x + 27, y, w3 + 1, 23, 270, 90, 7)
            drawfillarc (x + 27, y, w3, 23, 270, 90, 93)
            drawbox (x + 19, y + 23, x + 25, y - 23, 7)
            drawfill (x + 20, y + 22, 187, 7)
            drawoval (x + 22, y, 6, 6, 7)
            drawfilloval (x + 22, y, 5, 5, 187)

        elsif side = 2 then

            %boaw
            drawarc (x - 39, y + 267, 115, 400, 290, 309, 7)
            drawarc (x + 42, y + 267, 119, 400, 231, 250, 7)
            drawfill (x, y - (yh + 1), 185, 7)

            %stiars
            for decreasing j : 35 .. 20 by 2
                drawline (x + 26, y + 22, x + 26, y + 35, 7)
                drawline (x + 32, y + j, x + 26, y + j, 7)
            end for

            %backmass
            drawarc (x, y + 25, 23, w + 1, 180, 360, 7)
            drawfillarc (x, y + 26, 23, w, 180, 360, 93)
            drawbox (x + 23, y + 33, x - 23, y + 27, 7)
            drawfill (x + 22, y + 30, 187, 7)
            drawoval (x, y + 30, 6, 6, 7)
            drawfilloval (x, y + 30, 5, 5, 187)

            %mainmass
            drawarc (x, y - 1, 25, w2 + 1, 180, 360, 7)
            drawfillarc (x, y + 1, 25, w2, 180, 360, 93)
            drawbox (x + 25, y + 7, x - 25, y + 1, 7)
            drawfill (x + 24, y + 3, 187, 7)
            drawoval (x, y + 3, 6, 6, 7)
            drawfilloval (x, y + 3, 5, 5, 187)

            %Frontmass
            drawarc (x, y - 27, 23, w3 + 1, 180, 360, 7)
            drawfillarc (x, y - 27, 23, w3, 180, 360, 93)
            drawbox (x + 27, y - 19, x - 27, y - 25, 7)
            drawfill (x + 26, y - 20, 187, 7)
            drawoval (x, y - 22, 6, 6, 7)
            drawfilloval (x, y - 22, 5, 5, 187)


        elsif side = 3 then
            %boaw
            drawarc (x + 266, y - 39, 400, 115, 141, 160, 7)
            drawarc (x + 267, y + 41, 400, 119, 200, 219, 7)
            drawfill (x - (xh + 1), y, 185, 7)
            %stiars
            for decreasing j : 35 .. 20 by 2
                drawline (x + 22, y - 26, x + 35, y - 26, 7)
                drawline (x + j, y - 32, x + j, y - 26, 7)
            end for

            %backmass
            drawarc (x + 25, y, w + 1, 23, 90, 270, 7)
            drawfillarc (x + 24, y, w, 23, 90, 270, 93)
            drawbox (x + 33, y + 23, x + 27, y - 23, 7)
            drawfill (x + 32, y + 22, 187, 7)
            drawoval (x + 30, y, 6, 6, 7)
            drawfilloval (x + 30, y, 5, 5, 187)

            %mainmass
            drawarc (x - 1, y, w2 + 1, 25, 90, 270, 7)
            drawfillarc (x - 1, y, w2, 25, 90, 270, 93)
            drawbox (x + 7, y + 25, x + 1, y - 25, 7)
            drawfill (x + 6, y + 24, 187, 7)
            drawoval (x + 3, y, 6, 6, 7)
            drawfilloval (x + 3, y, 5, 5, 187)

            %Frontmass
            drawarc (x - 27, y, w3 + 1, 23, 90, 270, 7)
            drawfillarc (x - 27, y, w3, 23, 90, 270, 93)
            drawbox (x - 19, y - 23, x - 25, y + 23, 7)
            drawfill (x - 20, y - 22, 187, 7)
            drawoval (x - 22, y, 6, 6, 7)
            drawfilloval (x - 22, y, 5, 5, 187)
        end if

        fork move

        View.Update
        delay (20)
    end loop
end drawship

fork drawship


this is actully a small part of a larger program. I"m not asking you to do it for me but to just suggest how best to slove the jerky turn problem.
thank you

ps. it is very late and I'm very tried sorry for any spelling errors

-----------------------------------
blaster009
Mon Jan 23, 2006 2:13 am


-----------------------------------
That's quite the line animation you've got there :)  It looks really good.  To limit the turning, you can do many of several things: The best idea would be to put in a timer that takes the last time the ship turned, and tell the program not to turn until a certain amount of time has passed since that last turn.  Or you can take the lazy way out and stick a delay in (usually not a good idea).  You might want to look up Time.Elapsed and how to use functions.  That'll set you and your ship sailing in the right direction.

-----------------------------------
blaster009
Mon Jan 23, 2006 2:15 am


-----------------------------------
Oh, and I hate to double post, but you might want to take your program out of processes, and put them in a loop instead.  Forking processes tends to get really laggy and really messy in Turing.  :wink:

-----------------------------------
Drean Grott
Mon Jan 23, 2006 12:57 pm

No i mean...
-----------------------------------
No i meen that i don't want the ship to go striaght on the x or y axis. I'm trying to make the ship have a smooth turn on a cruve. like a real ship would turn. 


Thanks for all your help

-----------------------------------
Rasta Fella
Mon Jan 23, 2006 4:20 pm


-----------------------------------
I get the drift of what you want to do but I'cant seem to find a way to do this but If you are good a decyphering code you should check the "Space Game". Which is located under Turing->Support->Games->Space Game. It uses somewhat what you are trying to achieve but with a spaceship.

-----------------------------------
blaster009
Mon Jan 23, 2006 5:10 pm


-----------------------------------
Trigonmetry, my friend.  Use of slopes, speeds and tangents.  There's a tutorial around here for it somewhere...

-----------------------------------
Drean Grott
Mon Jan 23, 2006 5:11 pm

reply
-----------------------------------
Thanks for the help. I looked at the space game and found that the ship was a pic then they used the rotate picture command. so i still need help plaese anyone?

-----------------------------------
blaster009
Mon Jan 23, 2006 5:14 pm


-----------------------------------
Replace your line art with a ship from a file (Bitmap or otherwise).  Then, use Pic.Rotate to assign various rotations of it to an array.  After that, it gets a little more difficult.  As I mentioned, you're going to need to start using trigonometry and slopes to determine the direction and speed that your ship should be moving at.
