about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-17 11:23:21 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-17 11:23:21 +0000
commit35bcd41aa281325112dd09f12dce89236cca937d (patch)
treee1256dae0dce1e1183e309a4883a3dc609da61dd /src/game/client
parenta6be56dbdcbcd7b7a3ebf7dae7cd0537027486ea (diff)
downloadzcatch-35bcd41aa281325112dd09f12dce89236cca937d.tar.gz
zcatch-35bcd41aa281325112dd09f12dce89236cca937d.zip
added hammer hit effect. added reset of all systems on state change. solves a lot of possible memory errors
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/effects.cpp17
-rw-r--r--src/game/client/components/effects.hpp1
-rw-r--r--src/game/client/gameclient.cpp12
3 files changed, 29 insertions, 1 deletions
diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp
index 282da6f8..5e2e25e3 100644
--- a/src/game/client/components/effects.cpp
+++ b/src/game/client/components/effects.cpp
@@ -6,6 +6,7 @@
 #include <game/client/components/skins.hpp>
 #include <game/client/components/flow.hpp>
 #include <game/client/components/damageind.hpp>
+#include <game/client/components/sounds.hpp>
 #include <game/client/gameclient.hpp>
 
 #include "effects.hpp"
@@ -215,6 +216,22 @@ void EFFECTS::explosion(vec2 pos)
 	}
 }
 
+
+void EFFECTS::hammerhit(vec2 pos)
+{
+	// add the explosion
+	PARTICLE p;
+	p.set_default();
+	p.spr = SPRITE_PART_EXPL01;
+	p.pos = pos;
+	p.life_span = 0.4f;
+	p.start_size = 150.0f;
+	p.end_size = 0;
+	p.rot = frandom()*pi*2;
+	gameclient.particles->add(PARTICLES::GROUP_EXPLOSIONS, &p);	
+	gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_HAMMER_HIT, 1.0f, pos);
+}
+
 void EFFECTS::on_render()
 {
 	static int64 last_update_100hz = 0;
diff --git a/src/game/client/components/effects.hpp b/src/game/client/components/effects.hpp
index 13af8947..8574bf60 100644
--- a/src/game/client/components/effects.hpp
+++ b/src/game/client/components/effects.hpp
@@ -13,6 +13,7 @@ public:
 	void smoketrail(vec2 pos, vec2 vel);
 	void skidtrail(vec2 pos, vec2 vel);
 	void explosion(vec2 pos);
+	void hammerhit(vec2 pos);
 	void air_jump(vec2 pos);
 	void damage_indicator(vec2 pos, vec2 dir);
 	void playerspawn(vec2 pos);
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 22800a7a..4ac9c50a 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -432,7 +432,12 @@ void GAMECLIENT::on_statechange(int new_state, int old_state)
 {
 	// clear out the invalid pointers
 	mem_zero(&gameclient.snap, sizeof(gameclient.snap));
-		
+	
+	// first issue a reset to all
+	for(int i = 0; i < all.num; i++)
+		all.components[i]->on_reset();
+	
+	// then change the state
 	for(int i = 0; i < all.num; i++)
 		all.components[i]->on_statechange(new_state, old_state);
 }
@@ -463,6 +468,11 @@ void GAMECLIENT::process_events()
 			NETEVENT_EXPLOSION *ev = (NETEVENT_EXPLOSION *)data;
 			gameclient.effects->explosion(vec2(ev->x, ev->y));
 		}
+		else if(item.type == NETEVENTTYPE_HAMMERHIT)
+		{
+			NETEVENT_HAMMERHIT *ev = (NETEVENT_HAMMERHIT *)data;
+			gameclient.effects->hammerhit(vec2(ev->x, ev->y));
+		}
 		else if(item.type == NETEVENTTYPE_SPAWN)
 		{
 			NETEVENT_SPAWN *ev = (NETEVENT_SPAWN *)data;