| 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"cxx . . $ `<file>/src/paper.h`/ |
| 19 | #include "sprite.h"cxx . . $ `<file>/src/sprite.h`/ |
| 20 | #include "random.h"cxx . . $ `<file>/src/random.h`/ |
| 21 | |
| 22 | const int Papercxx . . $ Paper#::DeltaYcxx . . $ Paper#DeltaY.=5; |
| 23 | const int Papercxx . . $ Paper#::NFramescxx . . $ Paper#NFrames.=5; |
| 24 | |
| 25 | Papercxx . . $ Paper#::Papercxx . . $ Paper#Paper(5c34b3c18f01d176).(int maxY, PaperColorcxx . . $ Paper#PaperColor# color, ImageManagercxx . . $ ImageManager# * im):AnimatedCanvascxx . . $ AnimatedCanvas#(){ |
| 26 | |
| 27 | this->maxYcxx . . $ Paper#maxY.=maxY; |
| 28 | Randomcxx . . $ Random# ran=Randomcxx . . $ Random#Random(49f6e7a06ebc5aa8).(); |
| 29 | framecxx . . $ Paper#frame.=ran.getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, NFramescxx . . $ Paper#NFrames.); |
| 30 | l_widthcxx . . $ Paper#l_width.=20; |
| 31 | l_heightcxx . . $ Paper#l_height.=12; |
| 32 | |
| 33 | Strcxx . . $ Str# * filenamebase; |
| 34 | |
| 35 | switch (color){ |
| 36 | case Redcxx . . $ Paper#Red.:{filenamebase =new Strcxx . . $ Str#("red_paper");break;} |
| 37 | case Bluecxx . . $ Paper#Blue.:{filenamebase =new Strcxx . . $ Str#("blue_paper");break;} |
| 38 | case Greencxx . . $ Paper#Green.:{filenamebase =new Strcxx . . $ Str#("green_paper");break;} |
| 39 | } |
| 40 | spritecxx . . $ Paper#sprite.=new Spritecxx . . $ Sprite#Sprite(7c5e60030c36ad17).(filenamebase, new Strcxx . . $ Str#(".png"), NFramescxx . . $ Paper#NFrames., im); |
| 41 | } |
| 42 | |
| 43 | Papercxx . . $ Paper#::~cxx . . $ Paper#`~Paper`(ced63f7c635d850d).Papercxx . . $ Paper#(){ |
| 44 | delete spritecxx . . $ Paper#sprite.; |
| 45 | } |
| 46 | |
| 47 | int Papercxx . . $ Paper#::widthcxx . . $ Paper#width(b126dc7c1de90089).(){ |
| 48 | return l_widthcxx . . $ Paper#l_width.; |
| 49 | } |
| 50 | |
| 51 | int Papercxx . . $ Paper#::heightcxx . . $ Paper#height(b126dc7c1de90089).(){ |
| 52 | return l_heightcxx . . $ Paper#l_height.; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | void Papercxx . . $ Paper#::paintcxx . . $ Paper#paint(dec28a01b93bce57).(VideoManagercxx . . $ VideoManager# * vm){ |
| 57 | vm->blitcxx . . $ VideoManager#blit(d6e51777aa68e081).(spritecxx . . $ Paper#sprite.->framecxx . . $ Sprite#frame(e8d7ae696153184b).(vm->getImageManagercxx . . $ VideoManager#getImageManager(d5fe12bbc8163445).(), framecxx . . $ Paper#frame.), xcxx . . $ Canvas#x., ycxx . . $ Canvas#y.); |
| 58 | } |
| 59 | |
| 60 | void Papercxx . . $ Paper#::tickcxx . . $ Paper#tick(49f6e7a06ebc5aa8).(){ |
| 61 | framecxx . . $ Paper#frame.=(framecxx . . $ Paper#frame.+1)%NFramescxx . . $ Paper#NFrames.; |
| 62 | ycxx . . $ Canvas#y.=(ycxx . . $ Canvas#y.+DeltaYcxx . . $ Paper#DeltaY.)%maxYcxx . . $ Paper#maxY.; |
| 63 | } |