Jump to content


Photo

Concentration


  • Please log in to reply
5 replies to this topic

#1 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 02 May 2004 - 08:30 PM

Default
user posted image

Todo List:
Make it Skinnable
Add Sounds
Bug Fixes
Add Help
Better Scoring System

Save as - Concentration.xas
CODE

// ----------------------------------------------------------------------------------------
// Script: Concentration
// Version: 1.0
// Author: flattspott
// Install: Copy the Concentration.xas file to your Xbox
// It needs to be named Concentration.xas
// Do NOT rename the file.
// All you have to do is point MXM to the Concentration.xas file and the script
// will work by itself. No path changing needed.
// Warning: You need to have 8 retail game saves.
// Usage: A standard CallFile will do.
// CallFile <Path>\Concentration.xas
// -----------------------------------------------------------------------------------------

If $MXMVersion$ #^ "0.9n.6" Goto vError
Goto SetupGame

:vError
BeginDraw
MessageBox "This script is not compatible with MXM $MXMVersion$"
EndDraw
DelayMS 3000
Goto Kill

:SetupGame
SetFunc Path Replace "Concentration.xas" "" %0%

XMLCreate ImageList main
LoadImage Cover ::SkyTile

Set iCount 1
Set iPath E:\UDATA

:Search
BeginSearch %iPath%\*

:StartSearch
SearchType sType
SearchItem sName
If "%sName%" == "" Goto DoneSearch
If %sType% == "dir" Goto Check
If %sType% == "file" Goto SearchContinue

:SearchContinue
SearchNext
Goto StartSearch

:DoneSearch
EndSearch
Goto PrepareBoard

:Check
If %sName% #^ "f001601d" Goto SearchContinue
If %sName% #^ "00000000" Goto SearchContinue
If %sName% #^ "ffadf32f" Goto SearchContinue
If %sName% #^ "0facfac0" Goto SearchContinue
If %sName% #^ "7433336c" Goto SearchContinue
If %sName% #^ "ffffedcb" Goto SearchContinue
If %sName% #^ "ffff1982" Goto SearchContinue
If %sName% #^ "50783639" Goto SearchContinue
If %sName% #^ "01010001" Goto SearchContinue
If %sName% #^ "0face008" Goto SearchContinue
If %sName% #^ "0face007" Goto SearchContinue
If %sName% #^ "ffff0026" Goto SearchContinue
If %sName% #^ "586f7645" Goto SearchContinue
If %sName% #^ "080299ff" Goto SearchContinue
If %sName% #^ "9e115330" Goto SearchContinue
If %sName% #^ "00004321" Goto SearchContinue
If %sName% #^ "ffff051f" Goto SearchContinue
If %sName% #^ "ffff0504" Goto SearchContinue
If %sName% #^ "0000fa7e" Goto SearchContinue
If %sName% #^ "64646464" Goto SearchContinue
If %sName% #^ "4d414d45" Goto SearchContinue
If %sName% #^ "64ffffff" Goto SearchContinue
If %sName% #^ "ffff051e" Goto SearchContinue
If %sName% #^ "0fffdaed" Goto SearchContinue
If %sName% #^ "a64fea57" Goto SearchContinue
If %sName% #^ "ffff7269" Goto SearchContinue
If %sName% #^ "0001e240" Goto SearchContinue
If %sName% #^ "186418cd" Goto SearchContinue
If %sName% #^ "ffffa31c" Goto SearchContinue
If# %iCount% == 9 Goto DoneSearch
SetFunc isImage FileExists %sName%\TitleImage.xbx
If %isImage% == 1 Then
  Set File %sName%\TitleImage.xbx
  LoadImage gPiece%iCount% %File%
  Add iCount 1
EndIf
Goto SearchContinue

:Start
Set sTime $timer$
Set ToGet 1
Set pLeft 220
Set pTop 140
Set Index 1
Set WaitOnTwo 0
Set Matches 8
Set gScore 0

:RefreshGame
BeginDraw
Box 0 0 640 480 LIGHTGRAY LIGHTGRAY

Set gLeft 220
Set gTop 140
Set tCount 1

For I = 1 to 16
  If# %tCount% == 5 Then
     Set tCount 1
     Add gTop 48
     Set gLeft 220
  EndIf
   XMLGetValue ImageList gNum !.Image^%I%~Piece
   XMLGetValue ImageList gStatus !.Image^%I%~Status
   If# %gStatus% == 3 Goto Skip
   If# %gStatus% == 0 Then
      Image Cover %gLeft% %gTop% 46 46
   Else
      Image gPiece%gNum% %gLeft% %gTop% 46 46
   EndIf
   :Skip
   Add gLeft 48
   Add tCount 1
Next

Box %pLeft% %pTop% 48 48 0x60000000 0x60000000
Box 0 0 640 137 DARKGRAY GRAY
Box 0 336 640 144 DARKGRAY GRAY
Text 320 110 Center "Concentration"
Text 320 335 Center "Select Piece %ToGet%"
Text 320 355 Center "Score %gScore%"
EndDraw
If# %ReturnOn% == 1 Then
  Set ReturnOn 0
  Return
EndIf

IQWaitMsg Any
If %MSG_ID% == "UI_RT" Goto MoveRight
If %MSG_ID% == "UI_LF" Goto MoveLeft
If %MSG_ID% == "UI_UP" Goto MoveUp
If %MSG_ID% == "UI_DN" Goto MoveDown
If %MSG_ID% == "UI_SELECT" Goto Click
If %MSG_ID% == "UI_VIRTKB" Goto Credits
If %MSG_ID% == "UI_BACK" Goto End
Goto RefreshGame

: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 "Concentration" DARKGRAY
Text 320 %Top2% Center "Version 1.0" DARKGRAY
Text 320 %Top3% Center "By flattspott" DARKGRAY
Box 0 0 640 137 DARKGRAY GRAY
Box 0 336 640 144 DARKGRAY GRAY
EndDraw
For X = 0 to 3
Sub Top%X% 1
Next
Goto RefreshCredits
:EndCredits
Goto RefreshGame

:MoveRight
If# %pLeft% == 364 Then
  Set pLeft 220
  Sub Index 3
Else
  Add pLeft 48
  Add Index 1
EndIf
Goto RefreshGame

:MoveLeft
If# %pLeft% == 220 Then
  Set pLeft 364
  Add Index 3
Else
  Sub Index 1
  Sub pLeft 48
EndIf
Goto RefreshGame

:MoveUp
If# %pTop% == 140 Then
  Add Index 12
  Set pTop 284
Else
  Sub Index 4
  Sub pTop 48
EndIf
Goto RefreshGame

:MoveDown
If# %pTop% == 284 Then
  Set pTop 140
  Sub Index 12
Else
  Add pTop 48
  Add Index 4
EndIf
Goto RefreshGame

:Click
Set ReturnOn 1
If# %WaitOnTwo% == 0 Then
  Set WaitOnTwo 1
  XMLGetValue ImageList bPiece1 !.Image^%Index%~Piece
  Set Temp1 %Index%
  XMLGetValue ImageList bStatus !.Image^%Index%~Status
   If# %bStatus% == 3 Goto EndClick
   If# %bStatus% == 1 Goto EndClick
  If# %bStatus% == 0 Then
     XMLSetValue ImageList !.Image^%Index%~Status 1
// Else
//    XMLSetValue ImageList !.Image^%Index%~Status 0
  EndIf
  Set ToGet 2
  GoSub RefreshGame
Else
  XMLGetValue ImageList bPiece2 !.Image^%Index%~Piece
  Set Temp2 %Index%
  XMLGetValue ImageList bStatus !.Image^%Index%~Status
  If# %bStatus% == 3 Goto EndClick
  If# %bStatus% == 1 Goto EndClick
  If# %bStatus% == 0 Then
     XMLSetValue ImageList !.Image^%Index%~Status 1
// Else
//    XMLSetValue ImageList !.Image^%Index%~Status 0
  EndIf
  GoSub RefreshGame
  DelayMS 500
  GoSub CheckMatch
  Set WaitOnTwo 0
EndIf
:EndClick
Goto RefreshGame

:CheckMatch
 If# %bPiece1% == %bPiece2% Then
     XMLSetValue ImageList !.Image^%Temp1%~Status 3
     XMLSetValue ImageList !.Image^%Temp2%~Status 3
     Sub Matches 1
     Add gScore 100
  Else
     XMLSetValue ImageList !.Image^%Temp1%~Status 0
     XMLSetValue ImageList !.Image^%Temp2%~Status 0
     Sub gScore 5
  EndIf
  Set ToGet 1
  If# %Matches% == 0 Goto GetScore
Return

:GetScore
Set eTime $timer$
Sub eTime %sTime%
Set tTime %eTime%
Div tTime 1000
Set tScore %gScore%
Set tTotal %tScore%
Add tTotal %tTime%
:RefreshScore
If# %tScore% == %tTotal% Goto EndScore
BeginDraw
Box 0 0 640 480 LIGHTGRAY LIGHTGRAY
Text 320 210 Center "Calculating Score" DARKGRAY
Text 320 230 Center "Time Penalty: %tTime%" DARKGRAY
Text 320 250 Center "Current Score: %tScore%" DARKGRAY
Box 0 0 640 137 DARKGRAY GRAY
Box 0 336 640 144 DARKGRAY GRAY
EndDraw
Add tScore 1
Goto RefreshScore
:EndScore
DelayMS 1500

:PrepareBoard
Set Total 16
Set tTotal %Total%
Add tTotal 1

For I = 1 To %Total%
   Set Taken%I% 0
Next

For X = 1 to %Total%
:Redo
  Set R $rand$
  Mod R %tTotal%
  If# %R% <= 0 Goto Redo
  If# %Taken{R}% == 1 Goto Redo
  Set Rnd%X% %R%
  Set Taken%R% 1
Next

Set F 1
For P = 1 to %Total%
  If# %F% == 9 Then
     Set F 1
  EndIf
  XMLSetValue ImageList !.Image^%Rnd{P}%~Piece %F%
  XMLSetValue ImageList !.Image^%Rnd{P}%~Status 0
  Add F 1
Next
Goto Start

:End
// DEBUG - Remove the comment marks below to save the xml
// XMLSave ImageList %Path%ConcentrationDEBUG.xml
XMLClose ImageList
CloseImage Cover
For I = 1 to 8
  CloseImage gPiece%I%
Next
:Kill

Edited by flattspott, 02 May 2004 - 08:32 PM.


#2 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 02 May 2004 - 10:21 PM

Update, but not posted yet.

The scoring now works like so. Correct matches gets you 100 point, incorrect matches gets you -5 points. Then at the end your completion time is calculated and subtracted from your score makeing it lower. So the point is to finish it as fast as you can with the least incorrect matches.

Edited by flattspott, 02 May 2004 - 10:23 PM.


#3 koldfuzion

koldfuzion

    X-S Freak

  • Members
  • PipPipPipPipPip
  • 1,480 posts

Posted 02 May 2004 - 11:22 PM

awesome work! beerchug.gif

#4 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 03 May 2004 - 10:22 PM

Status update

I made it so that it's like a real game in regards to the scoring. The first time you play, you'll automatically set the highscore. Then after the first you have a chance to to set one of the top 3 highscores. You get to enter your 3 initals if you get one.

Now I gotta add a View Top Scores thingy.

#5 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 03 May 2004 - 10:25 PM

Also in case you might be wondering why I have a bunch of
If %sName% #^ "f001601d" Goto SearchContinue

It's so I can filter out most of the homebrew stuff seeing how a lot of them use the same save dir or have no icon etc.

#6 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 08 May 2004 - 11:10 PM

I'm not thrilled by the "Calculating score" bit... dunno if it's because I'm running DEBUG, but it takes forever.

It should also wait until I clear a message box to start the game (and the penalty timer).

Oh... lastly, can the board be bigger, maybe?

biggrin.gif




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users