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

Username:   Password: 
 RegisterRegister   
 Animation Game with Arrow Keys?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
luckyduckstr




PostPosted: Mon Oct 28, 2013 8:09 am   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Mon Oct 28, 2013 1:50 pm   Post subject: RE:Animation Game with Arrow Keys?

What have you tried so far?
luckyduckstr




PostPosted: Tue Oct 29, 2013 1:21 pm   Post subject: RE:Animation Game with Arrow Keys?

ill ive done so far is to make the sprite run through the 20 frames
DemonWasp




PostPosted: Tue Oct 29, 2013 2:51 pm   Post subject: 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




PostPosted: Fri Nov 01, 2013 7:35 am   Post subject: 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




PostPosted: Fri Nov 01, 2013 7:37 am   Post subject: 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




PostPosted: Tue Dec 17, 2013 9:59 pm   Post subject: Re: Animation Game with Arrow Keys?

Hi,

In the future would you please use code tags?
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

Raknarg




PostPosted: Tue Dec 17, 2013 10:41 pm   Post subject: RE:Animation Game with Arrow Keys?

For future reference, always check the date on the last post before you post.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: