
-----------------------------------
luckyduckstr
Mon Oct 28, 2013 8:09 am

Animation Game with Arrow Keys?
-----------------------------------
What is it you are trying to achieve?
Im trying to create a game with sprites
and when the arrow keys are pressed itll show a certain animation of the sprite doing it
e.g. when i press right itll show 20 frames of the character running

What is the problem you are having?
how do i make it so that it the character will move in the screen but the character will also go through the 20 frames 

Please specify what version of Turing you are using
4.1.1

-----------------------------------
DemonWasp
Mon Oct 28, 2013 1:50 pm

RE:Animation Game with Arrow Keys?
-----------------------------------
What have you tried so far?

-----------------------------------
luckyduckstr
Tue Oct 29, 2013 1:21 pm

RE:Animation Game with Arrow Keys?
-----------------------------------
ill ive done so far is to make the sprite run through the 20 frames

-----------------------------------
DemonWasp
Tue Oct 29, 2013 2:51 pm

RE:Animation Game with Arrow Keys?
-----------------------------------
Okay, so what's preventing you from changing the coordinates that you draw at from one frame to the next?

-----------------------------------
luckyduckstr
Fri Nov 01, 2013 7:35 am

RE:Animation Game with Arrow Keys?
-----------------------------------
ive done this 
loop
    Input.KeyDown (chars)
    %
    %If the user presses the Up arrow key
    %
    if chars (KEY_UP_ARROW) then
        %Hides the standing still sprite
        Sprite.Hide (standR)
        Sprite.Hide (standL)

        % Loading each picture into the array
        for i : 1 .. 11
            pics (i - 1) := Pic.FileNew ("up" + intstr (i) + ".bmp")
            if Error.Last not= 0 then
                put "Error loading image: ", Error.LastMsg
                return
            end if
        end for
        sprite := Sprite.New (pics (0))

        %Animate picture
        for i : 1 .. 11
            Sprite.ChangePic (sprite, pics (i mod 10))
            Sprite.SetPosition (sprite, maxx div 2, maxy div 2, true)
            Sprite.Show (sprite)
            delay (100)
        end for
        Sprite.Free (sprite)
        Sprite.SetPosition (standR, maxx div 2, maxy div 2, true)
        Sprite.Show (standR)
    end if
end loop 
however when i add a "+50" to the maxy div 2 it shows the sprite move the 50 then go through the animation 
how should i place the movement in between the animation

-----------------------------------
luckyduckstr
Fri Nov 01, 2013 7:37 am

RE:Animation Game with Arrow Keys?
-----------------------------------
i also have this before the top coding
%Declare Variables
var chars : array char of boolean
var pics : array 0 .. 45 of int
var sprite, standR, standRID, standL, standLID : int

%Initialize standing sprite
standRID := Pic.FileNew ("standR.bmp")
standR := Sprite.New (standRID)
standLID := Pic.FileNew ("standL.bmp")
standL := Sprite.New (standLID)

%Starting picture
Sprite.SetPosition (standL, maxx div 2, maxy div 2, true)
Sprite.Show (standL)

-----------------------------------
tiedye1
Tue Dec 17, 2013 9:59 pm

Re: Animation Game with Arrow Keys?
-----------------------------------
Hi,

In the future would you please use code tags? [code]Code![/code]

So to make your gut move your have to change the position of the sprite each time you draw a frame:
[code]
loop
    Input.KeyDown (chars)
    %
    %If the user presses the Up arrow key
    %
    if chars (KEY_UP_ARROW) then
        %Hides the standing still sprite
        Sprite.Hide (standR)
        Sprite.Hide (standL)

        % Loading each picture into the array
        for i : 1 .. 11
            pics (i - 1) := Pic.FileNew ("up" + intstr (i) + ".bmp")
            if Error.Last not= 0 then
                put "Error loading image: ", Error.LastMsg
                return
            end if
        end for
        sprite := Sprite.New (pics (0))

        %Animate picture
        for i : 1 .. 11
            Sprite.ChangePic (sprite, pics (i mod 10))
%-->        Increase (or decrease) the x or y value here each time you change the pic
            Sprite.SetPosition (sprite, maxx div 2 + i, maxy div 2, true)
            Sprite.Show (sprite)
            delay (100)
        end for
        Sprite.Free (sprite)
        Sprite.SetPosition (standR, maxx div 2, maxy div 2, true)
        Sprite.Show (standR)
    end if
end loop

[/code]

-----------------------------------
Raknarg
Tue Dec 17, 2013 10:41 pm

RE:Animation Game with Arrow Keys?
-----------------------------------
For future reference, always check the date on the last post before you post.
