1local ns = {} 2setmetatable(ns, {__index = _G}) 3mt_elbrus_landscape_anim = ns; 4setfenv(1, ns); 5 6-- Animated image members 7local background = {}; 8 9-- Scrolling offsets 10local offset_x = 0; 11-- Must be > 1024.0 12local image_width = 1411; 13local first_update_done = false; 14 15-- c++ objects instances 16local Map = nil 17local Script = nil 18local Effects = nil 19 20function Initialize(map_instance) 21 Map = map_instance; 22 Script = Map:GetScriptSupervisor(); 23 Effects = Map:GetEffectSupervisor(); 24 -- Load the creatures animated background 25 background = Script:CreateImage("data/story/mt_elbrus/elbrus_landscape.png"); 26 background:SetDimensions(image_width, 768); 27 28 first_update_done = false; 29end 30 31 32function Update() 33 34 if (first_update_done == false) then 35 first_update_done = true; 36 -- 32.0 is the number of tiles on the x axis in the map mode. 37 -- 1024 is the area that is always shown on screen. 38 if (Map:GetMapXOffset() >= ((Map:GetMapWidth() * 2.0) - 32.0)) then 39 offset_x = 0; 40 else 41 offset_x = ((Map:GetMapWidth() * 2.0) - Map:GetMapXOffset() - 32.0) / (2.0 * Map:GetMapWidth() * (image_width - 1024)); 42 end 43 end 44 45 offset_x = offset_x + Effects:GetCameraXMovement() * Map:GetMapWidth() / image_width 46 -- Trouble-Shooting: This prevents certain ugly edge-cases. 47 if (offset_x < 0.0) then 48 offset_x = 0.0; 49 end 50 51 --print(offset_x, Map:GetMapXOffset(), Map:GetMapWidth()) 52end 53 54local white_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 55 56function DrawBackground() 57 -- Draw background animation 58 VideoManager:Move(512.0 + offset_x, 768.0); 59 background:Draw(white_color); 60end 61