| 1 | /*************************************************************************** |
| 2 | fire.cpp - description |
| 3 | ------------------- |
| 4 | begin : Fri Jan 18 2002 |
| 5 | copyright : (C) 2002 by Waldemar Baraldi |
| 6 | email : [email protected] |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | /*************************************************************************** |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #include "fire.h" |
| 19 | #include "sprite.h" |
| 20 | #include "random.h" |
| 21 | |
| 22 | const int Fire::NFrames=2; |
| 23 | |
| 24 | Fire::Fire(ImageManager * im):AnimatedCanvas(){ |
| 25 | |
| 26 | l_width=8; |
| 27 | l_height=14; |
| 28 | c=0; |
| 29 | frame=0; |
| 30 | |
| 31 | sprite=new Sprite(new Str("fire"), new Str(".png"), NFrames, im); |
| 32 | } |
| 33 | |
| 34 | Fire::~Fire(){ |
| 35 | delete sprite; |
| 36 | } |
| 37 | |
| 38 | int Fire::width(){ |
| 39 | return l_width; |
| 40 | } |
| 41 | |
| 42 | int Fire::height(){ |
| 43 | return l_height; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | void Fire::paint(VideoManager * vm){ |
| 48 | vm->blit(sprite->frame(vm->getImageManager(), frame), x, y); |
| 49 | } |
| 50 | |
| 51 | void Fire::tick(){ |
| 52 | if (c++%6==0) frame=(frame+1)%NFrames; |
| 53 | } |