Blog Stats
  • Posts - 178
  • Articles - 0
  • Comments - 61
  • Trackbacks - 234

 

Tetris.NET

So, I am ashamed at my lack of posts lately but I really have been extremely busy. I am still working on the Image Processing Library and the code generation tool that I posted several months ago. I am also working on a reproduction of Tetris in C#. I really like the look of the blocks and shapes. There are some simple screenshots of some of the different blocks and shapes here. The biggest pain so far is the virtual playing field which must be constructed over and over and tracking the shapes while in that field. GDI+ is great for images and will be adequate to fit my needs for this.

The game has a class that builds the shapes via an array of numbers. For instance, no shape will be bigger than 4x4. Most are 2x3 or 3x2. With that in mind, I constructed an algorithm that parses a series of integers to create the different blocks that make up the shapes. For example, here is the block array that all shapes fall into:

x x x x   1 - 4
x x x x   5 - 8
x x x x   9 - 12
x x x x   13 - 16

On an axis, block #1 has x,y coordinates of x,y, block #2 has x,y coordinates of x + blockwidth, y. For the small 2x2 block, I pass in the numbers 2, 3, 6, and 7. When these go through the algorithm, they come out as this:

#2 = x + blockwidth, y
#3 = x + (blockwidth*2), y
#6 = x + blockwidth, y + blockwidth
#7 = x + (blockwidth*2), y + (blockwidth*2)

I have 22 different shapes now but most are variants of each other such as Left-L, Right-L, Left-Z, Right-Z, Small(2x2) block, Large(3x3) block, etc. The best part is I could add 10 or 15 shapes in less than an hour. I will write a short synopsis of how I handle the movement and rotation of the shapes next week sometime.


Feedback

# re: Tetris.NET

Gravatar plz can you make a proxie for john smeaton comunity college fanx 5/2/2008 8:58 AM | myte

Post a comment





 

Please add 1 and 2 and type the answer here:

 

 

Copyright © Jason Bentley