I'm working on a dragon riding game.
So far I can make the dragon walk left and right and have it walk backwards left or right. I also made it so that when you press DOWN the dragon changes directions.
But what I really want is for the turning animation to be played while turning, I've been trying different things with the code but I just can't seem to get it to work properly.
The laptop I'm working on has no way of getting something off it but my code follows this logic:
Ok so the problem is with playing the turning animation from the sprite sheet.
Those sprite are in the middle of the sheet, so what I did was (when down is pressed) set 'currentframe' to the start of the animation (frame 7) and have it increment to 9 and set it to the standing pose (0 or 13).
But I just cant seem to pull of this piece properly.
Has anyone of you done something similar to this?
I forgot how to do the code tags
See that big button above the reply box that says "Formatting Help"? Click it.
Code tags use angle brackets, like this : <code>code goes here...</code>
There's a simple animation class for Allegro 4 here if you want to use it. It has support for forwards / backwards / forwards and back animations, once or in a loop. It tells you when the animation is done so you can set a new one. All you have to do is declare an animation, tell it how many frames and how long to run for each loop, set each frame, and then call AdvanceFrameTime when your timer ticks and DrawOn when you need to draw. Since you have several animations, you would probably want to use a pointer to an animation and change what the pointer points to when you change animations.
I suggest you learn to make tic tac toe or a game of rock paper scissors first, you lack basic programming skills
Don't pay any attention to van_houtte, he's disgruntled because he works overnights and doesn't have any friends.
he's disgruntled because he works overnights and doesn't have any friends.
Not to mention he can't use the tools of the trade...
KLAXXZ GAME MAKER is the tool of the trade
Well yeah, there IS alot for me to learn, but I have made a rock paper scissors type monster fighting game before
I don't have allegro 4. I had 2 computers with a compiler/allegro on it, one is in the shop waiting to be fixed and the other has busted usb ports and got allegro before 4 came out.
But I tried to analyze the animation class that you should me, I changed my code to use switch/case, but now it doesn't even go.
If you want help, show code. We're not mind readers.
Ok, so I finally got it to work. The problem was that I had the down code modeled after the left and right code
if(dir==1)//left { if(key[KEY_LEFT]) //looking left and going left { x++; curframe ++; if(curframe > 4) { curframe =1; } }
What I did was added a while loop and took out the if statement
//down button (turning action) if(dir=1) { curframe = 4; while(key[KEY_DOWN]) { curframe++; if(curframe > 7)//last frame in turn animation { curframe = 12; //standing facing the opposite direction } } dir=2; }
Putting everything in switches helped.
What I did was added a while loop and took out the if statement
//down button (turning action) if(dir=1) { curframe = 4; while(key[KEY_DOWN]) { curframe++; if(curframe > 7)//last frame in turn animation { curframe = 12; //standing facing the opposite direction } } dir=2; }
Putting everything in switches helped.
You do know that that while loop will almost always result in curframe being 12, and whenever dir equals 1 it will be set to 2 right? That doesn't sound like it does what you want it to.
I think you should take a look at the link to the animation class I posted earlier in this thread. If you use it, your code could be as simple as this :