Main Page | Modules | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members

ufo.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * $Id: ufo.h,v 1.5 2003/07/16 11:42:15 schou Exp $
00003  * Author: Jakob Schou Jensen <schou@sourceforge.net>
00004  * Licence: GPL
00005  *
00006  * Description: Ufo
00007  *
00008  ****************************************************************************/
00009 
00015 #ifndef UFO_H
00016 #define UFO_H
00017 
00018 #include <adsotexture.h>
00019 #include <adsomath.h>
00020 #include "camera.h"
00021 #include "rigidbody.h"
00022 #include "object.h"
00023 #include "animation.h"
00024 
00025 class FlashRand {
00026   unsigned int random_state, init_state;
00027 
00028 public:
00029   float uni(){
00030     double r;
00031     unsigned long l;
00032 
00033     random_state = random_state+0x12345;
00034     l = (random_state+0x12345)*random_state;
00035     random_state = l;
00036     r = (double)random_state/(double)0x100000000;
00037     return (float)r;
00038   }
00039 
00040   float norm(){
00041     return tan((uni()-0.5f)*2.0f);
00042   }
00043   
00044   void next(){ init_state = random_state; }
00045   void reset(){ random_state = init_state; }
00046   void set(unsigned int s) { init_state = s; reset(); }
00047 
00048   FlashRand(){ init_state = 0; random_state = 0; }
00049 };
00050 
00051 
00052 class Ufo : public RigidBody, public PhysicalAnimation {
00053   Camera *eye;
00054   v3f targetPos;
00055   float appearTimer;
00056   float disappearTimer;
00057   float flashTimer;
00058   float attackTimer;
00059   float shootTimer;
00060 
00061   FlashRand flashRand;
00062 
00063   // state
00064   int active, targetOpponent;
00065 
00066   // Drawing
00067   static AdsoTexture *ufoTex;
00068   GLuint ufoTI;
00069   GLuint flashTI;
00070 
00071  public: 
00072   static void setTexture(AdsoTexture *t){ ufoTex = t; }
00073 
00074   void appear();
00075   void disappear();
00076   void kill();
00077   int isActive(){ return active; }
00078   void activate() { appearTimer = (float)frandom(30.0f)+2.0f; }
00079   void draw(DrawHint);
00080   void update(double deltaTime);
00081   Ufo();
00082 };
00083 
00084 #endif
00085 

Generated on Mon Jul 21 10:44:47 2003 for Rover by doxygen 1.3.2