Skip to content

Commit

Permalink
Fix magic flare scaling with higher resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed May 26, 2015
1 parent 6ee3022 commit 77cc3ed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
36 changes: 23 additions & 13 deletions src/game/Spells.cpp
Expand Up @@ -144,7 +144,8 @@ bool GLOBAL_MAGIC_MODE = true;
short ARX_FLARES_broken(1);

long snip=0;
static Vec2s Lm;
static Vec2s g_LastFlarePosition;
static unsigned long g_LastFlareTime;

unsigned char ucFlick=0;

Expand Down Expand Up @@ -540,23 +541,32 @@ void ARX_SPELLS_ManageMagic() {
pos = MemoMouse;
}

Vec2s pos2 = Lm;
unsigned long time = (unsigned long)(arxtime);

if(!ARX_FLARES_broken)
FlareLine(pos2, pos);

if(rnd() > 0.6)
AddFlare(pos, 1.f, -1);
else
AddFlare(pos, 1.f, 3);
const unsigned long interval = 1000 / 60;

OPIPOrgb = PIPOrgb;
if(ARX_FLARES_broken) {
g_LastFlarePosition = pos;
g_LastFlareTime = time - interval;
}

Lm = DANAEMouse;
if(TRUE_PLAYER_MOUSELOOK_ON) {
Lm = MemoMouse;
if(time - g_LastFlareTime >= interval) {

if(glm::distance(Vec2f(pos), Vec2f(g_LastFlarePosition)) > 14 * g_sizeRatio.y) {
FlareLine(g_LastFlarePosition, pos);
g_LastFlarePosition = pos;
}

if(rnd() > 0.6)
AddFlare(pos, 1.f, -1);
else
AddFlare(pos, 1.f, 3);

g_LastFlareTime = time - std::min(time - g_LastFlareTime - interval, interval);
}

OPIPOrgb = PIPOrgb;

ARX_FLARES_broken=0;

if(!ARX_SOUND_IsPlaying(SND_MAGIC_DRAW))
Expand Down
14 changes: 13 additions & 1 deletion src/graphics/particle/MagicFlare.cpp
Expand Up @@ -318,6 +318,9 @@ void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
while(i < tmpPos1.x) {
long z = rnd() * FLARELINERND;
z += FLARELINESTEP;
if(!io) {
z *= g_sizeRatio.y;
}
i += z;
tmpPos0.y += m * z;
AddLFlare(Vec2s(i, tmpPos0.y), io);
Expand All @@ -329,6 +332,9 @@ void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
while(i < tmpPos0.x) {
long z = rnd() * FLARELINERND;
z += FLARELINESTEP;
if(!io) {
z *= g_sizeRatio.y;
}
i += z;
tmpPos0.y += m * z;
AddLFlare(Vec2s(i, tmpPos0.y), io);
Expand All @@ -350,6 +356,9 @@ void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
while(i < tmpPos1.y) {
long z = rnd() * FLARELINERND;
z += FLARELINESTEP;
if(!io) {
z *= g_sizeRatio.y;
}
i += z;
tmpPos0.x += m * z;
AddLFlare(Vec2s(tmpPos0.x, i), io);
Expand All @@ -361,6 +370,9 @@ void FlareLine(const Vec2s & pos0, const Vec2s & pos1, Entity * io)
while(i < tmpPos0.y) {
long z = rnd() * FLARELINERND;
z += FLARELINESTEP;
if(!io) {
z *= g_sizeRatio.y;
}
i += z;
tmpPos0.x += m * z;
AddLFlare(Vec2s(tmpPos0.x, i), io);
Expand Down Expand Up @@ -464,7 +476,7 @@ void ARX_MAGICAL_FLARES_Update() {
mat.setDepthTest(flare.io != NULL);

if(flare.bDrawBitmap) {
s *= 2.f;
s *= 2.f * minSizeRatio();
EERIEAddBitmap(mat, flare.v.p, s, s, surf, Color::fromRGBA(flare.tv.color));
} else {
EERIEAddSprite(mat, flare.v.p, s * 0.025f + 1.f,
Expand Down

0 comments on commit 77cc3ed

Please sign in to comment.