From f1a648c038a2a6e1eb97e9f45a115fbe0da3df1f Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 18 Jul 2008 17:30:49 +0100 Subject: [PATCH] Nicer exhaust effect --- src/Emitter.cpp | 13 ++++++++----- src/Emitter.hpp | 4 +++- src/Ship.cpp | 8 +++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Emitter.cpp b/src/Emitter.cpp index e67e261..dd27bc0 100644 --- a/src/Emitter.cpp +++ b/src/Emitter.cpp @@ -40,7 +40,7 @@ Emitter::Emitter(int x, int y, float r, float g, float b, bool createnew, float max_speed, float size, float slowdown) : partsize(size), r(r), g(g), b(b), deviation(deviation), xg(xg), yg(yg), life(life), maxspeed(max_speed), xpos((float)x), ypos((float)y), - slowdown(slowdown), createrate(64.0f) + slowdown(slowdown), createrate(128.0f), xi_bias(0.0f), yi_bias(0.0f) { LOAD_ONCE { texture = new Texture("images/particle.png"); @@ -188,6 +188,9 @@ void Emitter::NewParticle(int index) particle[index].xi = (float)((rand()%50)-26.0f)*maxspeed; particle[index].yi = (float)((rand()%50)-25.0f)*maxspeed; } while (pow(particle[index].yi, 2) + pow(particle[index].xi, 2) > pow(25.0f*maxspeed, 2)); + + particle[index].xi += xi_bias; + particle[index].yi += yi_bias; } @@ -195,12 +198,12 @@ void Emitter::NewParticle(int index) * Smoke trail constructor. Sets special Emitter constants. */ SmokeTrail::SmokeTrail() - : Emitter(0, 0, 0.9f, 0.9f, 0.0f, + : Emitter(0, 0, 0.9f, 0.7f, 0.0f, false, 0.2f, - 0.0f, 0.1f, - 0.3f, 20.0f, 4.0f, 2.0f) + 0.0f, 0.0f, + 0.3f, 0.0f, 5.0f, 0.001f) { - + createrate = 64.0f; } diff --git a/src/Emitter.hpp b/src/Emitter.hpp index e666f50..bde55b6 100644 --- a/src/Emitter.hpp +++ b/src/Emitter.hpp @@ -43,6 +43,8 @@ public: float partsize, r, g, b, deviation, xg, yg, life, maxspeed, flSize; float xpos, ypos, slowdown, createrate; + + float xi_bias, yi_bias; protected: void NewParticle(int index); @@ -55,7 +57,7 @@ protected: float xi, yi; float xg, yg; } particle[MAX_PARTICLES]; - + static Texture *texture; }; diff --git a/src/Ship.cpp b/src/Ship.cpp index aae04cc..6895664 100644 --- a/src/Ship.cpp +++ b/src/Ship.cpp @@ -106,12 +106,10 @@ void Ship::Move() - (shipImage.GetWidth()/2)*(double)sin(angle*(PI/180)); exhaust.ypos = ypos + shipImage.GetHeight()/2 + (shipImage.GetHeight()/2)*(double)cos(angle*(PI/180)); - //exhaust.yg = speedY; //+ (flGravity * 10); - //exhaust.xg = speedX; - const float SCALE = 10.0f; - exhaust.yg = SCALE * sin(angle); - exhaust.xg = SCALE * cos(angle); + const float SCALE = 1.0f; + exhaust.yi_bias = SCALE * cos(angle*PI/180) + speedY; + exhaust.xi_bias = SCALE * -sin(angle*PI/180) + speedX; explosion.xpos = xpos + shipImage.GetWidth()/2; explosion.ypos = ypos + shipImage.GetHeight()/2; -- 2.39.2