Godzil 3 lat temu
rodzic
commit
0c6fc9c239
2 zmienionych plików z 16 dodań i 4 usunięć
  1. 15 3
      assets/scripts/Level1.lua
  2. 1 1
      source/Game.cpp

+ 15 - 3
assets/scripts/Level1.lua

@@ -1,3 +1,14 @@
+-- Load a different tilemap image depending on the current system time
+local current_system_hour = os.date("*t").hour
+
+-- Use a day-map or night-map texture (9am - 6pm)
+local map_texture_asset_id
+if current_system_hour >= 9 and current_system_hour < 18 then
+    map_texture_asset_id = "tilemap-texture-day"
+else
+    map_texture_asset_id = "tilemap-texture-night"
+end
+
 -- Define a table with the start values of the first level
 Level = {
     ----------------------------------------------------
@@ -5,7 +16,8 @@ Level = {
     ----------------------------------------------------
     assets = {
         [0] =
-        { type = "texture", id = "tilemap-texture",             file = "./assets/tilemaps/jungle.png" },
+        { type = "texture", id = "tilemap-texture-day",         file = "./assets/tilemaps/jungle.png" },
+        { type = "texture", id = "tilemap-texture-night",       file = "./assets/tilemaps/jungle-night.png" },
         { type = "texture", id = "chopper-texture",             file = "./assets/images/chopper-green-spritesheet.png" },
         { type = "texture", id = "su27-texture",                file = "./assets/images/su27-spritesheet.png" },
         { type = "texture", id = "f22-texture",                 file = "./assets/images/f22-spritesheet.png" },
@@ -84,7 +96,7 @@ Level = {
     ----------------------------------------------------
     tilemap = {
         map_file = "./assets/tilemaps/jungle.map",
-        texture_asset_id = "tilemap-texture",
+        texture_asset_id = map_texture_asset_id,
         num_rows = 20,
         num_cols = 25,
         tile_size = 32,
@@ -257,7 +269,7 @@ Level = {
                     health_percentage = 100
                 },
                 projectile_emitter = {
-                    projectile_velocity = { x = 100, y = 0 },
+                    projectile_velocity = { x = math.random(10, 200), y = 0 },
                     projectile_duration = 2, -- seconds
                     repeat_frequency = 1, -- seconds
                     hit_percentage_damage = 20,

+ 1 - 1
source/Game.cpp

@@ -162,7 +162,7 @@ void Game::Setup()
     this->registry->addSystem<RenderHealthSystem>();
     this->registry->addSystem<RenderGUISystem>();
 
-    this->lua.open_libraries(sol::lib::base, sol::lib::math);
+    this->lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::os);
 
     loader.LoadLevel(this->lua, this->registry, this->assetStore, this->renderer, 1);
 }