about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-02-02 18:05:16 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-02-02 18:05:16 +0000
commit5f32f5b36f5013deff20ba5144d6bec9077b6ea2 (patch)
treea94e734138edb960420aed65ebdc9a48b022713e /src/game/client
parent1fe3202f0b7e2f52e50c430caa744b029fd5bcef (diff)
downloadzcatch-5f32f5b36f5013deff20ba5144d6bec9077b6ea2.tar.gz
zcatch-5f32f5b36f5013deff20ba5144d6bec9077b6ea2.zip
added laser weapon
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/gc_client.cpp2
-rw-r--r--src/game/client/gc_render.cpp4
-rw-r--r--src/game/client/gc_render.h1
-rw-r--r--src/game/client/gc_render_obj.cpp72
4 files changed, 75 insertions, 4 deletions
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index c092ca73..79b50317 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -1117,7 +1117,7 @@ void render_game()
 		for (int i = 0; i < local_character->weaponstage; i++)
 			gfx_quads_drawTL(x+local_character->ammocount * 12 -i*12, y+22, 11, 11);
 		select_sprite(data->weapons[local_character->weapon%data->num_weapons].sprite_proj);
-		for (int i = 0; i < local_character->ammocount; i++)
+		for (int i = 0; i < min(local_character->ammocount, 10); i++)
 			gfx_quads_drawTL(x+i*12,y+24,10,10);
 
 		gfx_quads_end();
diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp
index 6297fc9c..285b6c1c 100644
--- a/src/game/client/gc_render.cpp
+++ b/src/game/client/gc_render.cpp
@@ -341,6 +341,10 @@ static void render_items()
 			if(prev)
 				render_powerup((const obj_powerup *)prev, (const obj_powerup *)data);
 		}
+		else if(item.type == OBJTYPE_LASER)
+		{
+			render_laser((const obj_laser *)data);
+		}
 		else if(item.type == OBJTYPE_FLAG)
 		{
 			const void *prev = snap_find_item(SNAP_PREV, item.type, item.id);
diff --git a/src/game/client/gc_render.h b/src/game/client/gc_render.h
index d7adeada..b62206f7 100644
--- a/src/game/client/gc_render.h
+++ b/src/game/client/gc_render.h
@@ -57,6 +57,7 @@ void render_tee(class animstate *anim, tee_render_info *info, int emote, vec2 di
 void render_flag(const struct obj_flag *prev, const struct obj_flag *current);
 void render_powerup(const struct obj_powerup *prev, const struct obj_powerup *current);
 void render_projectile(const struct obj_projectile *current, int itemid);
+void render_laser(const struct obj_laser *current);
 void render_player(
 	const struct obj_player_character *prev_char, const struct obj_player_character *player_char,
 	const struct obj_player_info *prev_info, const struct obj_player_info *player_info);
diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp
index 00f54c89..6f836307 100644
--- a/src/game/client/gc_render_obj.cpp
+++ b/src/game/client/gc_render_obj.cpp
@@ -26,7 +26,7 @@ void render_projectile(const obj_projectile *current, int itemid)
 
 	// get positions
 	float gravity = -400;
-	if(current->type != WEAPON_ROCKET)
+	if(current->type != WEAPON_GRENADE)
 		gravity = -100;
 
 	float ct = (client_tick()-current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime()*1/(float)SERVER_TICK_SPEED;
@@ -41,7 +41,7 @@ void render_projectile(const obj_projectile *current, int itemid)
 	
 
 	// add particle for this projectile
-	if(current->type == WEAPON_ROCKET)
+	if(current->type == WEAPON_GRENADE)
 	{
 		effect_smoketrail(pos, vel*-1);
 		flow_add(pos, vel*1000*client_frametime(), 10.0f);
@@ -136,6 +136,72 @@ void render_flag(const obj_flag *prev, const obj_flag *current)
 }
 
 
+void render_laser(const struct obj_laser *current)
+{
+
+	vec2 pos = vec2(current->x, current->y);
+	vec2 from = vec2(current->from_x, current->from_y);
+	vec2 dir = normalize(pos-from);
+
+
+
+	float ticks = client_tick() + client_intratick() - current->eval_tick;
+	float ms = (ticks/50.0f) * 1000.0f;
+	float a =  ms / tuning.laser_bounce_delay;
+	a = clamp(a, 0.0f, 1.0f);
+	float ia = 1-a;
+	
+	
+	
+	vec2 out(dir.y, -dir.x);
+	
+	out = out * (4.0f*ia);
+
+	gfx_blend_normal();
+	gfx_texture_set(-1);
+	gfx_quads_begin();
+	
+	vec4 start_color(0.25f,0.25f,0.5f,1.0f);
+	vec4 end_color(0.85f,0.85f,1.0f,1.0f);
+	start_color = end_color;
+	
+	gfx_setcolorvertex(0, start_color.r, start_color.g, start_color.b, start_color.a);
+	gfx_setcolorvertex(1, start_color.r, start_color.g, start_color.b, start_color.a);
+	gfx_setcolorvertex(2, end_color.r, end_color.g, end_color.b, end_color.a);
+	gfx_setcolorvertex(3, end_color.r, end_color.g, end_color.b, end_color.a);
+	
+	from = mix(from, pos, a);
+	
+	gfx_quads_draw_freeform(
+			from.x-out.x, from.y-out.y,
+			from.x+out.x, from.y+out.y,
+			pos.x-out.x, pos.y-out.y,
+			pos.x+out.x, pos.y+out.y
+		);
+		
+	gfx_quads_end();
+	
+	// render head
+	{
+		gfx_blend_normal();
+		gfx_texture_set(data->images[IMAGE_PARTICLES].id);
+		gfx_quads_begin();
+
+		gfx_setcolor(end_color.r, end_color.g, end_color.b, end_color.a);
+	
+		int sprites[] = {SPRITE_PART_SPLAT01, SPRITE_PART_SPLAT02, SPRITE_PART_SPLAT03};
+		select_sprite(sprites[client_tick()%3]);
+		gfx_quads_setrotation(client_tick());
+		gfx_quads_draw(pos.x, pos.y, 32,32);
+		gfx_quads_end();
+	}
+	
+	gfx_blend_normal();	
+}
+
+
+
+
 
 static void render_hand(tee_render_info *info, vec2 center_pos, vec2 dir, float angle_offset, vec2 post_rot_offset)
 {
@@ -416,7 +482,7 @@ void render_player(
 		{
 			case WEAPON_GUN: render_hand(&client_datas[info.clientid].render_info, p, direction, -3*pi/4, vec2(-15, 4)); break;
 			case WEAPON_SHOTGUN: render_hand(&client_datas[info.clientid].render_info, p, direction, -pi/2, vec2(-5, 4)); break;
-			case WEAPON_ROCKET: render_hand(&client_datas[info.clientid].render_info, p, direction, -pi/2, vec2(-4, 7)); break;
+			case WEAPON_GRENADE: render_hand(&client_datas[info.clientid].render_info, p, direction, -pi/2, vec2(-4, 7)); break;
 		}
 
 	}