<script> Set Size 36 Set Padding 2.5 Set PointerColor 0x60000000 Set MacroSpeed 250 Set CurrentLevel 0 Set OnColor 0xFF0000CB Set OffColor 0xFFFFFFFF Set InfoColor Yellow Set BackColor Black Set IsMacro 0 Set AlignX 135 Set AlignY 150 Set RandomPalette 0 // 0 = Off - Set this to 1 to override the default colors with random ones (might make it look like crap though)
// ########### Experimental Random On/Off Colors ############# If# %RandomPalette% != 0 Then For P = 0 To 1 For X = 0 To 3 SetFunc C%X% CvtToBase 16 0 %($rand%255)% Next Set CP%P% %C0%%C1%%C2%%C3% Next Set OnColor 0x%CP0% Set OffColor 0x%CP1% EndIf
:InputHandler IQWaitMsg Any Switch %MSG_ID% Case KEY_LF Gosub PreviousLevel If# %Audible% != 0 Then Playsound Sound2 EndIf EndCase Case KEY_RT Gosub NextLevel EndCase Case UI_UP Gosub PointerU EndCase Case UI_DN Gosub PointerD EndCase Case UI_LF Gosub PointerL EndCase Case UI_RT Gosub PointerR EndCase Case UI_SELECT Gosub PointerC EndCase Case MUSIC_NEXT Gosub MacroSolve EndCase Case SYS_MENU XMLOpen Game %0% XMLGetValue Game AuthorData !^Author XMLGetValue Game VersionData !^Version XMLGetValue Game TitleData !^Title XMLClose Game CallScript Documentation EndCase Case UI_VIRTKB CallScript _GetColor "Off Color" %OffColor% "On Color" %OnColor% Set OnColor %_Color2% Set OffColor %_Color1% EndCase Case UI_BACK If# %Audible% != 0 Then For ToClose = 1 To 4 CloseSound Sound%ToClose% Next EndIf Quit EndCase EndSwitch Return
:PreviousLevel If# %CurrentLevel% != 0 Then Sub CurrentLevel 1 Gosub LoadLevel If# %Audible% != 0 Then PlaySound Sound3 EndIf EndIf Return
:PointerU If# %Row% != 0 Then Sub Row 1 Sub LightIndex %GridSize% If# %Audible% != 0 Then PlaySound Sound3 EndIf EndIf Return
:PointerC Switch %LightIndex% Case 0 For p = 0 To 2 Set P%p% %LightIndex% Next Add P1 1 Add P2 %GridSize% Set ChangeCount 2 EndCase Case 1 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 1 Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 2 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 1 Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 3 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 1 Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 4 For p = 0 To 2 Set P%p% %LightIndex% Next Sub P1 1 Add P2 %GridSize% Set ChangeCount 2 EndCase Case 5 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 9 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 10 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 14 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 15 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Add P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 19 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 %GridSize% Set ChangeCount 3 EndCase Case 20 For p = 0 To 2 Set P%p% %LightIndex% Next Sub P1 %GridSize% Add P2 1 Set ChangeCount 2 EndCase Case 21 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 1 Set ChangeCount 3 EndCase Case 22 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 1 Set ChangeCount 3 EndCase Case 23 For p = 0 To 3 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 1 Set ChangeCount 3 EndCase Case 24 For p = 0 To 2 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Set ChangeCount 2 EndCase Default For p = 0 To 4 Set P%p% %LightIndex% Next Sub P1 %GridSize% Sub P2 1 Add P3 1 Add P4 %GridSize% Set ChangeCount 4 EndCase EndSwitch For A = 0 to %ChangeCount% Set ThisLight %P{A}% Set TempLight %Light{ThisLight}% If# %TempLight% == 1 Then Set Light%P{A}% 0 Else Set Light%P{A}% 1 EndIf Next Add Moves 1 If# %Audible% != 0 Then PlaySound Sound1 EndIf Return
:LoadLevel Set Row 0 Set Column 0 Set LightIndex 0 Set Moves 0 XMLOpen Game %0% XMLGetValue Game InitialData !.Classic^Level:%CurrentLevel%~Initial XMLGetValue Game MacroData !.Classic^Level:%CurrentLevel%~Macro XMLGetValue Game MoveData !.Classic^Level:%CurrentLevel%~Minimum XMLGetValue Game GridSize !.Classic~Gridsize XMLGetValue Game MaxLevels !.Classic~Number Set MaxRows %(GridSize-1)% Set MaxColumns %(GridSize-1)% For I = 0 To %(GridSize*GridSize)% SetFunc Light%I% Mid %I% 1 %InitialData% Next XMLClose Game Return
:DrawLevel BeginDraw Box 0 0 640 480 %OnColor% %OnColor% Box 100 100 440 280 %BackColor% %BackColor% Set CurrentLight 0 For Y = 0 To %MaxRows% For X = 0 To %MaxColumns% If# %Light{CurrentLight}% == 1 Then Box %(X*Size+AlignX+Padding)% %(Y*Size+AlignY+Padding)% %(Size-Padding)% %(Size-Padding)% %OnColor% %OnColor% Else Box %(X*Size+AlignX+Padding)% %(Y*Size+AlignY+Padding)% %(Size-Padding)% %(Size-Padding)% %OffColor% %OffColor% EndIf Add CurrentLight 1 Next Next Set PointerX %(Column*Size+AlignX)% Set PointerY %(Row*Size+AlignY)% Box %(PointerX+Padding)% %(PointerY+Padding)% %(Size-Padding)% %(Size-Padding)% %PointerColor% %PointerColor% If# %IsMacro% == 1 Then Text 360 230 Left "Macro Enabled" %OffColor% Else Text 345 200 Left "Current Level: %CurrentLevel%$eol$Minimum Moves: %MoveData%$eol$Total Moves: %Moves%" %OffColor% EndIf EndDraw Return
:WinCheck If# %IsMacro% == "1" Goto AbortWinCheck Set Counter 0 For ToCheck = 0 To %(GridSize*GridSize-1)% If# %Light{ToCheck}% == 0 Then Add Counter 1 EndIf Next If# %Counter% == %(GridSize*GridSize)% Then BeginDraw Box 0 0 640 480 %OnColor% %OnColor% Box 100 100 440 280 %BackColor% %BackColor% Text 320 180 Center "Congradulations$eol$You've completed level %CurrentLevel%$eol$$eol$Press any key to advance to level %(CurrentLevel+1)%" %InfoColor% EndDraw IQClear IQWaitMsg Any If# %CurrentLevel% == %MaxLevels% Then Set CurrentLevel 1 Else Add CurrentLevel 1 EndIf Gosub LoadLevel Goto GameLoop EndIf :AbortWinCheck Return </Script> <SubScripts> <script Name="Documentation"> Set Info "Credits:$EOL$$EOL$%TitleData%$EOL$Version - %VersionData%$eol$Author - %AuthorData%$EOL$$EOL$Description:$EOL$$EOL$This electronic puzzle by Tiger Toys consists$EOL$of a 5 x 5 grid of buttons which also have$EOL$lights in them. By pressing a button, its light$EOL$and those of the (non-diagonally) adjacent$EOL$buttons will change (switch on if it was off,$EOL$and vice versa). Given a pattern of lights,$EOL$you have to switch them all off by pressing$EOL$the correct buttons. Not only that, but you$EOL$have to do it in as few moves as possible.$EOL$$EOL$Controls:$EOL$$EOL$[D-Pad] moves the pointer$EOL$[A] toggles the light order$EOL$[X] plays a macro solution$EOL$[Y] to view documentation$EOL$[B] to quit or go back$EOL$[R and L Triggers + D-Pad] changes levels" Set Top 380 Set Counter 0
:Loop SetFunc Input IQPeekMsgID If %Input% != "" Gosub InputHandler Gosub Draw If# %Audible% != 0 Then Playsound Sound4 EndIf Sub Top 1 Add Counter 1 If# %Counter% >= 900 Then Quit EndIf Goto Loop
:InputHandler IQWaitMsg Any If %MSG_ID% == "UI_SELECT" Then IQClear IQWaitMsg Any EndIf If %MSG_ID% == "UI_BACK" Then Quit EndIf Return
:Draw BeginDraw
For Effect = 0 To 10 Set TempSize %($rand%20)% Box %(Effect*($rand%100))% %(Effect*($rand%100))% %TempSize% %TempSize% %OnColor% %OnColor% Box %(Effect*($rand%100))% %(Effect*($rand%100))% %TempSize% %TempSize% %OffColor% %OffColor% Next
Group: Head Moderator
Posts: 9688
Joined: 19-July 02
Member No.: 1853
Xbox Version: v1.1
360 version: v1 (xenon)
I'll try it as soon as I get back (Sunday, maybe). Just wrapping up coding on the network startup/shutdown event handling code, so the FTP server can survive a change in network settings.
Just have to add the command in ActionScripting to refresh the network settings from the XML (which basically should shut down any current FTP connections, de-init the network and then reconfigure and initialize with the new settings)
Group: Members
Posts: 53
Joined: 10-August 04
Member No.: 137432
Wow, very nice... and very compact for such a kickin little game. It probably would have taken me 3 or 4 times as many lines of code... nice work... Well, I am off to try some of your other scripts and code snippets... Keep'em comin