Sign in to follow this  
  • entries
    11
  • comments
    16
  • views
    5412

The Basics

Sign in to follow this  

117 views

So, after reading an excellent article on this website about game programming, I decided to follow the advice in the article by creating a Tetris clone, a Breakout Clone, a PacMan clone, and a Platformer.

My Tetris clone is almost complete. I was looking for a place to "publish" it, and found the GD Showcase. So I signed up as a member.

Below is the account of my Tetris development up to this point.

Sunday August 7, 2005 - I laid out the base classes tonight for my Tetris clone. Not much coding done yet.

Monday August 8, 2005 - Started writing the code for the classes. I kept confusing myself trying to think of all the things that had to be done in the game. I have to learn to focus. I created the pictures of the blocks tonight using MS Paint. They aren't pretty, but they work.

Tuesday August 9, 2005 - I don't know how to use GDI+ in .NET, so tonight I'm working on displaying a picture. I did some ad-hoc code to paint the "next" block in the preview area. It works, but when the window looses focus, the block disappears. I put together the layout of the main form and all of the components. I got a square to paint as the next block and in the main game area. I can move the block left and right.

Wednesday August 10, 2005 - I built the mechanism for the blocks to fall. I built the pile and started storing the blocks. There is no collision detection, so they overlap. The graphics blink, show ghost blocks, and have issues. I implement double buffering using a bitmap object as the buffer. This doesn't work. At higher levels, it's even worse + the drawing mechanism takes too long. I redo the algorithm to draw the current block instead of redrawing with a black square when it moves. This still doesn't work. I redo the algorithm to draw the main game board. Still having issues.

Thursday August 11, 2005 - I work on the game for about 1 hour trying to work out the graphics. I'm very close; I can feel it. It still doesn't work though.

Sunday August 14, 2005 - I finally get the graphics figured out. It works great now, and can keep up at the higher levels. After a long weekend back home, I am too tired to put any serious work into the game. After 20 minutes, I'm done.

Monday August 15, 2005 - Tonight I draw the pile, and that works. Move current block to pile, that works. Collision detection for falling blocks. That works, awesome, my pile is growing. I try collision detection for side-to-side movement. It's not work correctly. Eventually I get it figured out, and now I have a working game loop that looks like a Tetris game. Tomorrow I hope to do the block rotation and the ability to clear the lines. Once line clearing is done, the game loop is practically finished (scoring, lines, levels are all line clearing related). Last thing is sounds, high scores, pausing the game, and help files.

Tuesday August 16, 2005 - Sitting at work thinking about installing VS.NET 2003 tonight at home. I would really like to use some of the features in 2003 and .NET 1.1. But I also want to finish the basic game tonight. I think by Friday I should have a polished version.

6:00pm - So I start into the game. I change the base tetrimino class and creation the methods for rotating a block. I then implement the rotation methods in each of the block types. Cool, the blocks rotate. I change the down key so that instead of automatically putting the block on the bottom, it just moves it down. Now I'm getting a Null Reference error message, but there are no details with it. I put Try-Catch blocks around suspect code, but produce nothing.

I decide to upgrade to VS 2003, thinking that it has more debugging information. I start the install around 8:30. At 10:30 I'm ready to fire it up. Same error message comes up. I try to look at the dynamic help for something, but am reminded that I skipped the MSDN installation to save time. I'll have to do that tomorrow.

I wrap the draw next, draw current and draw pile methods in Try-Catch blocks. Aha, I catch an exception on the draw current. The block is a square. I try several more times, and the block is always a square. I open the square class, and there it is, I forgot to ReDim the array. I fix that one error, and finally it works now. During this time, I have realized a small flaw in my collision detection for falling blocks (side-to-side works great). My collision detection algorithm only checks the bottom layer, so an "overhanging" block isn't getting checked. I will have to change that tomorrow. It's now 1:00am and I have to wake up for work tomorrow. So I didn't finish the basic game tonight, but I did get VS 2003 installed. There is no reason that the line clearing, scoring, level advancement and collision detection fix can't be completed tomorrow.

Wednesday August 17, 2005 - Work is out early so I start working on the game around 4:00pm. I fix a bug where the game won't end, and clean up some other coding issues. Debbie had to use the computer so I started working again around 10:30. Time to clear lines. I build the methods, implement them, and everything works well. I then start keeping track of the score, lines, and level. I play the game for the first time. I get to level 13. A couple of issues came up: a rotating issue; a side-to-side collision detection issue; when the first block is created, there is no next block (they are the same, and rotate together). One other change I think the original Tetris game had was after a block was placed on the pile, there was a pause before the next one came out. I think the pause will help from automatically bringing the next block down.

Thursday August 18, 2005 - Today I want to fix those couple of issues that I found last night. I also want to implement the high score and highest lines. These will be stored in the registry and accessible through another Windows form. The game should be functionally stable tonight and very playable. The last thing to implement is music and sounds.

Eventually I also want to implement some way of showing the lines disappearing. Some ideas are: turn them white with particle effect streaming off, then remove them; break the blocks into 4x4 pieces and display those pieces across the screen, like they were crushed. Another idea is to change the background color when you advance a level. I would have a set of 30 colors (I can't see anyone getting past level 30)

Sunday August 21, 2005 - Ok, so my schedule is completely off now. Oh well. Tonight I basically worked on graphics with Debbie. We create some nice looking blocks. Then I decide to create some spheres. They turn out great. Now I have a title for my game as well, "Falling Spheres". That took about 3 hours to get the colors, contrast, etc right. GIMP made it easy, but there was still a lot of tweaking.

Monday, August 22, 2005 - Tonight I fixed the rotation from going out-of-bounds. I also implemented the pause after the collision. Tomorrow, I will work on the rotating overlapping the pile.

Tuesday, August 23, 2005 - I redo the rotation algorithm 3 times before I finally get it right. The game is completely functional now. I still have to implement the high score stuff, create a nice icon graphic, implement the music, and sounds.

Wednesday, August 24, 2005 - I started off tonight trying to separate the main timer loop from the UI. I wanted to be able to show the pile dropping down when lines are cleared. I completely failed. After 2 hours, I used the very nice feature in Visual Studio and undid 500+ edits in 2 files. I then implement the high score screens and registry entries. I play and set the first high score. Now Debbie will have fun playing and beating me. Tomorrow I will get the music and sounds implemented. I'm pretty excited to put the polished game on gamedev.net. Oh yeah, I signed up as a gdnet+ member today. Future journal entries for this game and the games to follow will be posted there.
Sign in to follow this  


5 Comments


Recommended Comments

Sounds like you got a good start on your lil project!

How long have you been coding in C?

Honorary rate+ to you! Welcome!

Share this comment


Link to comment
Greetings! Good luck with your endeavors.

If I might make a suggestion, after reading the part about you blasting 500 edits, I'd suggest getting some versioning software. It's handy, it can run locally, and it's saved my butt on at least 20 different occasions.

I suggest setting up Subversion (SVN). If you're using windows, once you get SVN set up, I suggest nabbing Tortoise SVN, which is an awesome shell extension for SVN. Then, set up a repository and get all your code into it. Every time you make a decent modification, commit it to SVN, and then if you ever need to, you can roll back to any point in time (which is also useful if you checked in a big bug and later needed to pull that code back out).

Again, SVN, or version control in general, has saved my code many times.

Welcome to the Journal club!

Share this comment


Link to comment
Welcome to Journal Land indeed, and I finnally beat everyone else to it! Rate++ all the way, man. Maybe if you're chill enough, you'll get to roll with my crew. Ha ha haaa... just kidding... but no, really.

If you want your journal to be popular, here are the three keys...

Post lots of pictars. Nobody wants to read your stuff w1th0ut teh p1kt4rZ!

Post alot about whatever project you're involved with. Try to give people insight as to the details of what you are doing while using as little code as possible. Remember, this is a journal, not a tutorial.

It's alright to get personal, and even be liberal about talking about the many details of your life. I know I do. But remember, nobody wants to sit back and load 20 pictures of you and your sister's boyfriend with dreadlocks pretending to eat a cat and trying to pass the dude off as yourself (little nudge, you know who you are... kidding, you're my main man) in dire hopes that you'll write a few sentances about your game project. Especially if you're new to the crew, cause (to be blunt) no one realy cares enough about you yet ;D.

Anyhow, a sincere welcome, and have a great time!

-IV

Share this comment


Link to comment
Thanks for all the feedback. I really wasn't expecting people to read this. My first post was straight from an MS Word document that I had been keeping.

As for source control, I didn't really see a need for it when I started this game. I usually use Source Safe (although, I hate it so much). I think for future game projects I will definitely have to use source control.

I've been coding for about 15 years now, started with Pascal in 1991. C++ since 1997.

I posted some screenshots, so check them out.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now