Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Marbles

0.00/5 (No votes)
24 Apr 2004 1  
A strategy game that you must think twice before you move because you can't go back. Face 14 Levels of exciting.

Sample Image - Marbles.jpg

Introduction

Marbles is a strategy game for smart devices to the smart users. The idea is taken from an old game called Marbles Deluxe.

How to play

The goal of the game is to move the ball to get all jewels then go to the target block. While doing this, you can switch pairs of blocks to make space for the ball.

Click on a block to select it then click it again to move the ball to this block, or click another block to switch the two blocks.

Some blocks cannot be switched like the target and the jewels. Some blocks will kill you like the skull block. Some blocks will move you like the arrows blocks.

Take care blocks vanish after you move on them. You will not be able to go backward. Except white blocks, you can hit them two times before they vanish.

Implementation

The code is readable and contains comments that don't need explanation except for some bug fixes. The Game contains two classes:

Marbles: which is the main form of the application and has all the interactivity of the game and its rules.

Board: which has the information of the game and how to save it and load it.

Graphics

Images for the game were created using 3D studio MAX 5. I'm a graphics designer too.

To create more levels

You can create your own editor for the game levels on a smart device or a normal windows application. To create the editor you will use the Board class and fill it with numbers of the images that are provided in the source project. Then save the file by calling the function void Board.Save(string file).

This is the code for saving the level after editing:

void Save(string file)
{
 StreamWriter r=new StreamWriter(file);
 r.WriteLine(Width.ToString());
 r.WriteLine(Height.ToString());

 for(int y=0;y<Height;y++)
 {
  for(int x=0;x<Width;x++)
  {
   r.WriteLine(Data[x,y].ToString());
  }
 }
 r.Close();
}

If you like it, please vote for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here