# Step by Step

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

## Recommended Posts

Yo i bin reading thru tutorials for C/C++ for a while now. I wanna start applying it but i have no idea where to start. I dont suppose anyone knows of an online walk thru to creating pong or tetris or sumthin do they? cheers for ya help, Dan.

##### Share on other sites
Well, there are several options for doing graphics. One of the best for c++ is SDL. It can do all sorts of graphics and player input things.

http://www.aaroncox.net/tutorials/2dtutorials/index.html
That website has some nice pong/tetris/other tutorials, but you'll probably want to make some text-based games/programs first.

Just a tip: you'll get better responses on this forum if you don't use too much internet slang.

##### Share on other sites
My tutorial site covers creating a breakout clone using directx.

##### Share on other sites
Actually, there are several good articles on this site that go step by step, you might have to do a little digging though.

##### Share on other sites
Um after battling with this for a bit....i think im gonna go for a txt based game first lolz.

Where should i start?

##### Share on other sites
here's a sample progression of games you can try making that each need more skill than the last:
Text:0)Hello world1)Guess a number2)tic-tac-toe3)Poker4)Text based adventure game, ie:  "pick up dagger"  "look at tapestry"  "attack wolf"2d graphics:5)use graphics and make pong6)breakout7)tetris8)side-scroler3d graphics9)3d pong10)simple 3d level with a few rooms to walk through11)put enemies in level12)animate enemies13)add physics and collision detection

##### Share on other sites
iam just a beginer at maya 7 ple i just downlaod it and i have this book for it i need help because in the book it tells me to go to creat poloygon tool then make the figure showen then extrude egdes and then it tells me to go to modify>convert>poloygon to subdiv i do all of this and when i go to click on poloygon to subdiv a waring thing shows up and says that it only works on polygon sufaces so if i could get some help that would be great thx.

##### Share on other sites

You might to search around a bit for a "step-by-step" explanation.
But programming is about learning, and appling what you learned to solve a problem, in this gase a game.
First you decide on the design of the game, like genre what stats are onscreen, menues, ect.
Then, you could ask yourself how you could accomplish each of those, possibly in pseudo-code (code-formatted English).
Once that's done, you would be better prepared to do or start it yourself and ask for help if you need.
Now I know that dosen't sound as friendly as a step-by-step tutorial. But in the long run you can learn more - you learn your programming limits, from mistakes, ect.

Good luck to ya.

##### Share on other sites
well i have done hello world lolz :)

whats guess a number?

lemmie guess,

1-The proggy randomly generates a number (lets say out of 10?).
2-Next that number is assigned to a variable (say we call it "prize")
3-Then i need to prompt the user to guess a number right?
4-The guessed number typed in by the user is then also assigned to a variable (say "guess").
5-Then the 2 variables are compared and either a success or fail message comes up?

Um, is that right?

(thanx for your replies btw :))

##### Share on other sites

Anywayz,
well i went on a bit of a google search and from what i can understand i need to use the rand and rand_max functions for step one, though im not sure of the proper syntax.

The input bit is a bit like this?:

#include <iostream>
using namespace std;

int main ()
{
int guess;
cout<< "plz guess a number"
cin>> guess;

##### Share on other sites
Really, you only have to seed it once, and after that it uses the previously generated number to create the next one.

If you use randomize(), then it seeds it with the current time, and you don't have to worry about it at all. It also guarantees a unique string of numbers every time.

##### Share on other sites
random number generators are a strange concept to grasp at first. the key thing to know about a seed is it allows you to either use the exact same sequence of random numbers or a different sequence every run of the program depending on what you send it. If you seed it with the same value every time you restart the program you will get the same list of numbers. take this program for instance:
#include <cstdlib>#include <iostream>using namespace std;int main(){  srand(100); // any number will do  for(int i = 0; i < 30; i++)  {    cout << rand() << "  "; // rand will give you a number between 0 and RAND_MAX                            // how big RAND_MAX is depends on the compiler  }  return;}

every time you run it you'll get the same output. This way if you wanted to duplicate something you'd be able to. Now most of the time you want different numbers every time you run the program. But what will change every time we run the program? Time! Every time you run the program the current time will be different and so every time you will get a different collection of numbers:
#include <cstdlib>#include <ctime>#include <iostream>using namespace std;int main(){  srand(time(NULL)); // time(NULL) will return the current time in seconds  for(int i = 0; i < 30; i++)  {    cout << rand() << "  ";  }  return 0;}

every time you run this program you should get different numbers printed out!

Okay, so what if you want a number between say 100 and 200? Well here's some code and I'll explain how it works:
int randomRange(int low, int high){  int range = high - low;  return (float)rand() / RAND_MAX * range + low;}

there are three parts to this. first, we need the range of numbers it gives. the only difference between a set of number between 100 and 200, and between 0 and 100 is that you add 100 to the first. the second is we need to turn the set of number between 0 and RAND_MAX to a set of numbers between 0 and 1. that is what
(float)rand() / RAND_MAX
does. it turns rand() into a floating point number and because rand() cannot be greater than RAND_MAX you'll get a number greater than 0 and less than 1. Next we multiply it by range. And finally we add the low number and return the result. Got it? Hope that helps a bit.

##### Share on other sites
Wow thats er confused me...lolz

I understand i am going to be using the ctime as the seed. And i can use either rand() or randomize(). But i am still confused as how to create a random number between 1 and 10.