From e5593e0f4b262cb13d8edd4f2b16f9b16eca4e16 Mon Sep 17 00:00:00 2001 From: Marek Moeckel Date: Wed, 18 May 2005 19:28:54 +0000 Subject: [PATCH] rainsplashes are now automatically generated by the particle system SVN-Revision: 2517 --- data/images/sprites.strf | 12 +++++++- data/levels/test/raintest.stl | 4 +-- src/object/particlesystem_interactive.cpp | 16 ++++++++++ src/object/rainsplash.cpp | 49 +++++++++++++++++++++++++++++++ src/object/rainsplash.h | 45 ++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 src/object/rainsplash.cpp create mode 100644 src/object/rainsplash.h diff --git a/data/images/sprites.strf b/data/images/sprites.strf index bb4fa03f7..51c326887 100644 --- a/data/images/sprites.strf +++ b/data/images/sprites.strf @@ -1519,13 +1519,23 @@ (sprite (name "rainsplash") (action + (fps 20) (images "objects/particles/rainsplash-1.png" "objects/particles/rainsplash-2.png" "objects/particles/rainsplash-3.png" "objects/particles/rainsplash-4.png") ) ) - + (sprite (name "rainsplash-vertical") + (action + (fps 20) + (images "objects/particles/rainsplash-vertical-1.png" + "objects/particles/rainsplash-vertical-2.png" + "objects/particles/rainsplash-vertical-3.png" + "objects/particles/rainsplash-vertical-4.png") + ) + ) + (sprite (name "worldmaptux") (action (name "small") diff --git a/data/levels/test/raintest.stl b/data/levels/test/raintest.stl index 228bee730..18868278e 100644 --- a/data/levels/test/raintest.stl +++ b/data/levels/test/raintest.stl @@ -76,11 +76,11 @@ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 47 0 0 0 0 0 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 0 0 0 0 0 0 0 0 0 0 diff --git a/src/object/particlesystem_interactive.cpp b/src/object/particlesystem_interactive.cpp index 5fd611d0a..13064bcc3 100644 --- a/src/object/particlesystem_interactive.cpp +++ b/src/object/particlesystem_interactive.cpp @@ -35,6 +35,7 @@ #include "collision.h" #include "collision_hit.h" #include "object/camera.h" +#include "object/rainsplash.h" #include "badguy/bomb.h" //TODO: Dynamically create splashes at collision spots @@ -182,6 +183,21 @@ void RainParticleSystem::update(float elapsed_time) particle->pos.y += movement; particle->pos.x -= movement; if ((particle->pos.y > SCREEN_HEIGHT + abs_y) || (collision(particle, Vector(-movement, movement)))) { + //Create rainsplash + if (particle->pos.y <= SCREEN_HEIGHT + abs_y){ + //TODO: Find out at which side of the tile the collision happens + bool vertical = false; + int splash_x, splash_y; + if (vertical) { + splash_x = int(particle->pos.x) - (int(particle->pos.x) % 32) + 32; + splash_y = int(particle->pos.y); + } + else { + splash_x = int(particle->pos.x); + splash_y = int(particle->pos.y) - (int(particle->pos.y) % 32) + 32; + } + Sector::current()->add_object(new RainSplash(Vector(splash_x, splash_y),vertical)); + } int new_x = (rand() % int(virtual_width)) + int(abs_x); int new_y = 0; //FIXME: Don't move particles over solid tiles diff --git a/src/object/rainsplash.cpp b/src/object/rainsplash.cpp new file mode 100644 index 000000000..5864042c2 --- /dev/null +++ b/src/object/rainsplash.cpp @@ -0,0 +1,49 @@ +// SuperTux +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +#include "rainsplash.h" +#include "sector.h" + +RainSplash::RainSplash(Vector pos, bool vertical) +{ + frame = 0; + position = pos; + if (vertical) sprite = sprite_manager->create("rainsplash-vertical"); + else sprite = sprite_manager->create("rainsplash"); +} + +RainSplash::~RainSplash() { + remove_me(); +} + +void +RainSplash::hit(Player& ) +{ +} + +void +RainSplash::update(float time) +{ + time = 0;//just so i don't get an "unused variable" error - don't know how to circumvent this + frame++; + if (frame >= 10) remove_me(); +} + +void +RainSplash::draw(DrawingContext& context) +{ + sprite->draw(context, position, LAYER_OBJECTS); +} diff --git a/src/object/rainsplash.h b/src/object/rainsplash.h new file mode 100644 index 000000000..489d5230f --- /dev/null +++ b/src/object/rainsplash.h @@ -0,0 +1,45 @@ +// SuperTux +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. + +#ifndef __RAINSPLASH_H__ +#define __RAINSPLASH_H__ + + +#include "game_object.h" +#include "resources.h" +#include "player.h" +#include "sprite/sprite.h" +#include "sprite/sprite_manager.h" +#include "video/drawing_context.h" + +class RainSplash : public GameObject +{ +public: + RainSplash(Vector pos, bool vertical); + ~RainSplash(); +protected: + virtual void hit(Player& ); + virtual void update(float time); + virtual void draw(DrawingContext& context); +private: + Sprite* sprite; + Vector position; + int frame; +}; + +#endif + -- 2.11.0