Tag Archives: Programming

Minimum requirements for game programming

26 May

“I’m interested in learning programming but I’m not sure how or where to start.”

This is an interesting statement, often come across by most programmers on forums, blogs, social media and pseudo-forum sites and most of the time the answer is the same. What I want to do is answer the question from a game programing perspective, firstly to disclose I’m not a professional or a graduate as yet however from my various searches and intrusions and questions asked and read on the above mentioned site I have gathered a fairly complete idea of what is requested. So lets begin leveling up.

Armour – Get the right Hardware

Samus and her trusty Powersuit

Chances are since your reading this that you already have the necessary hardware requirements covered. But if you’re looking for facts and figures this is what I would recommend.  These requirements are future proof so as your skills improve and you start shifting towards more graphically and mathematically complex games you don’t find yourself needing to upgrade your machine to use a more powerful development environment.

  • Computer that has a 1.6GHz or faster processor
  • 1 GB (32 Bit) or 2 GB (64 Bit) RAM (Add 512 MB if running in a virtual machine)
  • 3 GB of available hard disk space
  • 5400 RPM hard disk drive
  • DirectX 9 capable video card running at 1024 x 768 or higher-resolution display
  • DVD-ROM Drive
Most netbooks support these specifications and are a cheap low-cost investment. I would also recommend getting a netbook which can be connected to a monitor (most netbooks already offer this, I think?), preferably one which supports a resolution of 1280 x 1024 pixels.

Weapons – Basic Sword to the ultimate Blade

There are a few ways to tackle programming, the easiest and most direct route would be to learn Python. Python is a simple, dependable and compact language where most complex code is already done for you, it has a few popular graphics libraries (Pygame, Pyglet), which have been tried, tested, taken apart and put back together.  I strongly discourage you to start of in Python, I dislike the language you can read about it here, other than the reasons mentioned in that blog post I feel that Python, particularly in game programming gives a false sense of accomplishment which will cause disappointment as you start to expand your horizons and find that other lower level languages add a new level of complexity.

My recommendation is to start by learning “the C language“, it has a much steeper learning curve but allows you much more flexibility and a wider variety of libraries, game engines and scope if you decide to go professional. It also allows you to branch out to most other popular programming languages like Java, Objective – C, D, C#. It also allows for natural progression to learning and using C++, the professional grade language used by your favourite game programmers or development houses.

Level 01 – Learning C

The easiest way to learn C is to learn by example. Start by taking a book read chapter, do the examples and then the questions and repeat. This is going to be tedious, difficult, and tiring but by the end you should have covered:

  • Variable
  • Loops
  • Functions
  • Pointers (Very Important)
  • Reading / Writing to Files
  • Arrays
  • Structures and Unions

Level 2 – Learning C++

Using the same method as before. You should cover the following:

  • Classes
  • Strings
  • Templates
  • Operator Overloading
  • Function Overloading
  • Exception Handling

Level 3 – Data Structures & Algorithms

Once you get comfortable with Level 1 and 2 your ready to progress to level 3, the most important level in game programming. This is absolutely brutal and probably the hardest part of programming but the most essential, efficiency, searching and retrieval of data, decision trees and many others. Learning a few of these topics wont hurt.

  • Linked Lists
  • Searching & Sorting Algorithms
  • Hash Tables
  • Recursion
  • Trees
  • C++ Standard Library
  • Boost’s C++ Library

Level 4 – Graphics Library

At this point you have a couple of options, you can continue going slow and steady or jumping right in. If you want to continue going slow and steady you can try learning SDL, it’s a basic graphics library that allows you to create 2d games and even simple 3D ones, it is a tried, tested library which is being prepped to work with the iPhone.

The other alternative is moving straight to the meat of game programming and start learning DirectX or Open GL.

The third option that you have is to use a game engine, there are plenty of options depending on your requirements 2D, 3D, Isometric. Engines that have a large user base and well written tutorials are the Unity Engine, Unreal Engine, Panda3D amongst many others.

Summary

By this point if you have covered and are familiar with many of the intricacies of a programming language and graphics library and or and game engine your well on your way to becoming a game programmer, the road is hard and difficult but make google your best friend and you’ll be able to bring you ideas to life in no time.

If you have any questions or think that something is wrong do let me know.

Advertisements

Write readable code!!!

10 Mar

WARNING.

This issue is personal.

Evil programmers we know all know them and have worked with them at one point or another, the write code using a mixture of unicorn tears, penguin fur and carbon dioxide, making sure that they contribute towards making the world a more hostile and less sustainable place to live in.

They by virtue of being quite intelligent usually spend time observing, studying and writing brilliant pieces of code that no one can read. Learning every single nuance and obscure syntax that 90% of other coders will not be able to read and will take hours or days to decipher. They merge variables, arrays, functions, structures and classes into one big mess.

A good approach to writing readable code would be to use the KISS (Keep it Simple Stupid) approach, write it like the guy who will read it after you is the Batman. Take a extra line, use a few white spaces, try some whitespaces for a change. Just make the damn thing legible.

Commenting is another good approach to take.

Please, Please, Please write something everyone can read.

Specifications for the Design, Development and Deployment of a Text Based Adventure or SDDDTBA

26 Jan

Introduction
I spent a large part of January planning this game, and as of writing this the coding has yet to start but I estimate that completing the game will take no more than a few hours this weekend to complete. The chunk of time I spent design the game, the pseudo / actually code scripts and figuring out how to track user events, game events and the flow chart has helped sort out a lot of key problems I would have otherwise had if I used my usual head first method of diving right in making a mess getting an idea of how things should flow scraping work done and starting all over again.

Game Objectives
A text adventure has the beauty of being as complex or as simple as I the designer wants. I wanted to design a game that is follows a fairly linear path and that changes during each play through. Using this idea as my corner-stone I decided that I wanted the game to have two character options, a ranger or a mage, the ranger was a male character and the mage a female one. The game is radically or more accurately subtly different when playing with either character, it is simple things such as the ranger has to complete the game without loosing health and the mage can cast healing spell, or the ranger is capable of dealing and taking more damage than the mage.

The game is subdivided into two main sections, the first section is the Tower where your character needs to traverse the game and save a princess or prince depending on whom you’re playing, this character is intricately woven into the gameplay by being able to provide the player with health and distance attacks if the player is the ranger or a defensive / offensive mover if the player is the mage, the player must not let this character die or will need to start again.

Story
The main trunk of the story will be the same for either character, the only change will be about social interaction between the two characters, hopefully create an emotional connection by the player towards the two main characters.

A simple overview the player enters a magical forest and decides to camp in a clearing for the night and when the player awakens to see a tower that sprouted overnight and being the curious type, they enter the tower.

Setting and Game Play
I’m trying to design the game to be as non liner as possible, or to be more accurate and less misleading, I want the game to be dynamic, the gameplay is dynamic through having different characters with different stats, and most enemies will have more than one method of defeating or getting by.

The Tower
The tower consists of four floors and each floor has something to overcome and an item to collect that may or may not help in the future. The top floor you need to fight the main tower boss and save the character trapped in their.

Forest
The forest has been divided into a grid similar to that of a tic tac toe board numbered from 1 to 9, number for each zone will be given at random so that the player will not go through the same path on each play through, however due to time constraints each zone will be fairly linear.

As an additional challenge the player needs to escape the forest with a set limit of time or they will be lost in the forest forever.

Code: Buggy and Hackey
Even though I spent countless hours trying to perfectly plan the game in my head, on paper and in small utility scripts I think all that will go right out the window when I sit down to write it. The game will work but I have a nasty feeling that the code will be ugly and hackey unless I have time to refactor it.

I’m hoping to separate everything into classes, functions, or separate files so that in the future I will be able to reuse the code or atleast the concepts in the code. I’m trying to keep the code as readable (ugly but readable) and forgo trying to make it as efficient as ever maybe someone else can go ahead and do it for me.

The version of Python I have decided to use for this game is Python 2.7 in the IronPython flavour simply because I have yet to see a IDE better than Visual Studio. As of this moment no additional modules are needed or will be used, except maybe for the countdown timer or a curses module for the UI.

Summary or tl;dr
Nothing much to say in all honesty I’m still trying to learn the intricacies of programing and particularly python, so this is a learning experience much more than anything else.

Considering how much time has actually gone and that I have only a weekend to complete I hope that I can complete my specifications and make the game I want.

This is not an excercise in coding it is in completing a game, and in doing so I will write it as hackey as I need to just so that it works.

Gripes with Python

22 Jan

When I started my rather large undertaking to try to complete 12 games in 12 months I took python as my language of choice. I had very little experience in it and wanted to becoming versed in the language and its intricacies by the end of the year.

For January I decided to write a small text-based adventure (specifications will be put up shortly) it seemed to be right up Pythons alley, lots of string manipulations, none to very little data storage and the code is almost script like rather than a complete program because no external modules are used. All my code is kept in a box.net folder along with a python setup executable so that I can access the data and code / debug from anywhere on almost any computer. This setup was perfect for about 2 days when I started to run into various problems.

Gripe 1 – No proper IDE
Before everyone starts chewing off my head, I come from a C / C++ background with a Windows OS. I use Linux (Ubuntu or Fedora) and have love / hate relationship with it, I regularly use the command line for compiling and debugging and often switch between Visual Studio my IDE of choice and Notepad++ when coding. However Python has no proper IDE for Windows that can match Visual Studio for convenience and in my humble opinion quality, it just works and if I’m not mistaken that Python unofficial motto.

Gripe 2 – Whitespace or Tabs
Many people attribute this as a key component for improved productivity. For me however its been nothing but a headache. I’ve been forced to change my entire coding methodology as I can’t move from Visual Studio to Notepad++ with causing some sort of white space error. I spend more time trying to correct syntax errors than actual coding.

Gripe 3 – Lack of Braces
Using braces comes naturally to me because of use in C / C++. Python does not use any while this is not a major problem I find the syntax rather a little difficult to read as I find it difficult to find out where a condition ends particularly when it is multi-lined.

Gripe 4 – Multiple Versions
Python has far too many versions and to use any tool created I need to use a different version of Python or jump through hurdles to print “hello world”. While trying to program games I’m dabbling in the Google App Engine and it requires Python 2.5, I use IronPython in Visual Studio which is compatible with Python 2.7 and when I’m using Pygame or Panda 3D I need to use Python 3+. It is very annoying as each implementation has different syntax and modules are not cross-compatible with Python 2+ and Python 3+, with most not having finished conversion as yet.

Positives
Even though I have some genuine problems and irritation working with python I’m finding its community to be very helpful and patient with new users particularly those on r/python.

Code samples are readily available in Python, especially for those looking for large projects that include scaling and other popular buzzwords used today. There are some very interesting projects that are written in Python and following them, editing some of the source is interesting and makes for a good challenge.

It is very easy and very quick to write simple scripts and small utility programs. But only if the modules you hope to use are compatible with the version of python you have installed.

The biggest relief for me was the built-in data structures, I did not have to look for or write my own templated data structures. Along with data structure I find that I prefer Python’s weakly typed arrays, mixing numbers and strings without the use of a custom data structure is a real time saver.

Conclusion
Overall while I’m struggling with the language I’m going to continue using it as it has a lot of scope for the future with its popularity in web app development and game scripting. Hopefully the guys on top sort a few of the language issues and move to Python 3+ and we can all live in peace.

12 Months, 12 Games

2 Jan

Programming requires motivation, and motivation requires an idea that your interested in, and I’m interested in video games. Taking my interests into consideration and to fatten up my portfolio, I’m going to start a second project for 2011, 12 games in 12 months 🙂

Most of what I program doesn’t really interest me or make me want to pick up a new skill or challenge myself. It becomes mundane and everyday. In order to inspire myself and get those creative juices flowing I decided to start this project. The language that I have decided to use is Python 3 and most games will have a text-based gui, or be in 2D using pygame. The source code for the games will be available publicly on my git. One of my goals for is to make these games as casual and accessible as possible, with high replay value.

The games / genres / clones that I would like to make are listed below, I may change some of these around as time goes by removing the less challenging ones.

  1. Text Based Adventure
  2. Hangman
  3. Battleships
  4. Pong
  5. Asteroids
  6. Sidescroller
  7. Shooter
  8. Rougelike
  9. Children’s Game
  10. Racing Game
  11. Tamagotchi
  12. Tetris
  13. Snake
  14. Scorched Earth
  15. Minesweeper

It’s a little more than 12 games but I’m bound to remove a few at a later date. The order might change as well but I’m going to start with the Text Based Adventure.

Installing colorgcc in Ubuntu

14 Apr

Using the terminal and a simple text editor is my preferred method of writing code, regardless of the language its a fast and efficient method of testing code with running the overheads of an IDE on my little netbook. But deciphering errors has always been a pain as simple black and white error messages give eyestrain and are difficult to see.

Fortunately for the more tech-savvy they have the option of soft linking the colorgcc module to there compiler commands. But for the like of you and me its been a pain, atleast until quite by fluke I came across the following method of installing the module.

All you do is, go to terminal and type:

sudo apt-get install colorgcc

Thats it, it works wonders and now my error messages come in colour.

First Programs I’ve written

8 Apr

Recently, as in today while cleaning up my Code folder I can across a simple Hangman game that I had written a long time ago back when I was just completing my course in C++ and trying to make sense of it all.

Mind you it is very basic and needs a lot of work to make it more efficient and meet the standards required. So without further ado, cast your eyes down upon my very cool code :).

/************************************************************************* 
	Author: toughaspixels
	Purpose: To study and understand the use of STL ad Vectors
	Date: October 26th, 2009
	Modfied: April 7th, 2010
        License: Just let me know your using it please, feed my ego
*************************************************************************/
																			
#include<iostream>
#include<vector>
#include<algorithm>
#include<ctime>
#include<cctype>

using namespace std;

int main(){
    
    const int MAX_WRONG = 8;
    
    vector<string> words;
    words.push_back("APPLES");
    words.push_back("MEGAGAMES");
    words.push_back("ZELDA");
    words.push_back("SILVER");
    words.push_back("GLUE");
    words.push_back("TINTIN");
    words.push_back("GEEK");
    words.push_back("MANHATTEN");
    words.push_back("TINTIN");
    words.push_back("ASTERIX");
    
    srand(time(0));
    random_shuffle(words.begin(), words.end());
    const string THE_WORD = words[0];
    int wrong = 0;
    string soFar(THE_WORD.size(), '-');
    string used = "";
    
    cout << "Welcome to HangMan. Good Luck!" << endl;
    
    while((wrong < MAX_WRONG) && (soFar != THE_WORD)){
        cout << "You have " << MAX_WRONG - wrong << " incorrect guesses left." << endl;
        cout << "You have used the following letters " << used << endl;
        cout << "So far, The word is:\n" << soFar << endl;
        
        char guess;
        cout << "\n\nEnter your guess: ";
        cin >> guess;
        guess = toupper(guess);
        while(used.find(guess) != string::npos){
            cout << "\nYou have already guessed " << guess << endl;
            cout << "Enter your guess: ";
            cin >> guess;
            guess = toupper(guess);
        }
        
        used += guess;
        
        if(THE_WORD.find(guess) !=  string::npos){
            cout << "That's right! " << guess << " is in the word." << endl;
            for(int i = 0; i < THE_WORD.length(); i++){
                if(THE_WORD[i] == guess)
                    soFar[i] = guess;
            }   
        }
        else{
            cout << "Sorry, " << guess << "is not in the word." << endl;
            wrong++;
        }
    }    
    
    if(wrong == MAX_WRONG)
        cout << "GAH!! GUH! NOOOOOooooooo\n Your hanged : ) HAHAHAHA" << endl;
    else
        cout << "\nYou guessed it : ) Your awesome." << endl;
        
    cout << "\nThe word is " << THE_WORD << endl;
    
    return 0;
}

There you have it folks, enjoy.

Please feel free to use my code, just make sure I get credit or at the very least let me know whose using it.

%d bloggers like this: