Debian Codegraph @

src/paper.cpp

raw symbols SCIP
1 /***************************************************************************
2 paper.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 "paper.h"
19 #include "sprite.h"
20 #include "random.h"
21
22 const int Paper::DeltaY=5;
23 const int Paper::NFrames=5;
24
25 Paper::Paper(int maxY, PaperColor color, ImageManager * im):AnimatedCanvas(){
26
27 this->maxY=maxY;
28 Random ran=Random();
29 frame=ran.getRandomNumber(0, NFrames);
30 l_width=20;
31 l_height=12;
32
33 Str * filenamebase;
34
35 switch (color){
36 case Red:{filenamebase =new Str("red_paper");break;}
37 case Blue:{filenamebase =new Str("blue_paper");break;}
38 case Green:{filenamebase =new Str("green_paper");break;}
39 }
40 sprite=new Sprite(filenamebase, new Str(".png"), NFrames, im);
41 }
42
43 Paper::~Paper(){
44 delete sprite;
45 }
46
47 int Paper::width(){
48 return l_width;
49 }
50
51 int Paper::height(){
52 return l_height;
53 }
54
55
56 void Paper::paint(VideoManager * vm){
57 vm->blit(sprite->frame(vm->getImageManager(), frame), x, y);
58 }
59
60 void Paper::tick(){
61 frame=(frame+1)%NFrames;
62 y=(y+DeltaY)%maxY;
63 }