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

Username:   Password: 
 RegisterRegister   
 Walking animation help
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Monduman11




PostPosted: Tue Jun 08, 2010 5:31 pm   Post subject: Walking animation help

What is it you are trying to achieve?
i am trying to make my character look as if he is walking instead of just gliding


What is the problem you are having?
i cant seem to get it to work


Describe what you have tried to solve this problem
everything i can think of


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
below

Turing:


Input.KeyDown (chars)
if chars (KEY_LEFT_ARROW)
        then
    loop
        steps += 1
        Pic.Draw (PicName (steps mod pic#))
        if chars (KEY_LEFT_ARROW = false)
            steps := 0
            exit
        end if
    end loop



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Cezna




PostPosted: Tue Jun 08, 2010 5:37 pm   Post subject: RE:Walking animation help

The simplest way would be to draw the character at multiple stages of his run, taking pictures of each, and then either draw these pictures sequentially with Turing, or upload them into another program such as Power Point and make a .gif out of it.

You can also check this link to another thread in which someone posted a "Mario Movement Test", which does exactly what it sounds like you are trying to do.

Link:
http://compsci.ca/v3/viewtopic.php?t=24269&highlight=mario
Monduman11




PostPosted: Tue Jun 08, 2010 5:51 pm   Post subject: Re: Walking animation help

ah thank you so much... and btw in your welcome thread i cant reply cause for some reason its set to only mods and admins
Cezna




PostPosted: Tue Jun 08, 2010 5:53 pm   Post subject: RE:Walking animation help

Hmmmm.... just mine? Or are all of the welcome threads like that?
Monduman11




PostPosted: Tue Jun 08, 2010 5:54 pm   Post subject: Re: Walking animation help

im not sure cause ive only tried urs.... hold on ill go check Razz
edit: i checked and it seems that everyones is like that... wonder why
Cezna




PostPosted: Tue Jun 08, 2010 5:57 pm   Post subject: RE:Walking animation help

They're probably not supposed to develop into full-fledged conversations.
Btw, I'm the chat room right now.
Feel free to jump in.
Monduman11




PostPosted: Tue Jun 08, 2010 5:58 pm   Post subject: Re: Walking animation help

i would but i cant.. for some reason it gives me an error
Monduman11




PostPosted: Tue Jun 08, 2010 6:01 pm   Post subject: Re: Walking animation help

im attaching a picture so u can see for yourself lol


chat.jpg
 Description:
chat error
 Filesize:  82.7 KB
 Viewed:  83 Time(s)

chat.jpg


Sponsor
Sponsor
Sponsor
sponsor
Cezna




PostPosted: Tue Jun 08, 2010 6:01 pm   Post subject: RE:Walking animation help

It's probably filtering it out.
Try closing the page, then coming back (I mean close your browser), and then set it to allow "potentially unsafe content" if/when it prompts you
I had the same problem, and doing that fixed it.
edit : just saw the attachment, I had that EXACT same error message
Monduman11




PostPosted: Tue Jun 08, 2010 6:11 pm   Post subject: Re: Walking animation help

here it is
Turing:

var chars : array char of boolean
var x, y : array 0 .. 5 of int
var bullet, Posx, Posy : int := 0
var bullettrue : array 0 .. 5 of boolean := init (false, false, false, false, false, false)
var ball : int := Pic.FileNew ("fire.bmp")
process bulletshoot
    loop
        for z : 0 .. 5
            if bullettrue (z) then
                x (z) += 5
                Pic.Draw (ball, x (z), y (z), picMerge)
                if x (z) > maxx then
                    bullettrue (z) := false
                end if
            end if

        end for
        delay (10)
        cls
        View.Update
    end loop
end bulletshoot
fork bulletshoot
loop
    Input.KeyDown (chars)
    if chars ('s') and bullettrue ((bullet + 1) mod 6) = false
            then
        bullet += 1
        x (bullet mod 6) := Posx
        y (bullet mod 6) := Posy
        bullettrue (bullet mod 6) := true
        loop
            Input.KeyDown (chars)
            exit when chars ('s') = false
        end loop
    end if
end loop




fire.bmp
 Description:
here is the pic
 Filesize:  918 Bytes
 Viewed:  3541 Time(s)

fire.bmp


Cezna




PostPosted: Tue Jun 08, 2010 6:16 pm   Post subject: RE:Walking animation help

Here's a link to a post that explains why processes are bad.
http://compsci.ca/v3/viewtopic.php?t=7842
Monduman11




PostPosted: Tue Jun 08, 2010 6:48 pm   Post subject: Re: Walking animation help

Here is the shooting without a process.

Turing:

View.Set ("graphics:500;500,offscreenonly,nobuttonbar,title:Shooting")
var ball1 : int := Pic.FileNew ("fire.bmp")
const NUM_BULLETS := 6


type bullet :
    record
        x : int
        y : int
        isAlive : boolean
    end record


function newBullet (newX, newY : int, newIsAlive : boolean) : bullet
    var b : bullet
    b.x := newX
    b.y := newY
    b.isAlive := newIsAlive
    result b
end newBullet


var bullets : array 0 .. NUM_BULLETS of bullet

var keys : array char of boolean
var preKeys : array char of boolean

for i : 1 .. NUM_BULLETS
    bullets (i) := newBullet (0, 0, false)
end for

procedure Update ()
    Input.KeyDown (keys)


    if (keys ('s') and ~preKeys ('s')) then

        for i : 1 .. NUM_BULLETS
            if ( ~bullets (i).isAlive) then
                bullets (i).x := 0
                bullets (i).y := 50
                bullets (i).isAlive := true
                exit
            end if
        end for
    end if


    for i : 1 .. NUM_BULLETS

        if (bullets (i).isAlive) then

            bullets (i).x += 10


            if (bullets (i).x > maxx) then
                bullets (i).isAlive := false
            end if
        end if
    end for


    preKeys := keys
end Update

procedure Draw_ ()
    cls

    for i : 1 .. NUM_BULLETS
        if (bullets (i).isAlive) then

            Pic.Draw (ball1, bullets (i).x, bullets (i).y, picMerge)
        end if
    end for

    View.Update ()
end Draw_

loop
    Update ()
    Draw_ ()

    Time.DelaySinceLast (33)
end loop


I didint really want to use this one cause TerranceN helped me with it when i couldnt figure out how to do it without a process.
but yea if you could somehow help id appreciate it
Cezna




PostPosted: Wed Jun 09, 2010 7:12 pm   Post subject: RE:Walking animation help

I can't do anything without the picture Wink
Monduman11




PostPosted: Wed Jun 09, 2010 7:59 pm   Post subject: Re: Walking animation help

lol its the pic in the attachment Razz


fire.bmp
 Description:
here it is again
 Filesize:  2.63 KB
 Viewed:  3477 Time(s)

fire.bmp


Insectoid




PostPosted: Wed Jun 09, 2010 8:01 pm   Post subject: RE:Walking animation help

@Cezna, You could keep a stock image around for just this type of situation. I find it very helpful.

Anyway, what you want is an array of images with the character in different stages of walking. Keep a counter of what image is being used, and then say, if the left arrow key is pressed, increment the counter by 1 and instead of

Pic.Draw ("Whatever.bmp"), you'd have

Pic.Draw (picArray(counter)).

Using a 2d array of left and right images, you can swap which direction the character is facing for left or right movement using a direction variable. For example (a very pseudo-code-y, incomplete example),

code:

%pics at (0)(0-24) are left-facing, pics at (1)(0-24) are right-facing
var picArray : array 0..1, 0..24 of int
var counter : int := 0
var direction : int := 0

proc animate
        if counter = 24 then
            counter := 0
        else
            counter += 1
        end if
end animate
loop
    if (left arrow pressed) then
        direction := 0
       animate
    elsif (right arrow pressed) then
        direction := 1
        animate
    end if
    Pic.Draw (x, y, picArray(direction)(counter))
end loop


You could add an idle pic so if no key is pressed it switches to a default image so he doesn't freeze mid-stride (lawl).
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 2  [ 27 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: