Or perhaps let’s get the blocks falling. For my first attempt at an application of the skills I learned on the website I mentioned in my last post, I decided to go with a classic, Tetris. There are two reasons I chose Tetris. First, I’ve been playing Tetris for years, I feel that I have a firm grasp on the gameplay mechanic. Second, the premise of the game is simple, falling blocks that line up to clear lines. I felt that coding this would be much easier than something more recent. Tetris comes from an era where game hardware was really limited. My coding limitations sort of match that?
Despite what I just said about Tetris being really easy to program, that is a misconception that I quickly dismissed, in abstract terms, it’s easy to understand, but when you break it down into code, there are so many steps to consider in even the simplest step of the game. It’s scary to think about how bad a game like Pac-Man might be, where there is AI involved.
Regardless, I felt that diving headlong into coding the gameplay would be redundant. Seeing as this whole project is a way to push my programming experience, I felt that I should really try to reproduce Tetris in its entirety, not just the gameplay of it.
When taking on a project of this magnitude, there should always be a fair amount of planning before the first line of code is written. I only realize this in hindsight. Though my professors always stress the importance of this, It never really sinks in until you experience it all for yourself, more on that in a later post.
Like the noob that I am, I just jumped right in and created a game project in Visual Studio without much planning, hoping to wing it as I go, I had a rough idea of what I wanted to do as I went along. The first thing I wanted to do, was to display an opening screen onto a window. To allow this to happen, I recreated much of the Sprite class that was covered in those tutorials I mentioned in the second post. For those of you who haven’t read that tutorial, I will run over the key concepts of that topic.
Sprite Class
An object of the Sprite class will have various variables and methods available to it to allow it to be able to display a 2-D image onto the game window. This will be a super general object that really has no function to it. The sprite class will be widely inherited to allow for Sprite objects that are really far more beefed up and are really the core of what I used to build my game. Though, in the future when the games get more complicated, it may not be wise to inherit the Sprite class to create your gameplay objects, it might be more prudent to create Sprite objects inside your more prominent classes.
To see the specifics of this class – take a look at the Source Code I will upload.
At this point in my programming, I did not know how to print Text to the screen, So I simply printed an image with pre-rendered Text on it.
I’m going to split the discussion of the Tetris project down into smaller posts, So that you guys don’t have to deal with giant walls of text.
Hello there! Welcome to Programming Shenanigans! This is a blog documenting the trials and tribulations of two novice programmers as we try to navigate the weird and wondrous world of game coding.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment