enum class WorldWeather : unsigned char {
Sunny = 0, /**< Sunny/daytime */
Dark, /**< Nighttime */
- Rain /**< Rain (to be implemented)*/
+ Rain, /**< Rain */
+ Snowy /**< Snow */
};
/**
* velocity, color and duration (time to live).
*/
- void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int duration);
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d);
+ void addParticle(float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity );
/**
* Adds a light to the world with the specified coordinates and color.
World *exitArena( Player *p );
};
+std::string getWorldWeatherStr( WorldWeather ww );
+
/**
* Loads the player into the world created by the given XML file. If a world is
* already loaded it will be saved before the transition is made.
std::cout << "Num threads: " << std::thread::hardware_concurrency() << std::endl;
//currentWorld->mob.back()->followee = player;
+ glClearColor(1,1,1,1);
gameRunning = true;
while ( gameRunning )
currentWorld->update(player,deltaTime);
});*/
currentWorld->update( player, deltaTime );
+ currentWorld->detect(player);
/*
* Update debug variables if necessary
ui::putText(offset.x-SCREEN_WIDTH/2,
(offset.y+SCREEN_HEIGHT/2)-ui::fontSize,
- "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nTc: %u\nHA: %+.2f\nVol: %f",
+ "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nTc: %u\nHA: %+.2f\nVol: %f\nWea: %s",
fps,
player->ground,
SCREEN_WIDTH, // Window dimensions
debugY, // The player's y coordinate
tickCount,
handAngle,
- VOLUME_MASTER
+ VOLUME_MASTER,
+ getWorldWeatherStr( weather ).c_str()
);
if(ui::posFlag){
* that exist in this world.
*/
- currentWorld->detect(player);
+
if(player->loc.y<.02)gameRunning=false;
/*
else fadeIntensity = 0;
}
+ /*
+ * Rain?
+ */
+
+ if ( weather == WorldWeather::Rain ) {
+ for ( unsigned int r = (randGet() % 25) + 11; r--; ) {
+ currentWorld->addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2),
+ offset.y + SCREEN_HEIGHT / 2,
+ HLINE * 1.25, // width
+ HLINE * 1.25, // height
+ randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x
+ (4 + randGet() % 6) * .05, // vel.y
+ { 0, 0, 255 }, // RGB color
+ 2500 // duration (ms)
+ );
+ }
+ } else if ( weather == WorldWeather::Snowy ) {
+ for ( unsigned int r = (randGet() % 25) + 11; r--; ) {
+ currentWorld->addParticle(randGet() % currentWorld->getTheWidth() - (currentWorld->getTheWidth() / 2),
+ offset.y + SCREEN_HEIGHT / 2,
+ HLINE * 1.25, // width
+ HLINE * 1.25, // height
+ .0001 + randGet() % 7 * .01 * (randGet() % 2 == 0 ? -1 : 1), // vel.x
+ (4 + randGet() % 6) * -.03, // vel.y
+ { 255, 255, 255 }, // RGB color
+ 5000, // duration (ms)
+ false
+ );
+ }
+ }
+
/*
* Increment a loop counter used for animating sprites.
*/
extern Player *player;
extern World *currentWorld;
+extern WorldWeather weather;
/*
* In the case of dialog, some NPC quests can be preloaded so that they aren't assigned until
return;
}
switch(SDL_KEY){
+ case SDLK_z:
+ weather = WorldWeather::Snowy;
+ break;
case SDLK_a:
left = false;
break;
#define INDOOR_FLOOR_HEIGHT 100
+/**
+ * Gravity thing
+ */
+
+#define GRAVITY_CONSTANT 0.001f
extern Player *player; // main.cpp?
extern World *currentWorld; // main.cpp
// the sunny wallpaper is faded with the night depending on tickCount
bgTex->bind( 0 );
- safeSetColorA( 255, 255, 255, 255 - worldShade * 4 );
+ safeSetColorA( 255, 255, 255, weather == WorldWeather::Snowy ? 150 : 255 - worldShade * 4);
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex2i( worldStart, SCREEN_HEIGHT );
glEnd();
bgTex->bindNext();
- safeSetColorA( 255, 255, 255, worldShade * 4 );
+ safeSetColorA( 255, 255, 255, worldShade * 4);
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 ); glVertex2i( worldStart, SCREEN_HEIGHT );
e->ground = true;
return;
} else if ( e->vel.y > -2 )
- e->vel.y -= .003 * deltaTime;
+ e->vel.y -= GRAVITY_CONSTANT * deltaTime;
}
/*
part.velx = 0;
part.canMove = false;
} else if ( part.gravity && part.vely > -2 )
- part.vely -= .003 * deltaTime;
+ part.vely -= GRAVITY_CONSTANT * deltaTime;
}
// handle particle creation
particles.back().canMove = true;
}
+void World::
+addParticle( float x, float y, float w, float h, float vx, float vy, Color color, int d, bool gravity )
+{
+ particles.emplace_back( x, y, w, h, vx, vy, color, d );
+ particles.back().canMove = true;
+ particles.back().gravity = gravity;
+}
+
+
void World::addLight(vec2 loc, Color color){
if(light.size() < 64){
light.push_back(Light(loc,color,1));
}
}
-
+std::string getWorldWeatherStr( WorldWeather ww )
+{
+ switch ( ww ) {
+ case WorldWeather::Sunny:
+ return "Sunny";
+ break;
+ case WorldWeather::Dark:
+ return "Darky";
+ break;
+ case WorldWeather::Rain:
+ return "Rainy";
+ break;
+ default:
+ return "Look at the screen u scrub";
+ break;
+ }
+}
static bool loadedLeft = false;
static bool loadedRight = false;