Help - Search - Members - Calendar
Full Version: Tetris
Scenyx Entertainment Community > Xbox1 Forums > Dashboard Forums > Official MediaXMenu (MXM) Forum > MXM WIP Beta forum
geniusalz
More hype biggrin.gif

I'm working on a tetris actionscript, for a little game while transferring files cool.gif

How far along are the negotiations for boost mode? Heard UX is getting it.
geniusalz
Is there a modulus operation? Or any other way to get random numbers?
BenJeremy
Hmmmm... no, I don't have it at the moment, but I'll add some bit-wise operations, as well as MOD and a RANDOM function.
geniusalz
EDIT: Got around it, so its on low priority now

I'm having problems with input (yet again)

I don't want the script to halt while it waits for input, but stay in a loop while it waits.
The problem is that MSG_ID becomes numeric when using IQPeekMsgID

Here's a sample test script:

CODE
BeginDraw UseCurrent
Messagebox "Press Any Key Now"
Enddraw

:TOP
SETFUNC MSG_ID1 IQPeekMsgID
IF %MSG_ID1% GOTO BLAH
GOTO TOP

:BLAH
SETFUNC MSG_ID2 IQGetMsgID ANY
BeginDraw UseCurrent
Messagebox "Func IQGetMsgID gives ... %MSG_ID2%"
Enddraw
Delay 4

BeginDraw UseCurrent
Messagebox "Just MSG_ID ... %MSG_ID% ... this is blank"
Enddraw
Delay 4

QUIT


Edit: MXM returns a number for functions IQGetMsgID/IQPeekMsgID, while I want it to return "UI_BLAH"

Solution: Just put in a "IQWaitMsg ANY" before checking %MSG_ID%. It doesn't wait, but assigns a value to %MSG_ID%
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 biggrin.gif
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. wink.gif
geniusalz
Tetris Beta 1 cool.gif
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.xas
CODE
;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.xml
CODE
<pieces>
<piece1>
 <!-- bar -->
 <state1>
  <row1>1111</row1>
  <row2>0000</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0001</row1>
  <row2>0001</row2>
  <row3>0001</row3>
  <row4>0001</row4>
 </state2>
 <state3>
  <row1>1111</row1>
  <row2>0000</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0001</row1>
  <row2>0001</row2>
  <row3>0001</row3>
  <row4>0001</row4>
 </state4>
</piece1>
<piece2>
 <!-- backwards L -->
 <state1>
  <row1>0111</row1>
  <row2>0001</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0001</row1>
  <row2>0001</row2>
  <row3>0011</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0100</row1>
  <row2>0111</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0011</row1>
  <row2>0010</row2>
  <row3>0010</row3>
  <row4>0000</row4>
 </state4>
</piece2>
<piece3>
 <!-- short T -->
 <state1>
  <row1>0010</row1>
  <row2>0111</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0010</row1>
  <row2>0011</row2>
  <row3>0010</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0111</row1>
  <row2>0010</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0001</row1>
  <row2>0011</row2>
  <row3>0001</row3>
  <row4>0000</row4>
 </state4>
</piece3>
<piece4>
 <!-- straight L -->
 <state1>
  <row1>0111</row1>
  <row2>0100</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0011</row1>
  <row2>0001</row2>
  <row3>0001</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0001</row1>
  <row2>0111</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0010</row1>
  <row2>0010</row2>
  <row3>0011</row3>
  <row4>0000</row4>
 </state4>
</piece4>
<piece5>
 <!-- backwards Z -->
 <state1>
  <row1>0010</row1>
  <row2>0011</row2>
  <row3>0001</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0011</row1>
  <row2>0110</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0010</row1>
  <row2>0011</row2>
  <row3>0001</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0011</row1>
  <row2>0110</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state4>
</piece5>
<piece6>
 <!-- straight Z -->
 <state1>
  <row1>0001</row1>
  <row2>0011</row2>
  <row3>0010</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0110</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0001</row1>
  <row2>0011</row2>
  <row3>0010</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0110</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state4>
</piece6>
<piece7>
 <!-- box -->
 <state1>
  <row1>0011</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state1>
 <state2>
  <row1>0011</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state2>
 <state3>
  <row1>0011</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state3>
 <state4>
  <row1>0011</row1>
  <row2>0011</row2>
  <row3>0000</row3>
  <row4>0000</row4>
 </state4>
</piece7>
</pieces>
koldfuzion
QUOTE (geniusalz @ Dec 30 2003, 09:26 AM)
Tetris Beta 1 cool.gif
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.xas
CODE
;Tetris by geniusalz
;Beta, do not put up anywhere
;Change the path accordingly

you have way too much time on your hands. smile.gif

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 cool.gif

EDIT: Have you tried it out? Any thoughts?
BenJeremy
I'm dying to try it out.... wink.gif

If I can just get the wife to stop nagging me about cleaning up the house (and my computer room)
koldfuzion
QUOTE (geniusalz @ Dec 30 2003, 09:21 PM)
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 cool.gif

EDIT: Have you tried it out? Any thoughts?

i agree 100%.. just giving you a little elbow cause you have too much time on your hands.... and I dont seem to have any.

No, like BJ, im dying to try it.. I havent even loaded the latest WIP yet. But I will, thats for sure. It sucks to play catch-up after being gone for only 1 week.
geniusalz
Randomness works cool.gif
New features:
-Pressing 'B' drops the current piece straight down.
-Keeps track of score and lines, and displays them.

Major problem:
-Game flickers badly in skins using a low amount of resources (eg halowresource biggrin.gif). Works perfect in high-resource skins (eg bluespek haxored or however you spell it)
I guess the problem is that the framerate is high for skins that don't use too much resources, so the screen refreshes while the board is being drawn. Therefore sometimes the main layout of the skin flashes briefly, and the game board keeps flickering on/off.

There should be a way to lock screen updates while the screen is being drawn on.
e.g.
CODE
BeginDraw LockRefresh
blah
blah
blah
EndDraw

'BeginDraw LockRefresh' should keep the current frame on the screen, until the EndDraw statement is reached, thus eliminating the flickering.


On another note, I've noticed that skins show up more 'completely' while switching (when it tells you to reboot). Is this an indication of runtime skin switching coming soon?
BenJeremy
On the LockRefresh, I'll look into something like that... as for the skin switching... dunno for sure. The major things I need to update for what I plan on doing have not been implemented yet.


Work progresses on Virtual Keyboard, BTW.... the keyboard works 'seamlessly' in the input system (you can activate it and 'hit keys' that produce ASCII messages in the input system queue), but I still need to give it text editing legs.


An update might be in place tonight.
BenJeremy
Any chance we can see an update?

Looks cool, except I only get straight pieces (don't see $rand$ anywhere in the code) and the pieces are rather dark.

On a side note, I'm going to shortly implement dual Draw stacks, and alternate between them... this should eliminate the flicker issue.

Perhaps you can also add a few more features when time allows wink.gif since we can record high scores and such with names.
geniusalz
Here's the current version:
Use the pieces.xml from the other post
I'll probably add highscores, and fix colors tonight
CODE
;Tetris by geniusalz
;Beta, do not redistribute
;Change the path accordingly

XMLOPEN pieces c:pieces.xml
XMLCREATE counts Count
XMLCREATE board Board

SET score 0
SET lineTotal 0
SET interval 1000

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

SET falling 0

:Begin
SET endTime $timer$
ADD endTime %interval%

:BeginLoop
 IF# %falling% == 1 GOTO TimeUp
 IF# %pieceExists% == 0 GOSUB MakePiece
 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
SETFUNC nextPiece RIGHT 3 $rand$
MOD nextPiece 7
ADD nextPiece 1
SET nextState 1
SET nextLeft 2
SET nextTop 0
GOSUB CheckValidity
IF# %isValid% == 1 GOTO GetNewPiece
GOSUB EndGame

:GetNewPiece
SET curPiece %nextPiece%
SET curState 1
SET curLeft 2
SET curTop 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
IF %MSG_ID% == "UI_Back" GOTO DropIt
BeginDraw
 Messagebox "Paused $eol$Press Y to quit$eol$Anything else to continue"
Enddraw
IQWaitMsg ANY
IF %MSG_ID% == "SYS_MENU" GOTO Quit
GOTO DiscardInput
 :DropIt
 SET falling 1
 GOTO DiscardInput

 :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% GOSUB ResetTimer

  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%
RETURN

:DrawBoard
BeginDraw
SET leftVal %globalLeft%
ADD leftVal 9
SET topVal %globalTop%
ADD topVal 9
BOX %leftVal% %topVal% 101 201 0xFF000000 0x88FFFFFF

SUB topVal 24
BOX %leftVal% %topVal% 101 24 0xFF000000 0x88FFFFFF
TEXT %leftVal% %topVal% LEFT " Tetris 1.0"

ADD leftVal 50
ADD topVal 225
TEXT %leftVal% %topVal% CENTER "Score: %score%"
ADD topVal 24
TEXT %leftVal% %topVal% CENTER "Lines: %lineTotal%"

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
SET changed 0
EndDraw
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
SET falling 0
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
GOSUB CheckLine
RETURN

:CheckLine
SET lineCount 0
FOR y = 1 to 21
 XMLGetValue counts lineTot !.%y%
 
 IF# %lineTot% < 10 GOTO SkipLine
  GOSUB ResetTimer
  ADD lineCount 1
  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

IF# %lineCount% == 1 GOTO OneLine
;100
IF# %lineCount% == 2 GOTO TwoLines
;300
IF# %lineCount% == 3 GOTO ThreeLines
;600
IF# %lineCount% == 4 GOTO FourLines
;1000
GOTO NoLines

:FourLines
ADD lineTotal 1
ADD score 400
:ThreeLines
ADD lineTotal 1
ADD score 300
:TwoLines
ADD lineTotal 1
ADD score 200
:OneLine
ADD lineTotal 1
ADD score 100
SET changed 1

IF# %lineTotal% > 120 GOTO Line5
IF# %lineTotal% > 80 GOTO Line4
IF# %lineTotal% > 50 GOTO Line3
IF# %lineTotal% > 30 GOTO Line2
IF# %lineTotal% > 10 GOTO Line1
GOTO NoLines
:Line1
SET interval 800
GOTO NoLines
:Line2
SET interval 600
GOTO NoLines
:Line3
SET interval 400
GOTO NoLines
:Line4
SET interval 200
GOTO NoLines
:Line5
SET interval 100
:NoLines
RETURN

:ResetTimer
SET endTime $timer$
ADD endTime %interval%
RETURN

:EndGame
BeginDraw
 Messagebox "Game over.  Your score was %score% with %lineTotal% lines."
 IQWaitMsg ANY
Enddraw
:Quit
QUIT
BenJeremy
I fixed XML pathing, so as long as pieces.xml is in the same directory as the script, you don't need to use the full path.

::goes to copy the file over and check the new version out!::
geniusalz
So THAT's what "xml pathing" means laugh.gif
BenJeremy
The color of the pieces is 0xF2182228, right? Any reason why? It's awfully dim on my display.

Any chance for uniquely colored pieces? This thing has the gameplay down pat. Very nice! (Perhaps I should include it in a script pack?)

BenJeremy
OK... modified it a bit.... now it's more colorful (you may want to make it more accurate.) I'm sure you could also set the coloring as an element in the XML for the board, thus maintaining the original piece color (I'd probably have a dimmer color as part of the piece nodes to use for that)

pieces.xml
CODE

<pieces>
<piece1>
<!-- bar -->
<color>0xFFFF0000</color>
<state1>
 <row1>1111</row1>
 <row2>0000</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0001</row1>
 <row2>0001</row2>
 <row3>0001</row3>
 <row4>0001</row4>
</state2>
<state3>
 <row1>1111</row1>
 <row2>0000</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0001</row1>
 <row2>0001</row2>
 <row3>0001</row3>
 <row4>0001</row4>
</state4>
</piece1>
<piece2>
<color>0xFFFFFF00</color>
<!-- backwards L -->
<state1>
 <row1>0111</row1>
 <row2>0001</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0001</row1>
 <row2>0001</row2>
 <row3>0011</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0100</row1>
 <row2>0111</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0011</row1>
 <row2>0010</row2>
 <row3>0010</row3>
 <row4>0000</row4>
</state4>
</piece2>
<piece3>
<!-- short T -->
<color>0xFF00FF00</color>
<state1>
 <row1>0010</row1>
 <row2>0111</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0010</row1>
 <row2>0011</row2>
 <row3>0010</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0111</row1>
 <row2>0010</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0001</row1>
 <row2>0011</row2>
 <row3>0001</row3>
 <row4>0000</row4>
</state4>
</piece3>
<piece4>
<color>0xFF00FFFF</color>
<!-- straight L -->
<state1>
 <row1>0111</row1>
 <row2>0100</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0011</row1>
 <row2>0001</row2>
 <row3>0001</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0001</row1>
 <row2>0111</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0010</row1>
 <row2>0010</row2>
 <row3>0011</row3>
 <row4>0000</row4>
</state4>
</piece4>
<piece5>
<color>0xFF80FFFF</color>
<!-- backwards Z -->
<state1>
 <row1>0010</row1>
 <row2>0011</row2>
 <row3>0001</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0011</row1>
 <row2>0110</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0010</row1>
 <row2>0011</row2>
 <row3>0001</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0011</row1>
 <row2>0110</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state4>
</piece5>
<piece6>
<color>0xFFFF00FF</color>
<!-- straight Z -->
<state1>
 <row1>0001</row1>
 <row2>0011</row2>
 <row3>0010</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0110</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0001</row1>
 <row2>0011</row2>
 <row3>0010</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0110</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state4>
</piece6>
<piece7>
<color>0xFF8080FF</color>
<!-- box -->
<state1>
 <row1>0011</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state1>
<state2>
 <row1>0011</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state2>
<state3>
 <row1>0011</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state3>
<state4>
 <row1>0011</row1>
 <row2>0011</row2>
 <row3>0000</row3>
 <row4>0000</row4>
</state4>
</piece7>
</pieces>


tetris.xas
CODE

;Tetris by geniusalz
;Beta, do not redistribute
;Change the path accordingly

XMLOPEN pieces pieces.xml
XMLCREATE counts Count
XMLCREATE board Board



SET score 0
SET lineTotal 0
SET interval 1000

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

SET falling 0

:Begin
SET endTime $timer$
ADD endTime %interval%

:BeginLoop
IF# %falling% == 1 GOTO TimeUp
IF# %pieceExists% == 0 GOSUB MakePiece
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
SETFUNC nextPiece RIGHT 3 $rand$
MOD nextPiece 7
ADD nextPiece 1
SET nextState 1
SET nextLeft 2
SET nextTop 0
GOSUB CheckValidity
IF# %isValid% == 1 GOTO GetNewPiece
GOSUB EndGame

:GetNewPiece
SET curPiece %nextPiece%
SET curState 1
SET curLeft 2
SET curTop 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
IF %MSG_ID% == "UI_Back" GOTO DropIt
BeginDraw
Messagebox "Paused $eol$Press Y to quit$eol$Anything else to continue"
Enddraw
IQWaitMsg ANY
IF %MSG_ID% == "SYS_MENU" GOTO Quit
GOTO DiscardInput
:DropIt
SET falling 1
GOTO DiscardInput

: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% GOSUB ResetTimer

 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%
RETURN

:DrawBoard
BeginDraw
SET leftVal %globalLeft%
ADD leftVal 9
SET topVal %globalTop%
ADD topVal 9
BOX %leftVal% %topVal% 101 201 0xFF000000 0x88FFFFFF

SUB topVal 24
BOX %leftVal% %topVal% 101 24 0xFF000000 0x88FFFFFF
TEXT %leftVal% %topVal% LEFT " Tetris 1.0"

ADD leftVal 50
ADD topVal 225
TEXT %leftVal% %topVal% CENTER "Score: %score%"
ADD topVal 24
TEXT %leftVal% %topVal% CENTER "Lines: %lineTotal%"

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 0xFF1822FF 0xFF1822FF
 :DontDraw1
NEXT
NEXT
FOR y = 1 to 5
XMLGetValue pieces curRow !.piece%curPiece%.state%curState%.row%y%
XMLGetValue pieces PieceColor !.piece%curPiece%.color
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 %PieceColor% %PieceColor%
'0xFF1822FF 0xFF1822FF %curPiece%
 :DontDraw2
NEXT
NEXT
SET changed 0
EndDraw
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
SET falling 0
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
GOSUB CheckLine
RETURN

:CheckLine
SET lineCount 0
FOR y = 1 to 21
XMLGetValue counts lineTot !.%y%

IF# %lineTot% < 10 GOTO SkipLine
 GOSUB ResetTimer
 ADD lineCount 1
 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

IF# %lineCount% == 1 GOTO OneLine
;100
IF# %lineCount% == 2 GOTO TwoLines
;300
IF# %lineCount% == 3 GOTO ThreeLines
;600
IF# %lineCount% == 4 GOTO FourLines
;1000
GOTO NoLines

:FourLines
ADD lineTotal 1
ADD score 400
:ThreeLines
ADD lineTotal 1
ADD score 300
:TwoLines
ADD lineTotal 1
ADD score 200
:OneLine
ADD lineTotal 1
ADD score 100
SET changed 1

IF# %lineTotal% > 120 GOTO Line5
IF# %lineTotal% > 80 GOTO Line4
IF# %lineTotal% > 50 GOTO Line3
IF# %lineTotal% > 30 GOTO Line2
IF# %lineTotal% > 10 GOTO Line1
GOTO NoLines
:Line1
SET interval 800
GOTO NoLines
:Line2
SET interval 600
GOTO NoLines
:Line3
SET interval 400
GOTO NoLines
:Line4
SET interval 200
GOTO NoLines
:Line5
SET interval 100
:NoLines
RETURN

:ResetTimer
SET endTime $timer$
ADD endTime %interval%
RETURN

:EndGame
BeginDraw
Messagebox "Game over.  Your score was %score% with %lineTotal% lines."
IQWaitMsg ANY
Enddraw
:Quit
QUIT


I'll fix the screenshot stuff, too, so it works again with ActionScripts and post a few pics.
BenJeremy
user posted image

geniusalz
Cool idea for the colors. I'll add them for the board as well tonight (when the guests are done with the xbox).
BenJeremy
I have one other suggestion... pick the "next" piece while the other is in play and display it to the side (with the orientation it will appear), just like the original. Shouldn't be too hard to do.

Amazing how nice the XML "tree" handles the data wink.gif It solves a lot of data management issues.

Again, very nice work!

If I can, I'll consider adding something so ActionScripts will have sprite-like access to images.
BenJeremy
Geez... how cool is this, anyway.... I was testing the Virtual Keyboard with the IR Remote, and I figured... why not try Tetris with the IR... and it worked pretty well!

geniusalz
More tetris goodness biggrin.gif

Blocks got an embossed look now, check it out:
user posted image

But they look much brighter on my TV, with my normal brightness/contrast settings.
geniusalz
New version (almost final)
-Shows next piece
-Blocks look 3d
-Random states (rotation) of pieces on generation
-No path-changing required

Tetris 1.0b

Need to add highscore saving now. Is (read/write) file pathing improved like xml pathing as well?
EDIT: By the way, the no flicker fix works great.
Progress is slow on this because I'm playing more than developing biggrin.gif

I've changed the <color> tag in the pieces xml to only include the RGB values (6 digits) This way I can dim the colors just by adding an alpha value.
I made the borders have a lower alpha value than the fill. To my surprise, the pieces turned out to look 3d. Here is a zoomed in pic of a block.
user posted image
The funny thing is that a box without a fill has a constant colored border (atleast it looks constant; eg. the box around the whole board).
So is this some sort of an easter egg or a bug? Or was it meant to be like this?

Puzzled
BenJeremy
Hmmm... could be the anti-aliasing of DirectX kicking in for the effect.

Oh.... could we make the board a little bigger, and possibly present the high scores on one side? biggrin.gif

(Now thinking about the possiblity of doing Qix in ActionScript...)
koldfuzion
kudos to the two of you.. that looks great! love.gif
I'm sure people that have never used MXM have no idea about the power it contains. To make a game that looks and works that good with just a couple txt files is crazy.

beerchug.gif
BenJeremy
Almost there! Downside: the borders in the playing field seem to have gone away (or are too dark).

Increasing the size might also help.

I will look at including image handling into ActionScripts, too... backgrounds might be nice to have, too... wink.gif
geniusalz
More on the 3d look

I set the fill to be around 50% alpha. I set the border to be around 20% alpha.
I set the box to be 9 x 9 pixels.

I guess that the fill is drawn 9x9 pixels, but the border is drawn 10x10 pixels big. That causes it to overlap on the topleft part, creating the highlight. The 20% alpha border by itself creates the shadowed part.

A little bug, but pretty neat result in the end
BenJeremy
Well, I've added LINE (will be in next update) to the draw set, but image is a bit more complicated. I am also looking at a scheme where you can reference back to Draw List objects and manipulate them withouth having to redefine the draw list (handy for images, when sprites are working)

Hmmm.. given the flexibility of XML, I might tweak that a bit too... adding the ability to directly access any opened XML (%#<xmlhandle>.node% - but of course, embedding index values would be difficult. Perhaps I can fix that, too... maybe I could add the ability to nest variables with [] - %MyArray[index]% where the space between [] is interpreted as a variable name (and can be further nested in a similar manner.

My problem is with using % for the variable insertions into arguments... works fine, except when embedding a variable within a variable name. The brackets would solve that problem.
geniusalz
That would also add the ability to use arrays
SET myItem%index% "aaa"
SET blah %myItem[index]% <-- This statement couldn't be done before now.
BenJeremy
QUOTE (geniusalz @ Jan 3 2004, 12:00 PM)
That would also add the ability to use arrays
SET myItem%index% "aaa"
SET blah %myItem[index]% <-- This statement couldn't be done before now.

Correct. I am in the process of upping the latest changes.... The embedded XML isn't in there yet, but the embedded regular vars is (See the test script in the internal.xml file for a good, tested example)

Theoretically, you can nest embedding, too. Looks like MXM's actionscripting just got a whole lot more powerful.

Some stuff I may save for a follow-on to MXM - implementing it in a true tokenizing BASIC client. If the other dashbuilders would consider the module concept (using DLLs) and help out, I could create a nice unified BASIC module that would allow freely distributable apps for Xboxers!
geniusalz
QUOTE (BenJeremy @ Jan 3 2004, 02:15 PM)
Some stuff I may save for a follow-on to MXM - implementing it in a true tokenizing BASIC client. If the other dashbuilders would consider the module concept (using DLLs) and help out, I could create a nice unified BASIC module that would allow freely distributable apps for Xboxers!

I was going to suggest a tokenizer, and function calls with parameters and return values.
I don't really get why you want to 'save' it for later, seeing how well actionscripting is progressing.

You could even create a module to run actionscripts in other dashes, or even slowly add on to actionscripting to turn it into BASIC (it's similar enough already).
BenJeremy
QUOTE (geniusalz @ Jan 3 2004, 05:12 PM)
QUOTE (BenJeremy @ Jan 3 2004, 02:15 PM)
Some stuff I may save for a follow-on to MXM - implementing it in a true tokenizing BASIC client. If the other dashbuilders would consider the module concept (using DLLs) and help out, I could create a nice unified BASIC module that would allow freely distributable apps for Xboxers!

I was going to suggest a tokenizer, and function calls with parameters and return values.
I don't really get why you want to 'save' it for later, seeing how well actionscripting is progressing.

You could even create a module to run actionscripts in other dashes, or even slowly add on to actionscripting to turn it into BASIC (it's similar enough already).

Well, it's kind of an either-or thing, because of the syntax. In order to convert to a Basic Interpreter, I'd need to convert the ActionScripts.

If I had to do it all over again, I would have probably scrapped actionscript in favor of 100% basic. Even so, there are a ton of things I'd have to tweak on my BASIC interpreter to make it work with new data types and arrays.

Interestingly, the free-form, non-tokenized nature of ActionScripting makes it deceptively powerful. wink.gif
geniusalz
And deceptively easier to code? wink.gif

Well, maybe you could expand the SET statement to allow expressions.

SET y=(%x%+3)/2

As opposed to

SET y=%x%
ADD y 3
DIV y 2

You get my point.

Similarly, allow expressions in brackets as parameters. Shouldn't be too hard to implement once the above is done.

BOX (%x%*3) (%y%+2) 10 10 blah blah etc.
BenJeremy
QUOTE (geniusalz @ Jan 3 2004, 07:54 PM)
And deceptively easier to code? wink.gif

Well, maybe you could expand the SET statement to allow expressions.

SET y=(%x%+3)/2

As opposed to

SET y=%x%
ADD y 3
DIV y 2

You get my point.

Similarly, allow expressions in brackets as parameters. Shouldn't be too hard to implement once the above is done.

BOX (%x%*3) (%y%+2) 10 10 blah blah etc.

Yeah, I might be able to swing expressions.

So what do you think about the [] addition? I'm working on the XML stuff (%#xml.xx.xx% at the moment, along with getting the file manager going.

geniusalz
[] is pretty sweet. As I've said, no more makeshift arrays.
geniusalz
QUOTE (BenJeremy @ Jan 3 2004, 12:48 PM)
Well, I've added LINE (will be in next update) to the draw set, but image is a bit more complicated. I am also looking at a scheme where you can reference back to Draw List objects and manipulate them withouth having to redefine the draw list (handy for images, when sprites are working)

Some sort of ID?

SETFUNC boxID BOX 1 1 100 100
SETPOS %boxID% 2 2 100 100
DESTROY %boxID%

same with image
BenJeremy
QUOTE (geniusalz @ Jan 3 2004, 09:58 PM)
QUOTE (BenJeremy @ Jan 3 2004, 12:48 PM)
Well, I've added LINE (will be in next update) to the draw set, but image is a bit more complicated. I am also looking at a scheme where you can reference back to Draw List objects and manipulate them withouth having to redefine the draw list (handy for images, when sprites are working)

Some sort of ID?

SETFUNC boxID BOX 1 1 100 100
SETPOS %boxID% 2 2 100 100
DESTROY %boxID%

same with image

Hmmm... that's an idea... I have to cogitate on it though. Internally, I create a 'disposable' list without a reference back to it. For references, I need to add a reference count or something to prevent the deletion of drawing objects that are still being used. blink.gif
geniusalz
Well, shouldn't be too hard putting anything marked as 'undisposable' (i.e. created using the SETFUNC command) into a referenced linked list or something, while still keeping the old system for disposable objects.
geniusalz
New version
-High scores
-Settable brightness (and saves too)
-Pause menu
-Menu script included that can be used for any purpose.

Tetris 1.0c

The game gets sorta clunky as its about to end. This is because redrawing the board takes longer the more boxes there are.

Here are the benchmarks using $timer$
-Empty board about 60 ms to draw
-Full board about 120 ms to draw

However, if the FOR loop that draws all the 'stuck' pieces is removed, drawing time goes down to 7 ms only, no matter how full the board is.

This is a big indication of the need for 'permanent' objects, even if they're not referencable (A clearscreen command should clear everything)
BenJeremy
Hmmm... tomorrow I might have another update, and hopefully, you'll see a speed increase. I am now cacheing the values in/out of the xml elements, so it doesn't need to convert so much anymore (until you change the text), ad long as you aren't accessing attributes and only the actual XML elements.

Seems to have sped up a few things, actually. wink.gif
BenJeremy
On second thought.... I uploaded an update tonight. Give it a whirl. It has the cacheing implemented for XML nodes. See if you notice a speedup in the loading time, too (seems to be faster, but it's hard to tell on my crappy about-to-die HD)

(Save the last update, though...)

geniusalz
Can't really see the difference in loading times.

The drawboard in tetris seems about 5 ms faster (using the timer again), but nothing major.
geniusalz
Is the timer reset on reboot? If its not, it could be used to time reboots.
BenJeremy
Well, the message logger now "zeros out" the time base ont he first message out, meaning it no longer counts the actual time it took to go through the bootup animation and stuff.

oswald
the uninitiated would see this thread as BenJeremy tweaking MXM to run Tetris faster smile.gif
koldfuzion
QUOTE (oswald @ Jan 7 2004, 05:01 AM)
the uninitiated would see this thread as BenJeremy tweaking MXM to run Tetris faster smile.gif

dont you know that tetris powers the Universe? therefore, any tweaking to tetris makes everything run faster!

I ran 1.5 miles in 6 minutes today!





Not. biggrin.gif
geniusalz
You did NOT run 1.5 miles in 6 minutes today?
Clearly not enough tweaking

BJ, back to work!
ub312g0d
lols, Secretly Bj's goal with mxm was just to get it to the point where he could play tetris. Watch out though, when he gets to 3d, he'll prolly want a 3d tetris as well, maybe even a tetris sphere! madness wink.gif How is it that nobody has made a tetris homebrew for xbox yet though? Like damn, I want one. Looking good though.
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.