[Super-tux-commit] supertux/src gameloop.cpp,1.172,1.173 gameobjs.cpp,1.48,1.49 gameobjs.h,1.34,1.35
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-09-14 10:27:19
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23438/src Modified Files: gameloop.cpp gameobjs.cpp gameobjs.h resources.cpp resources.h sector.cpp sector.h Log Message: Made code using fireworks sound effect. Also improved Particles: it now has acceleration and knows the difference of X and Y. Index: resources.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- resources.h 26 Aug 2004 23:05:03 -0000 1.15 +++ resources.h 14 Sep 2004 10:27:05 -0000 1.16 @@ -52,6 +52,7 @@ SND_KICK, SND_EXPLODE, SND_WARP, + SND_FIREWORKS, NUM_SOUNDS }; Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sector.h 13 Sep 2004 22:48:14 -0000 1.12 +++ sector.h 14 Sep 2004 10:27:05 -0000 1.13 @@ -107,7 +107,7 @@ void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind); bool add_bullet(const Vector& pos, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); - bool add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); + bool add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); /** Try to grab the coin at the given coordinates */ void trygrabdistro(const Vector& pos, int bounciness); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- sector.cpp 13 Sep 2004 22:48:14 -0000 1.23 +++ sector.cpp 14 Sep 2004 10:27:05 -0000 1.24 @@ -737,9 +737,9 @@ } bool -Sector::add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time) +Sector::add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time) { - add_object(new Particles(epicenter, number, color, size, velocity, life_time)); + add_object(new Particles(epicenter, velocity, acceleration, number, color, size, life_time)); return true; } Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- gameobjs.cpp 13 Sep 2004 22:48:14 -0000 1.48 +++ gameobjs.cpp 14 Sep 2004 10:27:05 -0000 1.49 @@ -438,8 +438,8 @@ img_smoke_cloud->draw(context, position, LAYER_OBJECTS+1); } -Particles::Particles(const Vector& epicenter, int number, Color color_, int size_, float velocity_, int life_time) - : color(color_), size(size_), velocity(velocity_) +Particles::Particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color_, int size_, int life_time) + : color(color_), size(size_), vel(velocity), accel(acceleration) { timer.start(life_time); @@ -464,11 +464,14 @@ void Particles::action(float elapsed_time) { + vel.x += accel.x * elapsed_time; + vel.y += accel.y * elapsed_time; + // update particles for(int p = 0; p < particles.size(); p++) { - particles[p]->pos.x += sin(particles[p]->angle) * velocity * elapsed_time; - particles[p]->pos.y += cos(particles[p]->angle) * velocity * elapsed_time; + particles[p]->pos.x += sin(particles[p]->angle) * vel.x * elapsed_time; + particles[p]->pos.y += cos(particles[p]->angle) * vel.y * elapsed_time; } if(!timer.check()) Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- gameobjs.h 13 Sep 2004 22:48:14 -0000 1.34 +++ gameobjs.h 14 Sep 2004 10:27:05 -0000 1.35 @@ -179,7 +179,7 @@ class Particles : public GameObject { public: - Particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); + Particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); ~Particles(); virtual void action(float elapsed_time); @@ -188,7 +188,7 @@ private: Color color; float size; - float velocity; + Vector vel, accel; Timer timer; struct Particle { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.172 retrieving revision 1.173 diff -u -d -r1.172 -r1.173 --- gameloop.cpp 13 Sep 2004 22:48:50 -0000 1.172 +++ gameloop.cpp 14 Sep 2004 10:27:04 -0000 1.173 @@ -515,7 +515,7 @@ else if(!end_sequence && endtile && endtile->data == 0) { end_sequence = ENDSEQUENCE_RUNNING; - random_timer.start(200); // start 1st fire work + random_timer.start(200); // start 1st firework last_x_pos = -1; SoundManager::get()->play_music(level_end_song, 0); endsequence_timer.start(7000); // 5 seconds until we finish the map @@ -556,18 +556,20 @@ newsector = newspawnpoint = ""; } - // on end sequence make a few fire works + // on end sequence make a few fireworks if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check()) { Vector epicenter = currentsector->camera->get_translation(); epicenter.x += screen->w * ((float)rand() / RAND_MAX); epicenter.y += (screen->h/2) * ((float)rand() / RAND_MAX); - int red = rand() % 255; // calculate fire work color + int red = rand() % 255; // calculate firework color int green = rand() % red; - currentsector->add_particles(epicenter, 45, Color(red,green,0), 3, 1.4, 1300); + currentsector->add_particles(epicenter, Vector(1.4,1.4), Vector(0,0), + 45, Color(red,green,0), 3, 1300); - random_timer.start(rand() % 400 + 600); // next fire work + SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS)); + random_timer.start(rand() % 400 + 600); // next firework } } Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- resources.cpp 8 Sep 2004 11:23:29 -0000 1.52 +++ resources.cpp 14 Sep 2004 10:27:05 -0000 1.53 @@ -75,7 +75,8 @@ "/sounds/stomp.wav", "/sounds/kick.wav", "/sounds/explosion.wav", - "/sounds/warp.wav" + "/sounds/warp.wav", + "/sounds/fireworks.wav" }; |