Jump to content
  • Advertisement
Sign in to follow this  

How does one approach this task?...

This topic is 4912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Let's say I want a game sort of like Columns, where you have to match 3 or more colors, horizontally, vertically or diagonally. How would I go about doing this? That is, being a newbie, I don't know what programming steps I'd need to take, what functions I'd need, what variables I'd need, etc. In general, I don't know enough to have a clue as to what things need to be done/taken into consideration. Can someone give me at least a general summary of what I'd need to do? Thanks in advance... - JS

Share this post

Link to post
Share on other sites
well u could store everything in a 2d array

int width = 10;
int height = 20;

int array[10][20];

and its pritty quick to scan through the array to check for what you need

Share this post

Link to post
Share on other sites
What are you trying to accomplish? Something like connect 4 I presume. You'd have your game board and then go through a nice handy loop checking to see if any are in sequence. If you're L337, you'd create a recursive function to check.

Share this post

Link to post
Share on other sites
hopefully I'm correct in guessing that you know how to program in the language that you want to program your game in? Otherwise your best bet is to learn the language before programming a game. I've seen some intro to programming tutorials that use game development, but they are few and far between.

You would probably start off designing the structure.

The only problem with designing is that you really have to have some idea how you are going to program it. Designing is one of those things that you pick up as you get better at programming.

Probably the first thing you will want to work out is how you are going to store the game information.

What language are you using? With the example that you have chosen this doesn't make a huge difference but as you progress to more compilcated games it becomes more important. The language you choose normally dictates the structure of your program.

I'm guessing whatever language you are going to use you have some sort of array structure, I believe this is the best way to store your game information. I'm not familiar with "columns" but I am guessing it is played on a grid, and each square can either be empty or a colour from a finite set of colours. I'm also guessing that you are given a random colour, and you can choose which column to add it to. If your language has enumerations then for starters you can use them to represent the states of the grid. One enumeration would be for an empty square, and one for each colour that you want.

You then need to create functions that can access the array (either passing it around or as a global). This is where languages differ, in C the only real option is for the array to be global (it is possible to not do this, but impractical). It is widely agreed that globals are to be avoided. In C++ the solution would be to create a game class with the associated methods.

You then need to create your game logic functions. You would have functions like:

void add_puck(int column, int colour)
bool test_column(int column)
void test_grid()
bool game_over()
int generate_puck()
void clear()

After you complete these functions you need to build the api side. This includes displaying the game, getting input from the user.

Also it would be good to have other variables, like a score.

You can then write the main loop that does the correct things in order:

generate puck
get column from user
check if column is full
add puck
test grid
game over

I leave the actual logic (conditionals etc.) to you.

Share this post

Link to post
Share on other sites
Thanks very much for all your help. I greatly appreciate it. Just FYI, I'm using Delphi 5 Standard, with Un-DelphiX... out-dated, I know :/
Take Care,
Justin Szczap

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!