| 1 | /*************************************************************************** |
| 2 | sprite.cpp - description |
| 3 | ------------------- |
| 4 | begin : Thu Jan 17 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 "sprite.h"cxx . . $ `<file>/src/sprite.h`/ |
| 19 | #include "list.h"cxx . . $ `<file>/src/list.h`/ |
| 20 | #include "surface.h"cxx . . $ `<file>/src/surface.h`/ |
| 21 | #include "imagemanager.h"cxx . . $ `<file>/src/imagemanager.h`/ |
| 22 | |
| 23 | Spritecxx . . $ Sprite#::Spritecxx . . $ Sprite#Sprite(7c5e60030c36ad17).(Strcxx . . $ Str# * filenamebase, Strcxx . . $ Str# * filenameext, int nFrames, ImageManagercxx . . $ ImageManager# * im){ |
| 24 | framescxx . . $ Sprite#frames. = (Imagecxx . . $ Image#**) malloccxx . . $ malloc(9f008b2a9698428b).(nFrames*(sizeof(Imagecxx . . $ Image#*))); |
| 25 | |
| 26 | this->n_framescxx . . $ Sprite#n_frames.=nFrames; |
| 27 | this->filenamebasecxx . . $ Sprite#filenamebase.=filenamebase; |
| 28 | this->filenameextcxx . . $ Sprite#filenameext.=filenameext; |
| 29 | char aux[256]; |
| 30 | |
| 31 | for (int i=0;i<nFrames;i++){ |
| 32 | sprintf(aux, "%s%04i%s", filenamebase->getcxx . . $ Str#get(33a1f659e94feb42).(), i, filenameext->getcxx . . $ Str#get(33a1f659e94feb42).()); |
| 33 | framescxx . . $ Sprite#frames.[i]=im->getImagecxx . . $ ImageManager#getImage(3ac71a4852078d03).(new Strcxx . . $ Str#(aux)); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | Spritecxx . . $ Sprite#::~cxx . . $ Sprite#`~Sprite`(ced63f7c635d850d).Spritecxx . . $ Sprite#(){ |
| 38 | delete framescxx . . $ Sprite#frames.; |
| 39 | if (filenamebasecxx . . $ Sprite#filenamebase.) delete filenamebasecxx . . $ Sprite#filenamebase.; |
| 40 | if (filenameextcxx . . $ Sprite#filenameext.) delete filenameextcxx . . $ Sprite#filenameext.; |
| 41 | } |
| 42 | |
| 43 | int Spritecxx . . $ Sprite#::nFramescxx . . $ Sprite#nFrames(b126dc7c1de90089).(){ |
| 44 | return n_framescxx . . $ Sprite#n_frames.; |
| 45 | } |
| 46 | |
| 47 | int Spritecxx . . $ Sprite#::frameWidthcxx . . $ Sprite#frameWidth(57806aaf66c601ae).(ImageManagercxx . . $ ImageManager# * im){ |
| 48 | return framescxx . . $ Sprite#frames.[0]->widthcxx . . $ Surface#width(b126dc7c1de90089).(); |
| 49 | } |
| 50 | |
| 51 | int Spritecxx . . $ Sprite#::frameHeightcxx . . $ Sprite#frameHeight(57806aaf66c601ae).(ImageManagercxx . . $ ImageManager# * im){ |
| 52 | return framescxx . . $ Sprite#frames.[0]->heightcxx . . $ Surface#height(b126dc7c1de90089).(); |
| 53 | } |
| 54 | |
| 55 | Surfacecxx . . $ Surface# * Spritecxx . . $ Sprite#::framecxx . . $ Sprite#frame(e8d7ae696153184b).(ImageManagercxx . . $ ImageManager# * im, int n){ |
| 56 | return framescxx . . $ Sprite#frames.[n]; |
| 57 | } |