<CharlieDigital/> Programming, Politics, and uhh…pineapples

30Sep/05Off

DHTML Games

Finally figured out how to fix some of the bugs and problems I
had with jsTetris last night as I was laying down to sleep (I hate
that).

Each list element needs to have a property, State, which takes one of two values:

  • 0 when the list element is empty (no pieces in it) or the list element is holding an active block (a block that can still move).
  • 1 when the list element is holding a fixed block (a block that can no longer move).

One of the big problems I had previously was that it was difficult to
calculate when a piece could still move.  The method I was using
was too inefficient and took too many lines of code.  It tried to
examine each of the target blocks to see if it contained an inactive
block.  This should make it easier by performing some simple math
instead.

Each block of each piece must be examined in the direction of the move
and simply do a sum between each block and the list element in the
target block.  If the sum of the State is 0, then we can move the block.  If the sum is anything other than 0, then the block cannot be moved anymore.

Once a block stops moving, before the next buffered piece is moved (may
have to cancel timer), we sum across the bottom most row up 4 rows and
see if the sum in that row divided by the number of columns is exactly
1.  If so, this means that every list element in that row is
holding a fixed block and we can move get rid of that row.  Once
we've checked 4 rows, we can then move all of the remaining straggling
pieces down before reactivating the timer on the buffered piece.

Seems like a plan.

I was also thinking about doing two other games last night. 

One of them would be based off of pipe dreams.  Remember that game
where you have to move around blocks which contained pipes as this
green ooze started flowing?  I think it can be done with .gif
animations if each of the animations takes precisely the same amount of
time.  There are a total of 7 different pieces.  6 of those
pieces would need two sets of animations and one of them, a cross
shaped piece, would need 4 animations.  This brings the total
number of pieces up to 16.  The idea would be to cache each of
these images and swap them out as the flow of the ooze moves through
the pipes.  This one should be interesting.

The other game would be based off of a game that I had on my TI-83 back
in my highschool days which is kind of along the lines of Dr. Mario or
Tetris Attack, except without falling pieces.  Basically, you get
a random m*n board, which is completely filled with
pieces (maybe 5-6 different types).  When you have three or more
adjacent pieces, those pieces disappear.  And "loose" pieces fall
into the space left by those pieces and can cause "combos".  The
objective is to clear the entire board with as high a score as possible
(factoring in time and combos).  Like Tetris Attack (I don't
completely remember the mechanics of Dr. Mario), you can manipulate two
adjacent blocks in the grid at a time.

Neither of these seem too difficult and sound like fun.

Oh yeah, I'm also working on a ASP.Net Beta 2 based version of Chinese chess or Xiangqi
The idea is to use Atlas to allow two players to play in real time,
with the moves and chat being relayed using calls to web services from
the client.  So far, I have the board and objects laid out. 
I still have to figure out how I want to implement the game rules and
how complex to make it in terms of supporting multiple games at
once.  I'm also waiting for my Beta 2 hosting account from ServerIntellect, my webhost.

That's it for now.

Posted by Charles Chen

Filed under: Self Note Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.