diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_defs.c | 1 | ||||
| -rw-r--r-- | src/game.c | 4 | ||||
| -rw-r--r-- | src/map.c | 54 |
3 files changed, 18 insertions, 41 deletions
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"); @@ -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; @@ -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); } } } |
