about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-30 19:46:31 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-30 19:46:31 +0000
commitf826bc6cac4f4dfc191fa1d94f3336e117f44278 (patch)
tree4e1a74ae9b3caf6f47ea28d17f22aa48a7019c29 /src/game/client
parent57da0cae4f2d072211b39a6618a102c6b620197f (diff)
downloadzcatch-f826bc6cac4f4dfc191fa1d94f3336e117f44278.tar.gz
zcatch-f826bc6cac4f4dfc191fa1d94f3336e117f44278.zip
larger update. reduced the amount of video memory used from ~60 to ~36mb on a typical map
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/game_client.cpp33
-rw-r--r--src/game/client/menu.cpp48
2 files changed, 26 insertions, 55 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index 5ff6f777..b3f1bef6 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -5,19 +5,17 @@
 #include <string.h>
 #include <engine/config.h>
 #include <engine/client/ui.h>
-#include <engine/client/client.h>
 #include "../game.h"
 #include "mapres_image.h"
 #include "mapres_tilemap.h"
 #include "data.h"
 #include "menu.h"
 
-extern client main_client;
 using namespace baselib;
 
 data_container *data = 0x0;
 
-int charids[16] = {2,10,0,4,12,6,14,1,9,15,13,11,7,5,8,3};
+static int charids[16] = {2,10,0,4,12,6,14,1,9,15,13,11,7,5,8,3};
 
 static int gametype = GAMETYPE_DM;
 static int skinseed = 0;
@@ -122,7 +120,7 @@ static void select_sprite(sprite *spr, int flags=0, int sx=0, int sy=0)
 		gfx_quads_setsubset(x/(float)cx,y/(float)cy,(x+w)/(float)cx,(y+h)/(float)cy);
 }
 
-static void select_sprite(int id, int flags=0, int sx=0, int sy=0)
+void select_sprite(int id, int flags=0, int sx=0, int sy=0)
 {
 	if(id < 0 || id > data->num_sprites)
 		return;
@@ -324,7 +322,7 @@ public:
 	void render()
 	{
 		gfx_blend_additive();
-		gfx_texture_set(data->images[IMAGE_PARTICLES].id);
+		gfx_texture_set(data->images[IMAGE_GAME].id);
 		gfx_quads_begin();
 		
 		for(int i = 0; i < num_particles; i++)
@@ -606,7 +604,7 @@ void modc_newsnapshot()
 
 static void render_projectile(obj_projectile *prev, obj_projectile *current, int itemid)
 {
-	gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+	gfx_texture_set(data->images[IMAGE_GAME].id);
 	gfx_quads_begin();
 	
 	select_sprite(data->weapons[current->type%data->num_weapons].sprite_proj);
@@ -631,7 +629,7 @@ static void render_projectile(obj_projectile *prev, obj_projectile *current, int
 
 static void render_powerup(obj_powerup *prev, obj_powerup *current)
 {
-	gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+	gfx_texture_set(data->images[IMAGE_GAME].id);
 	gfx_quads_begin();
 	vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), client_intratick());
 	float angle = 0.0f;
@@ -925,7 +923,7 @@ static void render_player(obj_player *prev, obj_player *player)
 	// draw hook
 	if(player->hook_active)
 	{
-		gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+		gfx_texture_set(data->images[IMAGE_GAME].id);
 		gfx_quads_begin();
 		//gfx_quads_begin();
 
@@ -955,7 +953,7 @@ static void render_player(obj_player *prev, obj_player *player)
 
 	// draw gun
 	{
-		gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+		gfx_texture_set(data->images[IMAGE_GAME].id);
 		gfx_quads_begin();
 		gfx_quads_setrotation(state.attach.angle*pi*2+angle);
 
@@ -1189,7 +1187,7 @@ void ingamemenu_render()
 	if (ui_do_button(&menu_quit, "Disconnect", 0, column1_x, row3_y, 250, 48, draw_teewars_button))
 	{
 		menu_active = 0;
-		main_client.disconnect();
+		client_disconnect();
 	}
 	
 	gfx_texture_set(data->images[IMAGE_CURSOR].id);
@@ -1389,17 +1387,18 @@ void modc_render()
 		
 		static vec2 cloud_pos[6] = {vec2(-500,0),vec2(-500,200),vec2(-500,400)};
 		static float cloud_speed[6] = {30, 20, 10};
-		static int cloud_images[6] = {IMAGE_CLOUD_1, IMAGE_CLOUD_2, IMAGE_CLOUD_3};
+		static int cloud_sprites[6] = {SPRITE_CLOUD1, SPRITE_CLOUD2, SPRITE_CLOUD3};
 		
+		gfx_texture_set(data->images[IMAGE_CLOUDS].id);
+		gfx_quads_begin();
 		for(int i = 0; i < 3; i++)
 		{
 			float parallax_amount = 0.55f;
-			gfx_texture_set(data->images[cloud_images[i]].id);
-			gfx_quads_begin();
+			select_sprite(cloud_sprites[i]);
 			gfx_quads_drawTL((cloud_pos[i].x+fmod(client_localtime()*cloud_speed[i]+i*100.0f, 1700.0f))+screen_x*parallax_amount,
 				cloud_pos[i].y+screen_y*parallax_amount, 300, 300);
-			gfx_quads_end();
 		}
+		gfx_quads_end();
 
 		
 		// draw backdrop
@@ -1407,7 +1406,7 @@ void modc_render()
 		gfx_quads_begin();
 		float parallax_amount = 0.25f;
 		for(int x = -1; x < 3; x++)
-			gfx_quads_drawTL(1024*x+screen_x*parallax_amount, (screen_y)*parallax_amount+150, 1024, 1024);
+			gfx_quads_drawTL(1024*x+screen_x*parallax_amount, (screen_y)*parallax_amount+150+512, 1024, 512);
 		gfx_quads_end();
 	}
 	
@@ -1461,7 +1460,7 @@ void modc_render()
 	
 	if(local_player)
 	{
-		gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+		gfx_texture_set(data->images[IMAGE_GAME].id);
 		gfx_quads_begin();
 		
 		// render cursor
@@ -1540,7 +1539,7 @@ void modc_render()
 			x -= 44.0f;
 			if (killmsgs[r].weapon >= 0)
 			{
-				gfx_texture_set(data->images[IMAGE_WEAPONS].id);
+				gfx_texture_set(data->images[IMAGE_GAME].id);
 				gfx_quads_begin();
 				select_sprite(data->weapons[killmsgs[r].weapon].sprite_body);
 				draw_sprite(x, y+28, 96);
diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp
index 799f351d..8a02015a 100644
--- a/src/game/client/menu.cpp
+++ b/src/game/client/menu.cpp
@@ -141,7 +141,8 @@ struct pretty_font
 
 extern pretty_font *current_font;
 
-void render_sun(float x, float y);
+extern void render_sun(float x, float y);
+extern void select_sprite(int id, int flags=0, int sx=0, int sy=0);
 
 void draw_background(float t)
 {
@@ -152,48 +153,19 @@ void draw_background(float t)
 
 	render_sun(170, 170);
 
-    gfx_texture_set(data->images[IMAGE_CLOUD_1].id);
+    gfx_texture_set(data->images[IMAGE_CLOUDS].id);
     gfx_quads_begin();
-    gfx_quads_setcolor(1,1,1,1);
-	gfx_quads_setsubset(
-		0.0f, // startx
-		0.0f, // starty
-		1.0f, // endx
-		1.0f); // endy								
-    gfx_quads_drawTL(3500 - fmod(t * 20 + 2000, 4524), 0, 512, 512);
-    gfx_quads_end();
-
-    gfx_texture_set(data->images[IMAGE_CLOUD_2].id);
-    gfx_quads_begin();
-    gfx_quads_setcolor(1,1,1,1);
-	gfx_quads_setsubset(
-		0.0f, // startx
-		0.0f, // starty
-		1.0f, // endx
-		1.0f); // endy								
-    gfx_quads_drawTL(3000 - fmod(t * 50 + 2000, 4024), 150, 512, 512);
-    gfx_quads_end();
-
-    gfx_texture_set(data->images[IMAGE_CLOUD_3].id);
-    gfx_quads_begin();
-    gfx_quads_setcolor(1,1,1,1);
-	gfx_quads_setsubset(
-		0.0f, // startx
-		0.0f, // starty
-		1.0f, // endx
-		1.0f); // endy								
-    gfx_quads_drawTL(4000 - fmod(t * 60 + 500, 4512), 300, 256, 256);
+		select_sprite(SPRITE_CLOUD1);
+		gfx_quads_drawTL(3500 - fmod(t * 20 + 2000, 4524), 0, 512, 512);
+		select_sprite(SPRITE_CLOUD2);
+		gfx_quads_drawTL(3000 - fmod(t * 50 + 2000, 4024), 150, 512, 512);
+		select_sprite(SPRITE_CLOUD3);
+		gfx_quads_drawTL(4000 - fmod(t * 60 + 500, 4512), 300, 256, 256);
     gfx_quads_end();
 
     gfx_texture_set(data->images[IMAGE_MENU_BACKGROUND].id);
     gfx_quads_begin();
-    gfx_quads_setcolor(1,1,1,1);
-	gfx_quads_setsubset(
-		0.0f, // startx
-		0.0f, // starty
-		1.0f, // endx
-		1.0f); // endy								
-    gfx_quads_drawTL(0, -400, 1600, 1600);
+	    gfx_quads_drawTL(0, 400, 1600, 1600/2);
     gfx_quads_end();
 
 	int frame = int(t * 10) % 3;