

| CODE |
| // ---------------------------------------------------------------------------------------- // Script: LightsOut // Version: 1.4 // Author: flattspott // Features: 50 solveable puzzles // Install: Copy the both LightsOut.xas and LightsOut.xml to your Xbox // They need to be in the same folder. Do NOT rename the files. // Usage: A standard CallFile will do. // CallFile // ----------------------------------------------------------------------------------------- If $MXMVersion$ #^ "0.9n.6" Goto vError Goto DefinePath :vError BeginDraw MessageBox "This game is not compatible with MXM $MXMVersion$" Goto End :DefinePath Set PathTemp %0% SetFunc Path Replace "LightsOut.xas" "" %PathTemp% :MediaCheck SetFunc UseAudio1 FileExists "C:\\Audio\\MainAudio\\Global Scroll Beep.wav" If# %UseAudio1% == 1 Then LoadSound Move "C:\\Audio\\MainAudio\\Global Scroll Beep.wav" EndIf SetFunc UseAudio2 FileExists "C:\\Audio\\MainAudio\\Global Scroll Beep.wav" If# %UseAudio2% == 1 Then LoadSound Click "C:\\Audio\\MainAudio\\Global Keyboard Stroke 1.wav" EndIf SetFunc UseAudio3 FileExists "C:\\Audio\\MainAudio\\Global A Button Select.wav" If# %UseAudio3% == 1 Then LoadSound Select "C:\\Audio\\MainAudio\\Global A Button Select.wav" EndIf SetFunc UseAudio4 FileExists "C:\\Audio\\MainAudio\\Global B Button Back.wav" If# %UseAudio4% == 1 Then LoadSound Play "C:\\Audio\\MainAudio\\Global B Button Back.wav" EndIf :Start SetFunc UseOverlay FileExists %Path%overlay.png If# %UseOverlay% == 1 Then LoadImage Overlay %Path%overlay.png EndIf :BeginGame XMLOpen Game %Path%LightsOut.xml XMLCreate cGame Current Set Left 240 Set Top 160 Set Lvl 1 :Start XMLGetValue Game C0 !.Colors^Off XMLGetValue Game C1 !.Colors^On :RefreshSelect BeginDraw Box 0 0 640 480 DARKGRAY GRAY Box 0 144 640 192 LIGHTGRAY LIGHTGRAY Box 238 158 162 162 DARKGRAY GRAY Set I 0 For X = 0 to 4 XMLGetValue Game CurrentRow !.Levels.Level%Lvl%^Row%X% For Q = 0 To 4 Set T %X% Mult T 32 Add T %Top% Set L %Q% Mult L 32 Add L %Left% SetFunc CurrentPiece Mid %Q% 1 %CurrentRow% If# %CurrentPiece% == 1 Then Set Color %C1% Else Set Color %C0% EndIf Box %L% %T% 30 30 %Color% %Color% XMLSetValue cGame !.Block^%I%~Status %CurrentPiece% XMLSetValue cGame !.Block^%I%~L %L% XMLSetValue cGame !.Block^%I%~T %T% Add I 1 Next Next If# %UseOverlay% == 1 Then Image Overlay 0 0 640 480 EndIf Text 320 115 Center "LightsOut" WHITE Text 320 340 Center "Choose a Level" WHITE Text 320 360 Center "Level %Lvl% of 50" WHITE Text 320 380 Center "Press Y to view Help" WHITE EndDraw If# %RandomOn% == 1 Then Return EndIf IQWaitMsg ANY If %MSG_ID% == "UI_RT" Goto NextLevel // GAMEPAD RIGHT BUTTON If %MSG_ID% == "UI_LF" Goto PrevLevel // GAMEPAD LEFT BUTTON If %MSG_ID% == "UI_SELECT" Goto PlayLevel // GAMEPAD A BUTTON If %MSG_ID% == "MUSIC_NEXT" Goto LoadGame // GAMEPAD X BUTTON If %MSG_ID% == "UI_BACK" Goto End // GAMEPAD B BUTTON If %MSG_ID% == "SYS_MENU" Goto Help1 // GAMEPAD Y BUTTON If %MSG_ID% == "UI_VIRTKB" Goto Credits // GAMEPAD Y BUTTON + R-TRIGGER If %MSG_ID% == "SYS_HELP" Goto GetRandom // GAMEPAD WHITE BUTTON If %MSG_ID% == "SYS_GAMEHELP" Goto GameplayHelp // GAMEPAD BLACK BUTTON If %MSG_ID% == "SYS_REBOOT" Goto RefreshOptions Goto RefreshSelect :RefreshOptions If# %UseOverlay% == 0 Then Set Option Enable Else Set Option Disable EndIf BeginDraw Text 320 215 Center "Skin Options" Text 320 240 Center "Press A to %Option% skin" EndDraw IQWaitMsg ANY If %MSG_ID% == "UI_SELECT" Goto SkinCheck Goto RefreshOptions :SkinCheck SetFunc Skin FileExists %Path%overlay.png If# %Skin% == 0 Then SetFunc Skin FileExists %Path%_overlay.png EndIf If# %Skin% == 0 Then MsgBox "Couldn't find a skin to use" Goto Start EndIf :SkinSwitch If# %UseOverlay% == 0 Then Rename %Path%_overlay.png %Path%overlay.png Else Rename %Path%overlay.png %Path%_overlay.png CloseImage Overlay EndIf Goto Start :Help1 MsgBox "LightsOut Help$eol$Left and Right to change levels$eol$A to play selected level$eol$WHITE to jump to a random level$eol$BLACK to view how to play LightsOut$eol$B to Exit$eol$X to load last game$eol$R-Trigger + Start for Skin options$eol$R-Trigger + Y to view credits$eol$Y to view help" Goto RefreshSelect :GameplayHelp MsgBox "The object of LightsOut is simple. All you have do is click around on the board to turn the blocks on or off. You complete the level after turning all of the Blue blocks off." Goto RefreshSelect :GetRandom Set RandomOn 1 Set Random $rand$ Mod Random 50 If# %Random% < 0 Goto GetRandom If# %Random% == 0 Then Add Random 1 EndIf For Rnd = 0 To %Random% Set Lvl %Rnd% If# %UseAudio3% == 1 Then PlaySound Select EndIf GoSub RefreshSelect Next Set RandomOn 0 Goto RefreshSelect :NextLevel If# %Lvl% == 50 Then Set Lvl 1 Else Add Lvl 1 EndIf If# %UseAudio3% == 1 Then PlaySound Select EndIf Goto RefreshSelect :PrevLevel If# %Lvl% == 1 Then Set Lvl 50 Else Sub Lvl 1 EndIf If# %UseAudio3% == 1 Then PlaySound Select EndIf Goto RefreshSelect :PlayLevel Set bMoves 0 If# %UseAudio4% == 1 Then PlaySound Play EndIf XMLSave cGame %Path%Current.xml XMLClose cGame :LoadGame Set Index 0 Set PointerLEFT 240 Set PointerTOP 160 XMLOpen cGame %Path%Current.xml :RefreshGame GoSub WinCheck BeginDraw Box 0 0 640 480 DARKGRAY GRAY Box 0 144 640 192 LIGHTGRAY LIGHTGRAY Box 238 158 162 162 DARKGRAY GRAY For K = 0 To 24 XMLGetValue cGame BlockStatus !.Block.%K%~Status XMLGetValue cGame BlockLEFT !.Block.%K%~L XMLGetValue cGame BlockTOP !.Block.%K%~T If# %BlockStatus% == 1 Then Set Color %C1% Else Set Color %C0% EndIf Box %BlockLEFT% %BlockTOP% 30 30 %Color% %Color% Next Box %PointerLEFT% %PointerTOP% 32 32 0x60000000 0x60FFFFFF If# %UseOverlay% == 1 Then Image Overlay 0 0 640 480 EndIf Text 320 115 Center "LightsOut" WHITE Text 320 340 Center "Moves: %bMoves%" WHITE Text 320 360 Center "Block: %Index%" WHITE Text 320 380 Center "Press Y to view Help" WHITE EndDraw :Input IQWaitMsg ANY If %MSG_ID% == "UI_UP" Goto PointerUP // GAMEPAD UP BUTTON If %MSG_ID% == "UI_DN" Goto PointerDN // GAMEPAD DOWN BUTTON If %MSG_ID% == "UI_RT" Goto PointerRT // GAMEPAD RIGHT BUTTON If %MSG_ID% == "UI_LF" Goto PointerLF // GAMEPAD LEFT BUTTON If %MSG_ID% == "UI_SELECT" Goto Click // GAMEPAD A BUTTON If %MSG_ID% == "MUSIC_NEXT" Goto SaveGame // GAMEPAD X BUTTON If %MSG_ID% == "UI_BACK" Goto BeginGame // GAMEPAD B BUTTON If %MSG_ID% == "SYS_MENU" Goto Help // GAMEPAD Y BUTTON If %MSG_ID% == "UI_VIRTKB" Goto Solution // GAMEPAD Y BUTTON + R-TRIGGER Goto RefreshGame :PointerUP If# %PointerTOP% == 160 Then Set PointerTOP 288 Add Index 20 Else Sub PointerTOP 32 Sub Index 5 EndIf If# %UseAudio1% == 1 Then PlaySound Move EndIf Goto RefreshGame :PointerDN If# %PointerTOP% == 288 Then Set PointerTOP 160 Sub Index 20 Else Add PointerTOP 32 Add Index 5 EndIf If# %UseAudio1% == 1 Then PlaySound Move EndIf Goto RefreshGame :PointerLF If# %PointerLEFT% == 240 Then Set PointerLEFT 368 Add Index 4 Else Sub PointerLEFT 32 Sub Index 1 EndIf If# %UseAudio1% == 1 Then PlaySound Move EndIf Goto RefreshGame :PointerRT If# %PointerLEFT% == 368 Then Set PointerLEFT 240 Sub Index 4 Else Add PointerLEFT 32 Add Index 1 EndIf If# %UseAudio1% == 1 Then PlaySound Move EndIf Goto RefreshGame :WinCheck Set W1 0 For W2 = 0 To 24 XMLGetValue cGame pStatus !.Block^%W2%~Status If# %pStatus% == 0 Then Add W1 1 EndIf Next If# %W1% == 25 Then MsgBox "Congradulations$eol$You beat level %Lvl% in %bMoves% moves" If# %Lvl% == 50 Then Set Lvl 1 Else Add Lvl 1 EndIf Goto Start EndIf Return :Credits Set Top1 350 Set Top2 370 Set Top3 390 Set Stop 0 :RefreshCredits If# %Top1% < %Stop% Goto EndCredits BeginDraw UseCurrent Box 0 0 640 480 LIGHTGRAY LIGHTGRAY Text 320 %Top1% Center "LightsOut" DARKGRAY Text 320 %Top2% Center "Version 1.4" DARKGRAY Text 320 %Top3% Center "By flattspott" DARKGRAY Box 0 0 640 144 DARKGRAY GRAY Box 0 336 640 144 DARKGRAY GRAY EndDraw For X = 0 to 3 Sub Top%X% 1 Next Goto RefreshCredits :EndCredits Goto RefreshSelect :Solution If# %bMoves% > 100 Then XMLGetValue Game Solution !.Levels.Level%Lvl%^Solution MsgBox "Level %Lvl% Solution:$eol$Click the box numbers below in any order$eol$You may need to restart the level first$eol$%Solution%" EndIf Goto RefreshGame :Click If# %UseAudio1% == 1 Then PlaySound Click EndIf Add bMoves 1 Goto GetBlockSet :GetBlockSet If# %Index% == 0 Goto CornerSet1 If# %Index% == 4 Goto CornerSet2 If# %Index% == 20 Goto CornerSet3 If# %Index% == 24 Goto CornerSet4 If# %Index% == 5 Goto LeftSideSet If# %Index% == 10 Goto LeftSideSet If# %Index% == 15 Goto LeftSideSet If# %Index% == 9 Goto RightSideSet If# %Index% == 14 Goto RightSideSet If# %Index% == 19 Goto RightSideSet For p = 0 To 4 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 5 Sub P2 1 Add P3 1 Add P4 5 Goto ChangeFullSet :CornerSet1 For p = 0 To 2 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Add P1 1 Add P2 5 Goto ChangeHalfSet :CornerSet2 For p = 0 To 2 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 1 Add P2 5 Goto ChangeHalfSet :CornerSet3 For p = 0 To 2 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 5 Add P2 1 Goto ChangeHalfSet :CornerSet4 For p = 0 To 2 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 5 Sub P2 1 Goto ChangeHalfSet :LeftSideSet For p = 0 To 3 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 5 Add P2 1 Add P3 5 Goto ChangeHalfSet2 :RightSideSet For p = 0 To 3 Set P%p% %Index% Next // P0 IS ALWAYS THE CENTER BLOCK (THE ONE THAT IS CLICKED - INDEX) Sub P1 5 Sub P2 1 Add P3 5 Goto ChangeHalfSet2 :ChangeHalfSet For A = 0 to 2 XMLGetValue cGame pStatus !.Block.%P{A}%~Status If# %pStatus% == 1 Then XMLSetValue cGame !.Block.%P{A}%~Status 0 // IF THE BLOCK IS 1 CHANGE IT TO 0 Else XMLSetValue cGame !.Block.%P{A}%~Status 1 // IF THE BLOCK IS 0 CHANGE IT TO 1 EndIf Next Goto RefreshGame :ChangeHalfSet2 For A = 0 to 3 XMLGetValue cGame pStatus !.Block.%P{A}%~Status If# %pStatus% == 1 Then XMLSetValue cGame !.Block.%P{A}%~Status 0 // IF THE BLOCK IS 1 CHANGE IT TO 0 Else XMLSetValue cGame !.Block.%P{A}%~Status 1 // IF THE BLOCK IS 0 CHANGE IT TO 1 EndIf Next Goto RefreshGame :ChangeFullSet For A = 0 to 4 XMLGetValue cGame pStatus !.Block.%P{A}%~Status If# %pStatus% == 1 Then XMLSetValue cGame !.Block.%P{A}%~Status 0 // IF THE BLOCK IS 1 CHANGE IT TO 0 Else XMLSetValue cGame !.Block.%P{A}%~Status 1 // IF THE BLOCK IS 0 CHANGE IT TO 1 EndIf Next Goto RefreshGame :Help MsgBox "LightsOut - Help$eol$D-Pad to move selector$eol$A to switch lights$eol$B to return to level selection screen$eol$X to save current level as is" Goto RefreshGame :SaveGame XMLSave cGame %Path%Current.xml MsgBox "Current level saved" Goto RefreshGame :End XMLClose cGame XMLClose Game If# %UseAudio1% == 1 Then CloseSound Click EndIf If# %UseAudio2% == 1 Then CloseSound Move EndIf If# %UseAudio3% == 1 Then CloseSound Select EndIf If# %UseAudio4% == 1 Then CloseSound Play EndIf If# %UseOverlay% == 1 Then CloseImage Overlay EndIf |
| CODE |
| QUOTE (geniusalz @ Apr 25 2004, 09:28 PM) |
| Sweet! Another game done for the collection. BJ: If you can get down to finishing the actiondrawlist stuff, I can get down to arkanoid |
| QUOTE (geniusalz @ Apr 26 2004, 06:34 AM) |
| I like the credits screen The game works great. A minor (bug) is that it saves Lightsout.xasCurrent.xml instead of Current.xml, but that's not really a big deal, and doesn't affect gameplay. Gotta say, nice work on this thing. |
| CODE |
| Set PathTemp %0% SetFunc Path Replace "LightsOut.xas" "" %PathTemp% |
| QUOTE |
| The credits bit was very nice! |
| QUOTE |
| Yeah, I replaced the paths, because I wasn't using the $actualpath$, but C:\Scripts. That's what threw it off, I guess. |
| QUOTE |
| And I think pressing B ingame should go to the level select screen instead of quitting. |