Debian Codegraph @

src/tank.cpp

raw symbols SCIP
1 /***************************************************************************
2 tank.cpp - description
3 -------------------
4 begin : Fri Dec 29 2000
5 copyright : (C) 2000 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 #include "tank.h"
18
19 #define MAX_STATE 20
20
21 Tank::Tank(unsigned int full_level):AnimatedCanvas(){
22 this->full_level=full_level%(Capacity-1);
23 state=0;
24 changed=true;
25 }
26
27 Tank::~Tank(){}
28
29 void Tank::decFullLevel(unsigned int amount){
30 if (full_level>0 && (unsigned int)full_level>amount)
31 full_level-=amount;
32 else full_level=0;
33 changed=true;
34 }
35
36 bool Tank::isEmpty(){
37 return full_level<=0;
38 }
39
40 bool Tank::isChanged(){
41 return changed;
42 }
43
44 void Tank::paint(VideoManager * vm){
45 int f=(int)((float)TankHeight*(float)full_level/(float)Capacity);
46 Image * ima;
47
48 // Borra
49 vm->fillRect(x,y,TankWidth,TankHeight-f, 0,0,0,OPAQUE);
50 //Dibuja el liquido
51 vm->fillRect(x,y+TankHeight-f, TankWidth, f, 103,234,16,OPAQUE);
52 //Pinta el frente
53 ima=(vm->getImageManager())->getImage(new Str("tank.png"));
54 vm->blit(ima,x,y);
55 changed=false;
56 }
57
58 void Tank::tick(){
59 state=(state+1)%MAX_STATE;
60 }
61
62