Game Development Tutorial

Everything a total beginner needs for game programing!

19. How to get a promotion

Almost all games have levels. As the player advances, the game becomes more and more difficult. We'll do just that. We'll speed up our gameplay from level to level, and add a new color to the blocks every three or four levels... That should spice things up nicely... Uh! Oh! Another idea: let's increase the number of columns from level to level! So, that would mean that the player needs to survive 15 columns in the first level to move on, 16 in the second, and so on... Our game will not have a finall level. If the player is skilled enough, he could play trough an infinite number of levels. But hey, that's almost impossible. Reaching level 10 will be almost like winning in a lottery ;) Hehe...

So, when the player starts a new game we should reset the level count, score, speed, colors.. So we'll fill our 'NewGame' method.

// Reset the level and
// score value, and the
// number of colors in the game:

iLevel = 0;
lblLevel.Text = iLevel.ToString();
iScore = 0;
lblScore.Text = iScore.ToString();
iColor = 3;
iColors = 0;

// Reset the game speed
Game.Interval = 4000;

// We don't have the IOBox yet,
// so, the next line is commented
// out:
// IOBox.Visible = false;

lblDisplay.Visible = false;

NewLevel();

Now, add a new label to the form. Here are the settings:

Label

  • (name): lblLevel
  • BackgroundColor: Web > Transparent
  • Location: 555;81
  • Font: Microsoft Sans Serif; 9,75pt; style=Bold
  • Text:1

And here's the code for going from level to level.
(Put it in the NewLevel() method)

//Increase the level number.
iLevel++;

// Increase the number of 
// columns needed to complete
// the level. You can play
// with this code to make the
// game harder or easier.

iColumns = iWidth - 1 + iLevel;

// Reset the column count.
iColumn = 0;

// Increase the number of colors.
// But only to 10. (because we
// didn't prepare more colours in
// our DrawField method)

if (iColor < 10)
{
  // Do it every three levels...
  // The number '3' in the next 
  // line tells the game how
  // many levels to skip before
  // adding a new color:

  if (iColors == 3)
  {
    iColor++;
    iColors = 0;
  }
  else
  {
    iColors++;
  }
}

// Speed up the game.
// We speed it up for 50 
// miliseconds from level
// to level. This, probably,
// will stay unnoticed by
// the player. But you can
// change this to increase
// the difficulty.

if(iLevel > 1 &&
Game.Interval > 1500)
{
Game.Interval =
Game.Interval - 50;
}

// Display level text
lblLevel.Text =
iLevel.ToString();

// Create our new level's
// game field (empty):

CreateField();
// And the first column:
CreateNewColumn();

// Show it on the screen:
Redraw();

// Start the game:
Game.Start();

And the last thing is to change your 'New Game' button's code to this:

NewGame()

In the next chapter, we'll add some nice bonuses, that'll show between levels, and give the player to 'breathe' for a second or two... Ok, moving on!

0 comments:

Post a Comment

Downloads

Downloads
Finished Bubble Splash Game

Followers

Translate

Blog Directories

Programming Blogs - BlogCatalog Blog Directory
blog directory
Software Computers Business Directory - BTS Local
Top Blogs GoLedy.com
TopOfBlogs DigNow.net
Blog Directory blog search directory
Top Computers blogs Add to Technorati Favorites
Computers Blogs Blog Directory
blogsbycategory.com Blog Directory & Search engine
Blog Flux Directory Programming Blog Directory
Join My Community at MyBloglog! BlogRankers.com
Technology Blogs - Blog Rankings Blog Directory
C# Game programming tutorial Blogs lists and reviews
Bloglisting.net - The internets fastest growing blog directory Blog Directory - photarium
blogarama - the blog directory Blog Toplist
Blog directory Computers (Linux) - TOP.ORG
Blog Ratings si.blogs
Blogz game, development, programming, c#, visual studio, tutorial, source code
On our way to 1,000,000 rss feeds - millionrss.com
RSSMountain
TopBlogLists.com - Blog Search