Skip to content

Commit

Permalink
* Puffs should behave properly like stardust stuff now.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed May 15, 2011
1 parent 633f037 commit 98ba470
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/background.c
Expand Up @@ -28,6 +28,7 @@
#include "nlua_col.h"
#include "nlua_bkg.h"
#include "camera.h"
#include "nebula.h"


/**
Expand Down Expand Up @@ -157,6 +158,9 @@ void background_moveStars( double x, double y )
{
star_x += (GLfloat) x;
star_y += (GLfloat) y;

/* Puffs also need moving. */
nebu_movePuffs( x, y );
}


Expand Down
32 changes: 24 additions & 8 deletions src/nebula.c
Expand Up @@ -75,8 +75,10 @@ typedef struct NebulaPuff_ {
double height; /**< height vs player */
int tex; /**< Texture */
} NebulaPuff;
static NebulaPuff *nebu_puffs = NULL; /**< Stack of puffs. */
static int nebu_npuffs = 0; /**< Number of puffs. */
static NebulaPuff *nebu_puffs = NULL; /**< Stack of puffs. */
static int nebu_npuffs = 0; /**< Number of puffs. */
static double puff_x = 0.;
static double puff_y = 0.;


/*
Expand All @@ -85,10 +87,12 @@ static int nebu_npuffs = 0; /**< Number of puffs. */
static int nebu_checkCompat( const char* file );
static void nebu_loadTexture( SDL_Surface *sur, int w, int h, GLuint tex );
static int nebu_generate (void);
static void nebu_generatePuffs (void);
static int saveNebula( float *map, const uint32_t w, const uint32_t h, const char* file );
static SDL_Surface* loadNebula( const char* file );
static SDL_Surface* nebu_surfaceFromNebulaMap( float* map, const int w, const int h );
/* Puffs. */
static void nebu_generatePuffs (void);
static void nebu_renderPuffs( const double dt, int below_player );
/* Nebula render methods. */
static void nebu_renderMultitexture( const double dt );

Expand Down Expand Up @@ -580,6 +584,10 @@ void nebu_renderOverlay( const double dt )
gl_vboDeactivate();
gl_matrixPop();

/* Reset puff movement. */
puff_x = 0.;
puff_y = 0.;

gl_checkErr();
}

Expand All @@ -590,7 +598,7 @@ void nebu_renderOverlay( const double dt )
* @param dt Current delta tick.
* @param below_player Render the puffs below player or above player?
*/
void nebu_renderPuffs( const double dt, int below_player )
static void nebu_renderPuffs( const double dt, int below_player )
{
int i;

Expand All @@ -604,10 +612,8 @@ void nebu_renderPuffs( const double dt, int below_player )
(!below_player && (nebu_puffs[i].height > 1.))) {

/* calculate new position */
if (!paused && (player.p!=NULL)) {
nebu_puffs[i].x -= player.p->solid->vel.x * nebu_puffs[i].height * dt;
nebu_puffs[i].y -= player.p->solid->vel.y * nebu_puffs[i].height * dt;
}
nebu_puffs[i].x -= puff_x * nebu_puffs[i].height * dt;
nebu_puffs[i].y -= puff_y * nebu_puffs[i].height * dt;

/* Check boundries */
if (nebu_puffs[i].x > SCREEN_W + NEBULA_PUFF_BUFFER)
Expand All @@ -627,6 +633,16 @@ void nebu_renderPuffs( const double dt, int below_player )
}


/**
* @brief Moves the nebula puffs.
*/
void nebu_movePuffs( double x, double y )
{
puff_x += x;
puff_y += y;
}


/**
* @brief Prepares the nebualae to be rendered.
*
Expand Down
2 changes: 1 addition & 1 deletion src/nebula.h
Expand Up @@ -18,7 +18,6 @@ void nebu_exit (void);
*/
void nebu_render( const double dt );
void nebu_renderOverlay( const double dt );
void nebu_renderPuffs( const double dt, int below_player );

/*
* Misc
Expand All @@ -27,6 +26,7 @@ void nebu_genOverlay (void);
double nebu_getSightRadius (void);
void nebu_prep( double density, double volatility );
void nebu_forceGenerate (void);
void nebu_movePuffs( double x, double y );


#endif /* NEBULA_H */

0 comments on commit 98ba470

Please sign in to comment.