summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/imgs/tiles/space_parallax.pngbin0 -> 3026 bytes
-rw-r--r--data/maps/map1.datbin8384008 -> 8384008 bytes
-rw-r--r--include/asset_defs.h1
-rw-r--r--src/asset_defs.c1
-rw-r--r--src/game.c4
-rw-r--r--src/map.c54
6 files changed, 19 insertions, 41 deletions
diff --git a/data/imgs/tiles/space_parallax.png b/data/imgs/tiles/space_parallax.png
new file mode 100644
index 0000000..340b3ae
--- /dev/null
+++ b/data/imgs/tiles/space_parallax.png
Binary files differ
diff --git a/data/maps/map1.dat b/data/maps/map1.dat
index 6729378..811e5f1 100644
--- a/data/maps/map1.dat
+++ b/data/maps/map1.dat
Binary files differ
diff --git a/include/asset_defs.h b/include/asset_defs.h
index d691e61..f76a2bc 100644
--- a/include/asset_defs.h
+++ b/include/asset_defs.h
@@ -94,6 +94,7 @@ image* img_zombie_chunk_blood;
// Tiles
image* img_mars_surface;
+image* img_space_parallax;
image* img_tile_floor1;
image* img_tile_floor2;
diff --git a/src/asset_defs.c b/src/asset_defs.c
index 8a2e701..406fc69 100644
--- a/src/asset_defs.c
+++ b/src/asset_defs.c
@@ -99,6 +99,7 @@ void load_assets() {
img_mars_surface = assets_load_image_from_file("data/imgs/tiles/mars_surface.png");
img_tile_floor1 = assets_load_image_from_file("data/imgs/tiles/floor1.png");
img_tile_floor2 = assets_load_image_from_file("data/imgs/tiles/floor2.png");
+ img_space_parallax = assets_load_image_from_file("data/imgs/tiles/space_parallax.png");
// sounds
wav_throwable_bounce = Mix_LoadWAV("data/sounds/throwable_bounce.wav");
diff --git a/src/game.c b/src/game.c
index 01633bc..d17e432 100644
--- a/src/game.c
+++ b/src/game.c
@@ -353,12 +353,12 @@ static void move_camera(platform_window* window) {
float speedx = window->width / 1000.0f;
float diffx = (_next_camera_pos.x - _global_camera.x);
if (abs(diffx) <= speedx) diffx = 0.0f;
- speedx += (abs(diffx)/200.0f*speedx);
+ speedx += (abs(diffx)/50.0f*speedx);
float speedy = window->height / 600.0f;
float diffy = (_next_camera_pos.y - _global_camera.y);
if (abs(diffy) <= speedy) diffy = 0.0f;
- speedy += (abs(diffy)/200.0f*speedy);
+ speedy += (abs(diffy)/50.0f*speedy);
float length = sqrt(diffx * diffx + diffy * diffy);
if (length == 0) length = 1.0f;
diff --git a/src/map.c b/src/map.c
index 087d03c..555c524 100644
--- a/src/map.c
+++ b/src/map.c
@@ -171,6 +171,8 @@ void load_mapdata_into_world() {
int highest_point_bottomright = get_height_of_tile_br(h, x, y);
int highest_point_bottomleft = get_height_of_tile_bl(h, x, y);
+ if (x >= 205) map_to_load.tiles[y][x] = TILE_NONE;
+
loaded_map.heightmap[y][x] = (tile){.height = h, .type = map_to_load.tiles[y][x], highest_point_topleft, highest_point_topright, highest_point_bottomleft, highest_point_bottomright};
loaded_map.lightmap[y][x] = (light_data){0.0f,0.0f,0.0f,0.0f};
}
@@ -269,6 +271,8 @@ void load_mapdata_into_world() {
object o = loaded_map.objects[i];
if (!o.active) continue;
+ if (o.position.x >= 205) map_to_load.objects[i].active = 0;
+
if (o.type == OBJECT_ZOMBIE_SPAWNER) {
create_spawner((vec2){.x = o.position.x, .y = o.position.y});
}
@@ -406,56 +410,28 @@ vec2f world_pos_to_screen_pos(platform_window* window, float x, float y, float z
static void draw_backdrop(platform_window* window)
{
- map_info info = get_map_info(window);
-
- int tilemap_render_min_y = (_global_camera.y / info.tile_height)-1;
- int tilemap_render_max_y = tilemap_render_min_y + (window->height/ info.tile_height) + 2;
+ //map_info info = get_map_info(window);
+ int tile_size = 512;
- int tilemap_render_min_x = (_global_camera.x / info.tile_width)-1;
- int tilemap_render_max_x = tilemap_render_min_x + (window->width/ info.tile_width) + 2;
+ int tilemap_render_min_y = (_global_camera.y / tile_size)-2;
+ int tilemap_render_max_y = tilemap_render_min_y + (window->height/ tile_size) + 3;
- // north of spaceship
- for (int y = -40; y <= 7; y++)
- {
- if (y < tilemap_render_min_y) continue;
- if (y > tilemap_render_max_y) continue;
-
- for (int x = -40; x <= MAP_SIZE_X + 40; x++)
- {
- if (x < tilemap_render_min_x) continue;
- if (x > tilemap_render_max_x) continue;
-
- renderer->render_image(img_mars_surface, x*info.tile_width, y*info.tile_width, info.tile_width, info.tile_height);
- }
- }
-
- // west of spaceship
- for (int y = 0; y <= MAP_SIZE_Y; y++)
- {
- if (y < tilemap_render_min_y) continue;
- if (y > tilemap_render_max_y) continue;
-
- for (int x = -40; x <= 10; x++)
- {
- if (x < tilemap_render_min_x) continue;
- if (x > tilemap_render_max_x) continue;
-
- renderer->render_image(img_mars_surface, x*info.tile_width, y*info.tile_width, info.tile_width, info.tile_height);
- }
- }
+ int tilemap_render_min_x = (_global_camera.x / tile_size)-2;
+ int tilemap_render_max_x = tilemap_render_min_x + (window->width/ tile_size) + 3;
- // south of spaceship
- for (int y = 48; y <= 70; y++)
+ for (int y = tilemap_render_min_y; y <= tilemap_render_max_y; y++)
{
if (y < tilemap_render_min_y) continue;
if (y > tilemap_render_max_y) continue;
- for (int x = -40; x <= MAP_SIZE_X + 40; x++)
+ for (int x = tilemap_render_min_x; x <= tilemap_render_max_x; x++)
{
if (x < tilemap_render_min_x) continue;
if (x > tilemap_render_max_x) continue;
- renderer->render_image(img_mars_surface, x*info.tile_width, y*info.tile_width, info.tile_width, info.tile_height);
+ renderer->render_image(img_space_parallax,
+ ((int)(_global_camera.x*0.9f)%512) + x*tile_size,
+ ((int)(_global_camera.y*0.9f)%512) + y*tile_size, tile_size, tile_size);
}
}
}