1 /* 2 * JLib - Jacob's Library. 3 * Copyright (C) 2003, 2004 Juan Carlos Seijo P�rez 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the Free 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * Juan Carlos Seijo P�rez 20 * jacob@mainreactor.net 21 */ 22 23 /** Clase base de todos los objetos dibujables. 24 * @file JDrawable.h. 25 * @author Juan Carlos Seijo P�rez. 26 * @date 15/11/2003. 27 * @version 0.0.1 - 15/11/2003 - Primera versi�n. 28 * @version 0.0.2 - 25/09/2004 - Modificaci�n del m�todo 2D de Pos() para aceptar floats (quita libertad sino). 29 */ 30 31 #ifndef _JDRAWABLE_INCLUDED 32 #define _JDRAWABLE_INCLUDED 33 34 #include <JLib/Util/JTypes.h> 35 #include <stdio.h> 36 #include <JLib/Util/JObject.h> 37 #include <JLib/Util/JLoadSave.h> 38 #include <JLib/Math/JVector.h> 39 40 /** Clase base de todos los objetos dibujables. 41 */ 42 class JDrawable : public JObject 43 { 44 protected: 45 JVector pos; /**< Posici�n del objeto. */ 46 47 public: 48 /** Libera memoria. 49 */ ~JDrawable()50 virtual ~JDrawable() {} 51 52 /** Dibuja el objeto. Debe ser implementada en la clase hija. 53 */ Draw()54 virtual void Draw() {return;} 55 56 /** Actualiza el objeto. 57 */ Update()58 virtual s32 Update() {return 0;} 59 60 /** Recupera la posici�n de este objeto. 61 * @return Posici�n del objeto. 62 */ Pos()63 virtual const JVector & Pos() const {return pos;} 64 65 /** Establece la posici�n de este objeto. 66 * @param newPos Nueva posici�n del objeto. 67 */ Pos(const JVector & newPos)68 virtual void Pos(const JVector &newPos) {pos = newPos;} 69 70 /** Establece la posici�n de este objeto. 71 * @param x Nueva coordenada x. 72 * @param y Nueva coordenada y. 73 * @param z Nueva coordenada z. 74 */ Pos(float x,float y,float z)75 virtual void Pos(float x, float y, float z) {pos.x = x; pos.y = y; pos.z = z;} 76 77 /* Establece la posici�n de este objeto. �til para 2D. 78 * @param x Nueva coordenada x. 79 * @param y Nueva coordenada y. 80 */ Pos(float x,float y)81 virtual void Pos(float x, float y) {pos.x = x; pos.y = y;} 82 83 /** Establece la posici�n x de este objeto. 84 * @param x Nueva coordenada x. 85 */ X(float x)86 virtual void X(float x) {pos.x = x;} 87 88 /** Devuelve la posici�n x de este objeto. 89 * @return Coordenada x del objeto. 90 */ X()91 virtual float X() const {return pos.x;} 92 93 /** Establece la posici�n y de este objeto. 94 * @param y Nueva coordenada y. 95 */ Y(float y)96 virtual void Y(float y) {pos.y = y;} 97 98 /** Devuelve la posici�n y de este objeto. 99 * @return Coordenada y del objeto. 100 */ Y()101 virtual float Y() const {return pos.y;} 102 103 /** Establece la posici�n z de este objeto. 104 * @param z Nueva coordenada z. 105 */ Z(float z)106 virtual void Z(float z) {pos.z = z;} 107 108 /** Devuelve la posici�n z de este objeto. 109 * @return Coordenada z del objeto. 110 */ Z()111 virtual float Z() const {return pos.z;} 112 }; 113 114 #endif // _JDRAWABLE_INCLUDED 115