Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 19d8443f96
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 106 lines (85 sloc) 2.784 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
#ifndef PART_EMIT
#define PART_EMIT

/*
* ParticleEmitter.h
* SpaceRedux
*
* Created by Dave Lyon on 11/30/10.
* Copyright 2010 Northern Michigan University. All rights reserved.
*
*/

#ifdef MAC_OS_X_VERSION_MIN_REQUIRED
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include <OpenGL/glu.h>
#include "SDL_image.h"
#else // Linux includes
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "SDL/SDL_image.h"
#endif

#include "Textures.h"

#define MAX_PARTICLES 300
#define TRUE 1
#define FALSE 0
static const GLfloat colors[12][3] =
{
{ 1.0f, 0.3f, 0.3f},
{ 1.0f, 0.5f, 0.1f},
{ 0.8f, 0.2f, 0.0f},
{ 0.75f, 1.0f, 0.5f},
{ 0.5f, 1.0f, 0.5f},
{ 0.5f, 1.0f, 0.75f},
{ 0.5f, 1.0f, 1.0f},
{ 0.5f, 0.75f, 1.0f},
{ 0.5f, 0.5f, 1.0f},
{ 0.75f, 0.5f, 1.0f},
{ 1.0f, 0.5f, 1.0f},
{ 1.0f, 0.5f, 0.75f}
};

typedef struct {
int active; /* Active (Yes/No) */
float life; /* Particle Life */
float fade; /* Fade Speed */

float r; /* Red Value */
float g; /* Green Value */
float b; /* Blue Value */

float x; /* X Position */
float y; /* Y Position */
float z; /* Z Position */

float xi; /* X Direction */
float yi; /* Y Direction */
float zi; /* Z Direction */

float xg; /* X Gravity */
float yg; /* Y Gravity */
float zg; /* Z Gravity */
} particle;

class ParticleEmitter {
public:
// Constructor [Should be private... but not working >.<]
ParticleEmitter();

// Create a 'laser' particle a the specified location
void emitLaser(float xloc, float yloc);

// Create an 'explosion' particle at the specified location [Usually the location of a collision]
void emitExploder(float xloc, float yloc);

// Called by gameloop to render all active particles
void renderParticles(int tick, float ship_x, float ship_y);

static ParticleEmitter* Instance();

private:
particle shipParticles[MAX_PARTICLES];
void ResetParticle( int num, int color, float xDir, float yDir, float zDir );
void renderSetup(void);
void renderTeardown(void);

static ParticleEmitter *singletonInstance;

int rainbow; /* Toggle rainbow effect */
GLuint texture;
float slowdown; /* Slow Down Particles */
float xspeed; /* Base X Speed (To Allow Keyboard Direction Of Tail) */
float yspeed; /* Base Y Speed (To Allow Keyboard Direction Of Tail) */
float zoom; /* Used To Zoom Out */

GLuint loop; /* Misc Loop Variable */
GLuint col; /* Current Color Selection */

int exploderCounter;
};

#endif
Something went wrong with that request. Please try again.