Help - Search - Members - Calendar
Full Version: Grid Based Snippet
Scenyx Entertainment Community > Xbox1 Forums > Dashboard Forums > Official MediaXMenu (MXM) Forum > MXM WIP Beta forum
flattspott
CODE
MinimumBuild 1231
SetFunc ScriptPath FNPath %0%

// Basically the only values to change
Set Column 0        // The Intial PointerX
Set Row 0        // The Intial PointerY
Set Size 36
Set MaxRows 4
Set MaxColumns 4
Set PointerColor Blue

CreateBlankImage Pointer %Size% %Size%
Gosub CenterGrid

:PointerLoop
SetFunc Input IQPeekMsgID
If %Input% != "" Gosub InputHandler
Gosub DrawPointer
Goto PointerLoop

:InputHandler
IQWaitMsg Any
Switch %MSG_ID%
Case UI_UP
 If# %Row% != 0 Then
  Sub Row 1
 EndIf
EndCase
Case UI_DN
 If# %Row% != %MaxRows% Then
  Add Row 1
 EndIf
EndCase
Case UI_LF
 If# %Column% != 0 Then
  Sub Column 1
 EndIf
EndCase
Case UI_RT
 If# %Column% != %MaxColumns% Then
  Add Column 1
 EndIf
EndCase
Case UI_SELECT
 Gosub Click
EndCase
Case UI_BACK
 Quit
EndCase
EndSwitch
Return

:DrawPointer
Set TempPointer %Row%%Column%
For Y = 0 To %MaxRows%
For X = 0 To %MaxColumns%
 If# %TempPointer% == %Y%%X% Then
  Set PointerX %(X*Size+AlignX)%
  Set PointerY %(Y*Size+AlignY)%
  Break
 EndIf
Next
Next
BeginDrawTarget Pointer UseCurrent
Box %PointerX% %PointerY% %Size% %Size% %PointerColor% %PointerColor%
EndDraw
Return

:CenterGrid
Set ScreenLeft 0
Set ScreenTop 0
Set ScreenWidth 640
Set ScreenHeight 480
Set AlignX %((ScreenWidth-(MaxColumns*Size))/2)%
Set AlignY %((ScreenHeight-(MaxRows*Size))/2)%
Return


I'm trying to come up with a more effeciant way to draw and move the pointer around in my games, Lights Out, Concentration etc... This would be for grid base games.

Maybe someone else could make use of it too.

geniusalz
Cool, but...

:DrawPointer
Set TempPointer %Row%%Column%
For Y = 0 To %MaxRows%
For X = 0 To %MaxColumns%
If# %TempPointer% == %Y%%X% Then
Set PointerX %(X*Size+AlignX)%
Set PointerY %(Y*Size+AlignY)%
Break
EndIf
Next
Next

BeginDrawTarget Pointer UseCurrent
Box %PointerX% %PointerY% %Size% %Size% %PointerColor% %PointerColor%
EndDraw
Return

Why is the loop there?

You can use :
Set PointerX %(Row*Size+AlignX)%
Set PointerY %(Column*Size+AlignY)%
flattspott
Actually I pulled it strait out of the revamped Lights Out games and changed a few things at the last minute
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.