1-- Boot animation script file 2-- Set the boot tablespace name. 3local ns = {} 4setmetatable(ns, {__index = _G}) 5boot = ns; 6setfenv(1, ns); 7 8 9-- The Boot instance 10local Boot = nil 11local Script = nil 12 13local animation_timer = nil 14local boot_state = nil 15 16local background_image = nil 17local logo_image = nil 18local cloud_image = nil 19local mist_image = nil 20local fog_image = nil 21local crystal_image = nil 22local crystal_shadow_image = nil 23local satellite_image = nil 24local satellite_shadow_image = nil 25local flare_image = nil 26 27-- Init all the needed variables 28function Initialize(boot_instance) 29 Boot = boot_instance; 30 Script = Boot:GetScriptSupervisor(); 31 32 boot_state = Boot:GetState(); 33 34 -- Load the necessary files 35 background_image = Script:CreateImage("data/boot_menu/ep1/background.png"); 36 background_image:SetDimensions(1024.0, 768.0); 37 cloud_image = Script:CreateImage("data/boot_menu/ep1/cloudfield.png"); 38 mist_image = Script:CreateImage("data/boot_menu/ep1/cloudy_mist.png"); 39 mist_image:SetDimensions(1024.0, 768.0); 40 fog_image = Script:CreateImage("data/boot_menu/ep1/fog.png"); 41 fog_image:SetDimensions(1024.0, 768.0); 42 crystal_image = Script:CreateImage("data/boot_menu/ep1/crystal.png"); 43 crystal_shadow_image = Script:CreateImage("data/boot_menu/ep1/crystal_shadow.png"); 44 crystal_shadow_image:SetDimensions(192.0, 168.0); 45 satellite_image = Script:CreateImage("data/boot_menu/ep1/satellite.png"); 46 satellite_image:SetDimensions(34.0, 34.0); 47 satellite_shadow_image = Script:CreateImage("data/boot_menu/ep1/satellite_shadow.png"); 48 satellite_shadow_image:SetDimensions(48.0, 32.0); 49 flare_image = Script:CreateImage("data/boot_menu/ep1/flare.png"); 50 51 -- /// tr: The logo file path here can be overidden to an image of the logo made for your country language. 52 -- /// tr: Leave the same value if you don't plan to change this image. 53 local logo_filepath = vt_system.Translate("data/boot_menu/valyria_logo.png"); 54 logo_image = Script:CreateImage(logo_filepath); 55 56 -- Init the timer 57 animation_timer = vt_system.SystemTimer(7000, 0); 58end 59 60function Reset() 61 if (Boot:GetState() == vt_boot.BootMode.BOOT_STATE_MENU) then 62 AudioManager:PlayMusic("data/music/Soliloquy_1-OGA-mat-pablo.ogg"); 63 end 64end 65 66-- The image alpha channel values 67local logo_alpha = 0.0; 68local bckgrnd_alpha = 0.0; 69 70-- cloud field members 71local x_positions1 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 72local y_position1 = 368.0; 73local x_positions2 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 74local y_position2 = 438.0; 75local x_positions3 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 76local y_position3 = 508.0; 77local x_positions4 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 78local y_position4 = 578.0; 79local x_positions5 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 80local y_position5 = 648.0; 81local x_positions6 = { -110.0, 0.0, 110.0, 220.0 , 330.0, 440.0, 550.0, 660.0, 770.0, 880.0, 990.0}; 82local y_position6 = 718.0; 83 84-- crystal members 85local crystal_decay = 0.0; 86local crystal_time = 0; 87 88-- satellite members 89local sat1_decay = 0.0; 90local sat1_x_position = -15.0; 91local sat1_time = 0; 92local sat1_behind = false; 93 94local sat2_decay = 20.0; 95local sat2_x_position = 80.0; 96local sat2_time = 0; 97local sat2_behind = false; 98 99local sat3_decay = 10.0; 100local sat3_x_position = 40.0; 101local sat3_time = 0; 102local sat3_behind = true; 103 104function UpdateIntroFade() 105 -- After one second of black, start fade in the logo 106 if (animation_timer:GetTimeExpired() > 1000 107 and animation_timer:GetTimeExpired() <= 4000) then 108 109 logo_alpha = (animation_timer:GetTimeExpired() - 1000) / (4000 - 1000); 110 111 elseif (animation_timer:GetTimeExpired() > 4000 112 and animation_timer:GetTimeExpired() <= 7000) then 113 114 bckgrnd_alpha = (animation_timer:GetTimeExpired() - 4000) / (7000 - 4000); 115 end 116end 117 118-- Put the x coord on screen 119function fix_pos(position) 120 if (position <= -248.0) then 121 return position + 1224.0; 122 else 123 return position; 124 end 125end 126 127function UpdateBackgroundAnimation() 128 local time_expired = SystemManager:GetUpdateTime(); 129 130 -- deal with all the clouds 131 for i=1, #x_positions1 do 132 x_positions1[i] = fix_pos(x_positions1[i]) - 0.025 * time_expired; 133 end 134 135 for i=1, #x_positions2 do 136 x_positions2[i] = fix_pos(x_positions2[i]) - 0.05 * time_expired; 137 end 138 139 for i=1, #x_positions3 do 140 x_positions3[i] = fix_pos(x_positions3[i]) - 0.075 * time_expired; 141 end 142 143 for i=1, #x_positions4 do 144 x_positions4[i] = fix_pos(x_positions4[i]) - 0.1 * time_expired; 145 end 146 147 for i=1, #x_positions5 do 148 x_positions5[i] = fix_pos(x_positions5[i]) - 0.125 * time_expired; 149 end 150 151 for i=1, #x_positions6 do 152 x_positions6[i] = fix_pos(x_positions6[i]) - 0.15 * time_expired; 153 end 154 155 -- Compute the crystal and shadow movement 156 crystal_time = crystal_time + time_expired 157 if (crystal_time >= 31400) then 158 crystal_time = crystal_time - 31400; 159 end 160 crystal_decay = 10 + math.sin(0.002 * crystal_time) * 10; 161 162 -- compute the satellites movement 163 sat1_time = sat1_time + time_expired 164 if (sat1_time >= 31400) then 165 sat1_time = sat1_time - 31400; 166 end 167 168 sat1_decay = -5 + math.sin(0.003 * sat1_time) * 10; 169 sat1_x_position = 50 + (math.sin(0.0008 * sat1_time - 0.785) * 75); 170 171 if (sat1_behind) then 172 if (sat1_x_position < -24.0) then 173 sat1_behind = false; 174 end 175 else 176 if (sat1_x_position > 124.0) then 177 sat1_behind = true; 178 end 179 end 180 181 sat2_time = sat2_time + time_expired 182 if (sat2_time >= 31400) then 183 sat2_time = sat2_time - 31400; 184 end 185 186 sat2_decay = -5 + math.sin(0.003 * sat2_time + 1.57) * 10; 187 sat2_x_position = 50 + (math.sin(0.0008 * sat2_time + 3.14) * 75); 188 189 if (sat2_behind) then 190 if (sat2_x_position < -24.0) then 191 sat2_behind = false; 192 end 193 else 194 if (sat2_x_position > 124.0) then 195 sat2_behind = true; 196 end 197 end 198 199 sat3_time = sat3_time + time_expired 200 if (sat3_time >= 31400) then 201 sat3_time = sat3_time - 31400; 202 end 203 204 sat3_decay = -5 + math.sin(0.003 * sat3_time + 0.785) * 10; 205 sat3_x_position = 50 + (math.sin(0.0008 * sat3_time + 0.785) * 75); 206 207 if (sat3_behind) then 208 if (sat3_x_position < -24.0) then 209 sat3_behind = false; 210 end 211 else 212 if (sat3_x_position > 124.0) then 213 sat3_behind = true; 214 end 215 end 216end 217 218 219local music_started = false; 220local snow_started = false; 221 222-- Update the animation 223function Update() 224 animation_timer:Update(); 225 226 UpdateBackgroundAnimation(); 227 228 if (Boot:GetState() == vt_boot.BootMode.BOOT_STATE_INTRO) then 229 -- Start the timer 230 if (animation_timer:IsInitial() == true and animation_timer:IsRunning() ~= true) then 231 animation_timer:Run(); 232 elseif (animation_timer:IsFinished() == true) then 233 -- Show the menu once the presentation is done 234 Boot:ChangeState(vt_boot.BootMode.BOOT_STATE_MENU); 235 end 236 237 -- Update the starting animation 238 UpdateIntroFade(); 239 else 240 logo_alpha = 1.0; 241 bckgrnd_alpha = 1.0; 242 animation_timer:Finish(); 243 end 244 245 if (music_started == false) then 246 AudioManager:PlayMusic("data/music/Soliloquy_1-OGA-mat-pablo.ogg"); 247 music_started = true; 248 end 249 250 -- Update the menu bar alpha in menu mode. 251 252 if (Boot:GetState() == vt_boot.BootMode.BOOT_STATE_MENU) then 253 if (snow_started == false) then 254 Boot:GetParticleManager():AddParticleEffect("data/visuals/particle_effects/snow.lua", 512.0, 384.0); 255 snow_started = true; 256 end 257 end 258end 259 260local cloud_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 261 262function DrawCloudFieldLine(x_positions, y_position) 263 264 for _,v in pairs(x_positions) do 265 VideoManager:Move(v, y_position); 266 cloud_image:Draw(cloud_color); 267 end 268end 269 270local background_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 271 272function DrawBackground() 273 -- The background image 274 background_color:SetAlpha(bckgrnd_alpha); 275 VideoManager:Move(0.0, 0.0); 276 background_image:Draw(background_color); 277 278 -- The passing clouds 279 cloud_color:SetAlpha(0.6 * bckgrnd_alpha); 280 DrawCloudFieldLine(x_positions1, y_position1); 281 DrawCloudFieldLine(x_positions2, y_position2); 282 DrawCloudFieldLine(x_positions3, y_position3); 283 DrawCloudFieldLine(x_positions4, y_position4); 284 DrawCloudFieldLine(x_positions5, y_position5); 285 DrawCloudFieldLine(x_positions6, y_position6); 286end 287 288local mist_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 289local fog_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 290local logo_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 291 292local sat_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 293local sat_shadow_color = vt_video.Color(1.0, 1.0, 1.0, 1.0); 294 295function DrawPostEffects() 296 -- front mist + fog 297 mist_color:SetAlpha(bckgrnd_alpha * 0.6); 298 fog_color:SetAlpha(bckgrnd_alpha * 0.8); 299 VideoManager:Move(0.0, 0.0); 300 mist_image:Draw(mist_color); 301 fog_image:Draw(fog_color); 302 303 sat_shadow_color:SetAlpha(bckgrnd_alpha * 0.3); 304 sat_color:SetAlpha(bckgrnd_alpha * 0.7); 305 306 -- satellite behind 307 if (sat1_behind) then 308 VideoManager:Move(640.0 + sat1_decay + (sat1_x_position / 2.0), 438.0 + (sat1_x_position / 3.0)); 309 satellite_shadow_image:Draw(sat_shadow_color); 310 311 VideoManager:Move(448.0 + sat1_x_position, 368.0 - sat1_decay); 312 satellite_image:Draw(sat_color); 313 end 314 if (sat2_behind) then 315 VideoManager:Move(640.0 + sat2_decay + (sat2_x_position / 2.0), 438.0 + (sat2_x_position / 3.0)); 316 satellite_shadow_image:Draw(sat_shadow_color); 317 318 VideoManager:Move(448.0 + sat2_x_position, 368.0 - sat2_decay); 319 satellite_image:Draw(sat_color); 320 end 321 if (sat3_behind) then 322 VideoManager:Move(640.0 + sat3_decay + (sat3_x_position / 2.0), 438.0 + (sat3_x_position / 3.0)); 323 satellite_shadow_image:Draw(sat_shadow_color); 324 325 VideoManager:Move(448.0 + sat3_x_position, 368.0 - sat3_decay); 326 satellite_image:Draw(sat_color); 327 end 328 329 -- Crystal 330 VideoManager:Move(498.0 + crystal_decay, 438.0); 331 crystal_shadow_image:Draw(sat_shadow_color); 332 333 VideoManager:Move(448.0, 368.0 - crystal_decay); 334 crystal_image:Draw(sat_color); 335 336 VideoManager:Move(384.0, 328.0 - crystal_decay); 337 flare_image:Draw(mist_color); 338 339 -- satellite in front 340 if (sat1_behind == false) then 341 VideoManager:Move(640.0 + sat1_decay + (sat1_x_position / 2.0), 438.0 + (sat1_x_position / 3.0)); 342 satellite_shadow_image:Draw(sat_shadow_color); 343 344 VideoManager:Move(448.0 + sat1_x_position, 368.0 - sat1_decay); 345 satellite_image:Draw(sat_color); 346 end 347 if (sat2_behind == false) then 348 VideoManager:Move(640.0 + sat2_decay + (sat2_x_position / 2.0), 438.0 + (sat2_x_position / 3.0)); 349 satellite_shadow_image:Draw(sat_shadow_color); 350 351 VideoManager:Move(448.0 + sat2_x_position, 368.0 - sat2_decay); 352 satellite_image:Draw(sat_color); 353 end 354 if (sat3_behind == false) then 355 VideoManager:Move(640.0 + sat3_decay + (sat3_x_position / 2.0), 438.0 + (sat3_x_position / 3.0)); 356 satellite_shadow_image:Draw(sat_shadow_color); 357 358 VideoManager:Move(448.0 + sat3_x_position, 368.0 - sat3_decay); 359 satellite_image:Draw(sat_color); 360 end 361 362 -- Logo 363 logo_color:SetAlpha(logo_alpha); 364 VideoManager:Move(198.0, 18.0); 365 logo_image:Draw(logo_color); 366end 367