OG Xbox Forums > MXM WIP Beta forum

Tetris

(1/10) > >>

geniusalz:
Pretty much done, except for random pieces.
It's sorta slow checking for complete lines, can you suggest a more efficient way of emulating arrays, other than using xml?

EDIT: well, I fixed up some stuff, and now the subroutine takes only 4 ms on average

unleashx:
QUOTE (geniusalz @ Dec 30 2003, 02:38 AM) How far along are the negotiations for boost mode?  Heard UX is getting it.
Unfortunately, the negotiation died down as a result of a bogus user and some FB's. Team AVA took it the wrong way. I could safely assume this is the situation as TJ didn't bother to respond to my PM to him, so, no boost mode for UnleashX -of course, this, in no way doesn't mean, everything is over.  ;)  

geniusalz:
Tetris Beta 1  
For any WIP user who wants to try it out

Since theres no randomness, all pieces start off as a bar.  You can press UP to change them.  Left/right to move, A to rotate.


tetris.xasCODE ;Tetris by geniusalz
;Beta, do not put up anywhere
;Change the path accordingly
XMLOPEN pieces c:\pieces.xml

OPENWRITE log c:\log.txt
XMLCREATE counts Count
XMLCREATE board Board


XMLCREATE

SET pieceExists 1

SET globalTop 100
SET globalLeft 200

SET curPiece 1
SET curState 1
SET curLeft 0
SET curTop 0

SET nextPiece 1
SET nextState 1
SET nextLeft 0
SET nextTop 0

SET changed 1

:Begin
   SET endTime $timer$
   ADD endTime 1000

   :BeginLoop
 IF# %pieceExists% == 0 GOSUB MakePiece
 IF# %changed% == 1 GOSUB CheckLine
 IF# %changed% == 1 GOSUB DrawBoard

 SETFUNC MSG_ID1 IQPeekMsgID
 IF %MSG_ID1% GOSUB ExecuteInput
 IF# %endTime% < $timer$ GOTO TimeUp

 GOTO BeginLoop
    :TimeUp
    GOSUB MoveDown
    GOTO Begin
 GOTO BeginLoop
 
:MakePiece
   SET curPiece 1
   SET curState 1
   SET curLeft 0
   SET curTop 0
   SET nextPiece 1
   SET nextState 1
   SET nextLeft 0
   SET nextTop 0

   SET pieceExists 1
RETURN

:MoveDown
   SET nextTop %curTop%
   ADD nextTop 1
   SET nextPiece %curPiece%
   GOSUB CheckValidity
   
   IF# %isValid% == 1 GOTO Keep
   GOSUB FixPiece
   
   :Keep
   SET curTop %nextTop%
   SET changed 1
RETURN

:ExecuteInput
   IQWaitMsg ANY

   SET nextTop %curTop%
   SET nextLeft %curLeft%
   SET nextState %curState%
   SET nextPiece %curPiece%
   
   IF %MSG_ID% == "UI_UP" GOTO ChangePiece
   IF %MSG_ID% == "UI_DN" GOTO MoveDn
   IF %MSG_ID% == "UI_LF" GOTO MoveLeft
   IF %MSG_ID% == "UI_RT" GOTO MoveRight
   IF %MSG_ID% == "UI_Select" GOTO SpinLeft
   BeginDraw
 Messagebox %MSG_ID%
 Delay 1
   Enddraw
   GOTO Quit

 :MoveDn
 ADD nextTop 1
 GOTO DontFix
 
 :MoveRight
 ADD nextLeft 1
 GOTO DontFix
 
 :MoveLeft
 SUB nextLeft 1
 GOTO DontFix

 :ChangePiece
 ADD nextPiece 1
 
 IF# %nextPiece% > 7 GOTO FixPiec
    GOTO DontFix
    
    :FixPiec
    SUB nextPiece 7
 GOTO DontFix
 
 :SpinLeft
 ADD nextState 1
 
 IF# %nextState% > 4 GOTO Fix
    GOTO DontFix
    
    :Fix
    SUB nextState 4
 :DontFix
 GOSUB CheckValidity

 IF# %isValid% == 1 GOTO KeepInput
 GOTO DiscardInput
    :KeepInput
    IF# %nextTop% == %curTop% GOTO DontResetTimer
    SET endTime $timer$
    ADD endTime 1000

    :DontResetTimer
    SET curLeft %nextLeft%
    SET curTop %nextTop%
    SET curState %nextState%
    SET curPiece %nextPiece%
    
    SET changed 1
   :DiscardInput
   SET nextTop %curTop%
   SET nextLeft %curLeft%
   SET nextState %curState%
   SET nextPiece %curPiece%

   IQClear
RETURN

:DrawBoard
   
BeginDraw
   SET leftVal %globalLeft%
   ADD leftVal 9
   SET topVal %globalTop%
   ADD topVal 9
   BOX %leftVal% %topVal% 101 201 0x000000 0x88FFFFFF
   
   FOR x = 1 to 11
 FOR y = 1 to 21
    XMLGetValue board toDraw !.%x%.%y%
    IF# %toDraw% == 1 GOTO DrawThis1
    GOTO DontDraw1
    :DrawThis1
   SET xPos %x%
   MULT xPos 10
   SET yPos %y%
   MULT yPos 10
   ADD xPos %globalLeft%
   ADD yPos %globalTop%

   BOX %xPos% %yPos% 9 9 0xF2182228 0xF2182228
    :DontDraw1
 NEXT
   NEXT
   FOR y = 1 to 5
 XMLGetValue pieces curRow !.piece%curPiece%.state%curState%.row%y%
 FOR x = 1 to 5
    SET x2 %x%
    SUB x2 1
    SETFUNC toDraw1 MID %x2% 1 %curRow%
    
    IF# %toDraw1% == 1 GOTO DrawThis2
    GOTO DontDraw2
    :DrawThis2
   SET xPos %x%
   ADD xPos %curLeft%
   MULT xPos 10
   ADD xPos %globalLeft%
   SET yPos %y%
   ADD yPos %curTop%
   MULT yPos 10
   ADD yPos %globalTop%
 
   BOX %xPos% %yPos% 9 9 0xF2182228 0xF2182228
    :DontDraw2
 NEXT
   NEXT
EndDraw

SET changed 0
RETURN
   

:CheckValidity
   SET isValid 1

   FOR y = 1 to 5
 XMLGetValue pieces curRow !.piece%nextPiece%.state%nextState%.row%y%
 
 FOR x = 1 to 5
    SET x2 %x%
    SUB x2 1
    SETFUNC toCheck4 MID %x2% 1 %curRow%
    
    IF# %toCheck4% == 1 GOTO CheckThis4
    GOTO DontCheck4
    :CheckThis4
   SET xPos %x%
   ADD xPos %nextLeft%
   
   SET yPos %y%
   ADD yPos %nextTop%
 
   XMLGetValue board checkVal !.%xPos%.%yPos% 0
   
   IF# %checkVal% == 1 GOTO ThisIsInvalid
   IF# %xPos% < 1 GOTO ThisIsInvalid
   IF# %yPos% < 1 GOTO ThisIsInvalid
   IF# %xPos% > 10 GOTO ThisIsInvalid
   IF# %yPos% > 20 GOTO ThisIsInvalid

   GOTO DontCheck4

   :ThisIsInvalid
   SET isValid 0
    :DontCheck4
 NEXT
   NEXT
RETURN

:FixPiece
   FOR y = 1 to 5
 XMLGetValue pieces curRow !.piece%curPiece%.state%curState%.row%y%
 
 FOR x = 1 to 5
    SET x2 %x%
    SUB x2 1
    SETFUNC toDraw3 MID %x2% 1 %curRow%
    
    IF# %toDraw3% == 1 GOTO DrawThis3
    GOTO DontDraw3
    :DrawThis3
   SET xPos %x%
   ADD xPos %curLeft%
   
   SET yPos %y%
   ADD yPos %curTop%
 
   XMLSetValue board !.%xPos%.%yPos% 1
   XMLGetValue counts TEMP !.%yPos%
   ADD TEMP 1
   XMLSetValue counts !.%yPos% %TEMP%
    :DontDraw3
 NEXT
   NEXT
   
   SET pieceExists 0
   SET changed 1
RETURN

:CheckLine
   FOR y = 1 to 21
 XMLGetValue counts lineTotal !.%y%
 
 IF# %lineTotal% < 10 GOTO skipLine
    SET y2 %y%
    ADD y2 1
    FOR z = %y% to 0 step -1
   SET z2 %z%
   SUB z2 1
 
   FOR x = 1 to 11
      XMLGetValue board TEMP !.%x%.%z2%
      XMLSetValue board !.%x%.%z% %TEMP%
   NEXT
   XMLGetValue counts TEMP !.%z2%
   XMLSetValue counts !.%z% %TEMP%
    NEXT
 :skipLine  
   NEXT

   SET changed 1
RETURN

:Quit
QUIT


pieces.xmlCODE
   
 
 
    1111
    0000
    0000
    0000
 
 
    0001
    0001
    0001
    0001
 
 
    1111
    0000
    0000
    0000
 
 
    0001
    0001
    0001
    0001
 
   
   
 
 
    0111
    0001
    0000
    0000
 
 
    0001
    0001
    0011
    0000
 
 
    0100
    0111
    0000
    0000
 
 
    0011
    0010
    0010
    0000
 
   
   
 
 
    0010
    0111
    0000
    0000
 
 
    0010
    0011
    0010
    0000
 
 
    0111
    0010
    0000
    0000
 
 
    0001
    0011
    0001
    0000
 
   
   
 
 
    0111
    0100
    0000
    0000
 
 
    0011
    0001
    0001
    0000
 
 
    0001
    0111
    0000
    0000
 
 
    0010
    0010
    0011
    0000
 
   
   
 
 
    0010
    0011
    0001
    0000
 
 
    0011
    0110
    0000
    0000
 
 
    0010
    0011
    0001
    0000
 
 
    0011
    0110
    0000
    0000
 
   
   
 
 
    0001
    0011
    0010
    0000
 
 
    0110
    0011
    0000
    0000
 
 
    0001
    0011
    0010
    0000
 
 
    0110
    0011
    0000
    0000
 
   
   
 
 
    0011
    0011
    0000
    0000
 
 
    0011
    0011
    0000
    0000
 
 
    0011
    0011
    0000
    0000
 
 
    0011
    0011
    0000
    0000
 
   

koldfuzion:
QUOTE (geniusalz @ Dec 30 2003, 09:26 AM) Tetris Beta 1  
For any WIP user who wants to try it out

Since theres no randomness, all pieces start off as a bar.  You can press UP to change them.  Left/right to move, A to rotate.


tetris.xasCODE ;Tetris by geniusalz
;Beta, do not put up anywhere
;Change the path accordingly

you have way too much time on your hands.  

geniusalz:
I think its pretty neat that MXM lets u write a game with gameplay identical to a commercial game for xbox.

That, and I like doing stuff no one's done before.  This is the first time a homebrew game has been written for a dashboard

EDIT: Have you tried it out?  Any thoughts?

Navigation

[0] Message Index

[#] Next page

Go to full version