Click here to Skip to main content
15,887,683 members
Articles / Mobile Apps

Marbles

Rate me:
Please Sign up or sign in to vote.
2.72/5 (21 votes)
24 Apr 2004CPOL2 min read 36.6K   257   16   2
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:

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Link Development
Egypt Egypt
IF YOU WANT TO IMPROVE YOUR SOFTWARE, DON'T TEST MORE; DEVELOP BETTER.

http://bishoylabib.blogspot.com

Comments and Discussions

 
GeneralBUG: Hardcoded Path Pin
Steffen Lange27-Sep-08 7:50
Steffen Lange27-Sep-08 7:50 
GeneralHi Pin
yahtra1-Jul-07 21:48
yahtra1-Jul-07 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.