mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-23 15:32:19 +00:00
Use a function instead of a macro
Kept the old comment even if it is wrong.
This commit is contained in:
parent
a7298d2762
commit
782e5b42e4
2 changed files with 16 additions and 11 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -13,6 +13,9 @@ build
|
||||||
# Compiled static library
|
# Compiled static library
|
||||||
*.a
|
*.a
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode/*
|
||||||
|
|
||||||
# Programmer's Notepad state file
|
# Programmer's Notepad state file
|
||||||
*.pnps
|
*.pnps
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,9 @@ enum class Effect : u8 {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Random Number (0 - 1) in float
|
// Random Number (0 - 1) in float
|
||||||
#define RANDOM ((((float)(rand() % 12)) / 12) - 0.5f)
|
static float RandomFloat() {
|
||||||
|
return (static_cast<float>(rand() % 12) / 12.0f) - 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
// Basic structure to hold particle data
|
// Basic structure to hold particle data
|
||||||
struct Particle {
|
struct Particle {
|
||||||
|
@ -153,14 +155,14 @@ static void createEffect( Effect id, int _x, int _y ) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case Effect::SMOKEBOMB:
|
case Effect::SMOKEBOMB:
|
||||||
for (u8 i = 0; i < 5; i++) {
|
for (u8 i = 0; i < 5; i++) {
|
||||||
createParticle( 1, (_x + (RANDOM * 10)), (_y + (RANDOM * 10)), (1.4f+(RANDOM*0.20)), 1.0f, 64, 64, 64 );
|
createParticle( 1, (_x + (RandomFloat() * 10)), (_y + (RandomFloat() * 10)), (1.4f+(RandomFloat()*0.20)), 1.0f, 64, 64, 64 );
|
||||||
}
|
}
|
||||||
for (u8 i = 0; i < 20; i++) {
|
for (u8 i = 0; i < 20; i++) {
|
||||||
createParticle( 3, (_x + (RANDOM * 50)), (_y + (RANDOM * 50)), 1.25f, 1.5f, 92, 92, 92 );
|
createParticle( 3, (_x + (RandomFloat() * 50)), (_y + (RandomFloat() * 50)), 1.25f, 1.5f, 92, 92, 92 );
|
||||||
}
|
}
|
||||||
for (u8 i = 0; i < 5; i++) {
|
for (u8 i = 0; i < 5; i++) {
|
||||||
u8 _ColorAdd = (RANDOM * 75);
|
u8 _ColorAdd = (RandomFloat() * 75);
|
||||||
createParticle( 2, (_x + (RANDOM * 40)), (_y + (RANDOM * 40)), (1.0f+(RANDOM*0.20)), 1.0f, 128+_ColorAdd, 128+_ColorAdd, 128+_ColorAdd );
|
createParticle( 2, (_x + (RandomFloat() * 40)), (_y + (RandomFloat() * 40)), (1.0f+(RandomFloat()*0.20)), 1.0f, 128+_ColorAdd, 128+_ColorAdd, 128+_ColorAdd );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -179,14 +181,14 @@ static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha,
|
||||||
part->alpha = _alpha;
|
part->alpha = _alpha;
|
||||||
|
|
||||||
part->tex = GFX_Smoke;
|
part->tex = GFX_Smoke;
|
||||||
part->sy = RANDOM;
|
part->sy = RandomFloat();
|
||||||
part->sx = RANDOM;
|
part->sx = RandomFloat();
|
||||||
part->sscale = 0.9985;
|
part->sscale = 0.9985;
|
||||||
part->salpha = 0.985;
|
part->salpha = 0.985;
|
||||||
switch (part->id) {
|
switch (part->id) {
|
||||||
case 1:
|
case 1:
|
||||||
part->sy = RANDOM * 0.5;
|
part->sy = RandomFloat() * 0.5;
|
||||||
part->sx = RANDOM * 0.5;
|
part->sx = RandomFloat() * 0.5;
|
||||||
part->sscale = 0.999;
|
part->sscale = 0.999;
|
||||||
part->salpha = 0.992;
|
part->salpha = 0.992;
|
||||||
part->framedelay = 10;
|
part->framedelay = 10;
|
||||||
|
@ -197,8 +199,8 @@ static void createParticle( u8 _id, int _x, int _y, float _scale, float _alpha,
|
||||||
part->salpha = 0.95;
|
part->salpha = 0.95;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
part->sy = (RANDOM * 8);
|
part->sy = (RandomFloat() * 8);
|
||||||
part->sx = (RANDOM * 8);
|
part->sx = (RandomFloat() * 8);
|
||||||
part->salpha = 0.85;
|
part->salpha = 0.85;
|
||||||
part->scolor = 0.95;
|
part->scolor = 0.95;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue