about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 12:01:20 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-22 12:01:20 +0000
commit2231cd8c39b553e1ddf4bf1388083c618b708470 (patch)
tree819646eef860ee3215d411c33da8214620c19536 /src
parentbcb97cfdf631edec486e8f56349a275ddb706392 (diff)
downloadzcatch-2231cd8c39b553e1ddf4bf1388083c618b708470.tar.gz
zcatch-2231cd8c39b553e1ddf4bf1388083c618b708470.zip
various small changes
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/client.h2
-rw-r--r--src/engine/client/gfx.cpp17
-rw-r--r--src/engine/interface.h2
-rw-r--r--src/game/client/game_client.cpp15
-rw-r--r--src/game/client/mapres_tilemap.cpp36
-rw-r--r--src/game/client/menu.h2
-rw-r--r--src/game/server/game_server.cpp10
7 files changed, 64 insertions, 20 deletions
diff --git a/src/engine/client/client.h b/src/engine/client/client.h
index db9d142d..f433a376 100644
--- a/src/engine/client/client.h
+++ b/src/engine/client/client.h
@@ -45,4 +45,4 @@ public:
 	void pump_network();	
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp
index d8b3041c..db020cef 100644
--- a/src/engine/client/gfx.cpp
+++ b/src/engine/client/gfx.cpp
@@ -35,7 +35,10 @@ static opengl::vertex_buffer vertex_buffer;
 //static int screen_height = 600;
 static float rotation = 0;
 static int quads_drawing = 0;
-
+static float screen_x0 = 0;
+static float screen_y0 = 0;
+static float screen_x1 = 0;
+static float screen_y1 = 0;
 
 struct texture_holder
 {
@@ -415,11 +418,23 @@ void gfx_clear(float r, float g, float b)
 
 void gfx_mapscreen(float tl_x, float tl_y, float br_x, float br_y)
 {
+	screen_x0 = tl_x;
+	screen_y0 = tl_y;
+	screen_x1 = br_x;
+	screen_y1 = br_y;
 	mat4 mat;
 	mat.ortho(tl_x, br_x, br_y, tl_y, 1.0f, 10.f);
 	opengl::matrix_projection(&mat);
 }
 
+void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y)
+{
+	*tl_x = screen_x0;
+	*tl_y = screen_y0;
+	*br_x = screen_x1;
+	*br_y = screen_y1;
+}
+
 void gfx_setoffset(float x, float y)
 {
 	//const float scale = 0.75f;
diff --git a/src/engine/interface.h b/src/engine/interface.h
index 295528b0..05c1b961 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -750,6 +750,8 @@ int client_tickspeed();
 void gfx_pretty_text(float x, float y, float size, const char *text);
 float gfx_pretty_text_width(float size, const char *text);
 
+void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y);
+
 void mods_message(int msg, int client_id);
 void modc_message(int msg);
 
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index 511df061..7b5b69c4 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -629,7 +629,7 @@ static void render_powerup(obj_powerup *prev, obj_powerup *current)
 	float size = 64.0f;
 	if (current->type == POWERUP_TYPE_WEAPON)
 	{
-		angle = -0.25f * pi * 2.0f;
+		angle = 0; //-pi/6;//-0.25f * pi * 2.0f;
 		select_sprite(data->weapons[current->subtype%data->num_weapons].sprite_body);
 		size = data->weapons[current->subtype%data->num_weapons].visual_size;
 	}
@@ -1213,9 +1213,16 @@ void modc_render()
 	gfx_clear(0.65f,0.78f,0.9f);
 
 	// draw the sun	
-	{
-		render_sun(local_player_pos.x*0.5f, local_player_pos.y*0.5f);
-	}
+	render_sun(local_player_pos.x*0.5f, local_player_pos.y*0.5f);
+	
+	// draw backdrop
+	gfx_texture_set(data->images[IMAGE_BACKDROP].id);
+	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_end();
+	
 	
 	// render map
 	tilemap_render(32.0f, 0);
diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp
index dfc7a7f8..6038e67c 100644
--- a/src/game/client/mapres_tilemap.cpp
+++ b/src/game/client/mapres_tilemap.cpp
@@ -15,6 +15,10 @@ void tilemap_render(float scale, int fg)
 	if(!map_is_loaded())
 		return;
 	
+	
+	float screen_x0, screen_y0, screen_x1, screen_y1;
+	gfx_getscreen(&screen_x0, &screen_y0, &screen_x1, &screen_y1);
+	
 	// fetch indecies
 	int start, num;
 	map_get_type(MAPRES_TILEMAP, &start, &num);
@@ -40,23 +44,35 @@ void tilemap_render(float scale, int fg)
 			gfx_texture_set(img_get(tmap->image));
 			gfx_quads_begin();
 			
-			int c = 0;
 			float frac = (1.0f/1024.0f);//2.0f; //2.0f;
 			float texsize = 1024.0f;
 			float nudge = 0.5f/texsize;
-			for(int y = 0; y < tmap->height; y++)
-				for(int x = 0; x < tmap->width; x++, c++)
+			
+			int startx = (int)(screen_x0/scale) - 1;
+			int endx = (int)(screen_x1/scale) + 1;
+			int starty = (int)(screen_y0/scale) - 1;
+			int endy = (int)(screen_y1/scale) + 1;
+			for(int y = starty; y < endy; y++)
+				for(int x = startx; x < endx; x++)
 				{
+					int mx = x;
+					int my = y;
+					if(mx<0) mx = 0;
+					if(mx>=tmap->width) mx = tmap->width-1;
+					if(my<0) my = 0;
+					if(my>=tmap->height) my = tmap->height-1;
+					
+					int c = mx + my*tmap->width;
+						
 					unsigned char d = data[c*2];
 					if(d)
 					{
-						/*
-						gfx_quads_setsubset(
-							(d%16)/16.0f*s+frac,
-							(d/16)/16.0f*s+frac,
-							((d%16)/16.0f+1.0f/16.0f)*s-frac,
-							((d/16)/16.0f+1.0f/16.0f)*s-frac);
-							*/
+						//gfx_quads_setsubset(
+						//	(d%16)/16.0f*s+frac,
+						//	(d/16)/16.0f*s+frac,
+						//	((d%16)/16.0f+1.0f/16.0f)*s-frac,
+						//	((d/16)/16.0f+1.0f/16.0f)*s-frac);
+							
 						int tx = d%16;
 						int ty = d/16;
 						int px0 = tx*(1024/16);
diff --git a/src/game/client/menu.h b/src/game/client/menu.h
index 0a8c1fe3..66c69953 100644
--- a/src/game/client/menu.h
+++ b/src/game/client/menu.h
@@ -14,4 +14,4 @@ int ui_do_check_box(void *id, float x, float y, float w, float h, int value);
 int do_scroll_bar_horiz(void *id, float x, float y, float width, int steps, int last_index);
 int do_scroll_bar_vert(void *id, float x, float y, float height, int steps, int last_index);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp
index 6d026fb4..a1f1b72e 100644
--- a/src/game/server/game_server.cpp
+++ b/src/game/server/game_server.cpp
@@ -10,7 +10,7 @@ data_container *data = 0x0;
 using namespace baselib;
 
 // --------- DEBUG STUFF ---------
-const bool debug_bots = true;
+const bool debug_bots = false;
 
 // --------- PHYSICS TWEAK! --------
 const float ground_control_speed = 7.0f;
@@ -1691,14 +1691,18 @@ void mods_init()
 		case ITEM_ARMOR:
 			type = POWERUP_TYPE_ARMOR;
 			break;
+
 		case ITEM_NINJA:
 			type = POWERUP_TYPE_NINJA;
 			subtype = WEAPON_NINJA;
 			break;
 		};
 		
-		powerup *ppower = new powerup(type, subtype);
-		ppower->pos = vec2(it->x, it->y);
+		if(type != -1)
+		{
+			powerup *ppower = new powerup(type, subtype);
+			ppower->pos = vec2(it->x, it->y);
+		}
 	}
 	
 	world.insert_entity(&gameobj);