New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make snow effect less heavy and replace snowflake graphic #901

Merged
merged 2 commits into from Jun 21, 2016
Jump to file or symbol
Failed to load files and symbols.
+29 −21
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

Replace snow image with a 2x2 square. Adjust lifetime algorithm, look…

…s more like

RPG2k3 now.
  • Loading branch information...
Ghabry committed Jun 21, 2016
commit 7c3b6b66673b7ff1f8a539021ae650d8730ace60
View
@@ -223,9 +223,9 @@ void Game_Screen::UpdateSnowRain(int speed) {
for (it = snowflakes.begin(); it != snowflakes.end(); ++it) {
Snowflake& f = *it;
f.y += (uint8_t)speed;
f.life++;
if (f.life > snowflake_life)
f.life = 0;
f.life -= 5;
if (f.life < 10)
f.life = 255;
}
}
View
@@ -82,17 +82,25 @@ void Weather::Draw() {
}
}
static const uint8_t snow_image[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00,
0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x00, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0xd4, 0x9f, 0x76, 0xed,
0x00, 0x00, 0x00, 0x09, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00,
0xc0, 0xc0, 0xc0, 0xff, 0xff, 0xff, 0x0d, 0x6d, 0xd7, 0xbb, 0x00,
0x00, 0x00, 0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8,
0x66, 0x00, 0x00, 0x00, 0x0e, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7,
0x63, 0x10, 0x61, 0xc8, 0x04, 0x42, 0x11, 0x00, 0x03, 0xf0, 0x00,
0xfb, 0xb6, 0xa8, 0xf1, 0xda, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
static const uint8_t snow_image[] =
{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00,
0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x02, 0x04, 0x03, 0x00, 0x00, 0x00, 0x80, 0x98, 0x10, 0x17,
0x00, 0x00, 0x00, 0x06, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x00, 0x00,
0xff, 0xff, 0xff, 0x41, 0x1d, 0x34, 0x11, 0x00, 0x00, 0x00, 0x09,
0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0a, 0xf0, 0x00, 0x00, 0x0a,
0xf0, 0x01, 0x42, 0xac, 0x34, 0x98, 0x00, 0x00, 0x00, 0x07, 0x74,
0x49, 0x4d, 0x45, 0x07, 0xe0, 0x05, 0x1e, 0x16, 0x12, 0x02, 0x2c,
0xe7, 0xd0, 0xc3, 0x00, 0x00, 0x00, 0x2b, 0x74, 0x45, 0x58, 0x74,
0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x54, 0x69,
0x6d, 0x65, 0x00, 0x44, 0x69, 0x20, 0x33, 0x31, 0x20, 0x4d, 0x61,
0x69, 0x20, 0x32, 0x30, 0x31, 0x36, 0x20, 0x30, 0x30, 0x3a, 0x31,
0x35, 0x3a, 0x31, 0x35, 0x20, 0x2b, 0x30, 0x31, 0x30, 0x30, 0xc0,
0x15, 0x68, 0x2f, 0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, 0x54,
0x08, 0x5b, 0x63, 0x10, 0x64, 0x10, 0x04, 0x00, 0x00, 0x48, 0x00,
0x23, 0xf5, 0x3f, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
static const uint8_t rain_image[] = {
@@ -137,25 +145,25 @@ void Weather::DrawSnow() {
}
static const int wobble[2][18] = {
{-1,-1, 0, 1, 0, 1, 1, 0,-1,-1, 0, 1, 0, 1, 1, 0,-1, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1,-1, 0, 0, 1, 1, 0,-1,-1, 0, 1, 0, 1, 1, 0,-1, 0, 0}
};
Rect rect = snow_bitmap->GetRect();
const std::vector<Game_Screen::Snowflake>& snowflakes = Main_Data::game_screen->GetSnowflakes();
std::vector<Game_Screen::Snowflake>::const_iterator it;
for (it = snowflakes.begin(); it != snowflakes.end(); ++it) {
const Game_Screen::Snowflake& f = *it;
if (f.life > snowflake_visible)
std::vector<Game_Screen::Snowflake>::iterator it;
for (const Game_Screen::Snowflake& f : snowflakes) {
if (f.life < 0) {
continue;
int x = f.x - f.y/2;
}
int x = f.x - f.y / 4;
int y = f.y;
int i = (y / 2) % 18;
x += wobble[0][i];
y += wobble[1][i];
weather_surface->Blit(x, y, *snow_bitmap, rect, 192);
weather_surface->Blit(x, y, *snow_bitmap, rect, f.life);
}
dirty = true;
ProTip! Use n and p to navigate between commits in a pull request.