• Advertisement
Sign in to follow this  

why won't this animation work .

This topic is 3553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, ok, half noob here. Got some code that's not working, so. . .if you guys wouldn't mind taking a look at it and giving me some input, that'd be awesome. This is a animation I'm working on for a project(remaking a Zelda dungeon). I've done other animation before, but I wanna learn to do it through timers. main.cpp
Quote:
#include <allegro.h> #include "link.h" int charactermove(int positionX, int positionY, BITMAP *sprite1, BITMAP *sprite2, BITMAP *sprite3, BITMAP *buffer); volatile int ticks = 0; inline void ticker( ) { ++ticks; } END_OF_FUNCTION(ticker) int frame = 0; int main(){ allegro_init(); install_keyboard(); set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); LOCK_VARIABLE(ticks); LOCK_FUNCTION(ticker); link l; int nTick; install_int_ex(ticker, BPS_TO_TIMER(60)); nTick = ticks; ticks = 0; for(; nTick > 0; --nTick) { l.loadbitmaps(); frame++; if( frame == 240) { frame = 0; } } while(!key[KEY_ESC]) { draw_sprite( screen, l.buffer, 0, 0); draw_sprite( l.buffer, l.linkleft1, l.linkX, l.linkY); charactermove(l.linkX, l.linkY, l.linkleft2, l.linkleft3, l.linkleft1, l.buffer); clear_bitmap(l.buffer); } } END_OF_MAIN(); int charactermove(int positionX, int positionY, BITMAP *sprite1, BITMAP *sprite2, BITMAP *sprite3, BITMAP *buffer) { if(key[KEY_RIGHT]) { positionX++; if( frame < 60 ) { draw_sprite(buffer, sprite1, positionX, positionY); } else if( frame > 60 && frame < 120 ) { draw_sprite(buffer, sprite2, positionX, positionY); } else if(frame > 120 && frame < 180 ) { draw_sprite(buffer, sprite1, positionX, positionY); } else if(frame > 180 && frame < 240 ) { draw_sprite(buffer, sprite3, positionX, positionY); } } }
link.h
Quote:
#include <allegro.h> class link { public: link (); void loadbitmaps(); BITMAP *linkleft1; BITMAP *linkleft2; BITMAP *linkleft3; BITMAP *buffer; int linkX; int linkY; protected: };
link.cpp
Quote:
#include "link.h" link::link () { linkX = 100; linkY = 100; } void link::loadbitmaps() { linkleft1 = load_bitmap("move2.bmp", NULL); linkleft2 = load_bitmap("move1.bmp", NULL); linkleft3 = load_bitmap("move3.bmp", NULL); buffer = create_bitmap(480, 640); }
Thanks in advance for the help guys. LH

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement