View Full Version : Where to start
Unregistered
04-30-2002, 11:06 PM
I was wondering...
My last project was a dos calculato that uses void commands...
where do i go next. What do i learn now.
ihsir
04-30-2002, 11:45 PM
>>What do i learn now.
whatever you want... get questions from books, ask teachers, use your imagination... endless possibilities :)
jdinger
05-01-2002, 02:01 PM
Not sure what your console calculator program used but since
you're asking this in a game development forum here are a few
things you'll want to look at:
1 - if/else/else if
2 - switch/case
3 - string manipulation
4 - for loops
5 - arrays (and later linked lists)
6 - structs (and later classes)
Of course, I generalizing big time here, but you get the idea. A
game's logic will (typically) consist of a number of functions called
from inside a loop (usually for). The functions process input from
the player(s) and uses if/else or switch checks to determine the
game progression. For console games you'll mainly be interacting
with the player through cout/cin (or printf/scanf) so you'll need to
be familiar with string functions.
If you're used to writing console apps then try writing a TicTacToe or Hangman game. If you need some ideas search the board
there have been a bunch of really good console games posted
here in the last month or so.
Unregistered
05-04-2002, 12:18 AM
hmmm.....
See, i try to look at tetris type game sources and i get soo lost.
I know i could make a dos pong if someone would tell me the way to organize the code and what keywords and all... There are no tutorials that take u to simple game programming.
So.. how do i make pong?
TechWins
05-04-2002, 01:43 AM
Before you are able to make a game, even a simple like tic-tac-toe, you should probably be able to answer yes to all of these, such as jdinger stated.
1 - if/else/else if
2 - switch/case
3 - string manipulation
4 - for loops
5 - arrays (and later linked lists)
6 - structs (and later classes)
If you are able to answer yes to these, then you are probably ready to start making your first game. I'm not sure if you know any APIs, and if you don't you're going to have to start off with text based games only. However, with certain characters like X and O you can make games like tic-tac-toe. I keep mentioning tic-tac-toe because that was the first game I made, and I think many people have their first game as ttt. Right now I'm only working on my third game but you really do learn a lot in making your first couple of games...it's all just a matter of practice. It's not as easy as "how do I make pong" as you asked. People aren't going to tell you how to make pong. Don't worry, though, when I look at tetris source code I have no idea what is going on either. The two games I have created so far have open source code so you can look at those if you'd like.
here (http://www.cprogramming.com/cboard/showthread.php?s=&threadid=14320) is the link to the thread for my ttt game.
and here (http://www.cprogramming.com/cboard/showthread.php?s=&threadid=16220) is the link to the thread for my second game...a maze game.
neither of these two games are spectacular but that was not the purpose of either one of these two games. the purpose was for practice and a learning experience. I suggest to start off making games for the same purpose and later on when you have a lot of practice and experience yuu can show off all of your skills in a great game.
at www.gametutorials.com they have a tutorial on how to make a ttt game if you want to look at that.
Good luck and don't be afraid to make mistakes but make sure you always correct those mistakes.:)
Unregistered
05-04-2002, 01:54 AM
THANK YOU....
And
1.Definately
2.yah.. kind of
3.wat u talkin bout
4.yah.. once
5.not sure
6no.. dont think so
What would i use num 3, 5, 6, for?
And i dont know what an API is...
Unregistered
05-04-2002, 03:24 AM
tib foo tedri ai too daimensonel ary ov strang
aray [n] [4] [9] =
{
{"011011", "11010", "1001011", "10101"},
{"011011", "11010", "1001011", "10101"},
.
..
}
jdinger
05-04-2002, 08:35 AM
Originally posted by Unregistered
tib foo tedri ai too daimensonel ary ov strang
And that means what in English?
jdinger
05-04-2002, 08:41 AM
String manipulation - used for interacting with the player, etc. Things like strcmp, strcpy, strcat, toupper, tolower, etc., etc., etc.
Arrays - used to hold multiples of the same object, ie: sprites, units, map squares, etc.
Classes - uses to provide OOP (or, to please the masses, pseudo-OOP) modularity. Makes your life easier. If you have 200 units on the screen and initializing one unit takes 30 lines of code, without using classes you're looking at 6000 lines of code just for initialization. If you encasulate it in a class then you only need 1 line per unit to initialize (total of 200 lines of code, less if you use a loop and populate variables with generic standards). Plus there's less chance of mistake because you aren't typing the same stuff over and over 200 times. You type it all once, include the appropriate header and then declare your object.
Vicious
05-04-2002, 08:51 AM
as u can see i registered so im not confused with that guy didnt know englis or something.
thanx for all the help...
i will try to put all of those functions into a program...
any suggestions what to make using those?
:confused:
ErionD
05-04-2002, 09:47 AM
>tib foo tedri ai too daimensonel ary ov strang
Maybe: "Tip for tetris: a two dimensional array of strings"
Vicious
05-04-2002, 10:36 AM
WOW... howd u come up woth that one? :eek:
Vicious
05-04-2002, 10:45 AM
lol... I see now.. ROFL:D
Vicious
05-04-2002, 11:38 AM
Okay I understand how it all works.
But how do you tell it to put the X in the grid???:confused:
Here is what ive got so far.....
#include <iostream.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
int player[2]={0,
0};
char grid[3][3]={{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '}};
void Makegrid();
void Makegrid()
{
system("CLS");
cout<<endl<<endl
<<"\t\t\t\t Toe-Tac-Tic \n\n\n\n\n"
<<"\t\t\t\t"<<grid[0][0]<<" | "<<grid[0][1]<<" | "<<grid[0][3]
<<"\n\t\t\t\t ------------ "
<<"\n\t\t\t\t"<<grid[1][0]<<" | "<<grid[1][1]<<" | "<<grid[1][3]
<<"\n\t\t\t\t ------------ "
<<"\n\t\t\t\t"<<grid[2][0]<<" | "<<grid[2][1]<<" | "<<grid[2][3]
<<"\n\n\t\t\t"<<endl;
}
int main (int argc, char *argv[])
{
cout<<"This Tic-Tac-Toe Game uses the mouse.\n\n"<<endl;
system("pause");
Makegrid();
getchar ();
return 0;
}
sigh... PLZ HELP
Vicious
05-04-2002, 12:09 PM
oh forget about that mouse thing... :rolleyes:
red_baron
05-04-2002, 01:24 PM
take a loot at TechWins reply ;)
Vicious
05-04-2002, 02:31 PM
ive been there done that...
:o
TechWins
05-04-2002, 04:38 PM
ive been there done that...
Well, if you take a closer look you will be able to understand.
None the less I'm going to give you the benefit of the doubt and help you.
To answer a previous question of yours, an API is a graphics library. Such graphics libraries as DirectX, OpenGl, Allegro, SDL, etc... are the most popular. Most people start off learning the Win32 API to get a better handling with graphics. Win32 API teaches you the basics of how to use the mouse cursor for input, inserting a bitmap, creating a real 'window', changing the screen to full screen, and a few other things. Each API is just like learning C++ over again. While you are still using the fundamentals of C++ you are having to learn new functions that the API offers. Basically an API is just a bunch of include files that offers many helpful (and I'm sure that's an understatement) functions. That's about as good of an explanation I can give, because I have absolutely no experience with any APIs.
You can't use the mouse in a console based application (read above for some more info).
For inserting the Xs and Os into the array you are going to have to have user input, which you have with getch(). *With a game like ttt I would use cin instead of getch(). Cin will give the user a chance to put a character on the screen and still have a chance to change there mind, whereas, with getch() the user won't have a chance to change their mind once they input a character onto the screen.* If you played my ttt game you'll have noticed that you have to put in the row and column number. I'd recommend just assigning a number to each square in the grid. Such as the very middle square will equal 4. When the user is asked what square they want to check, if they input 4 then make grid[1][1] == 'X' (or 'O'). There have been a lot ttt games made lately on this forum and if you just play a few then look at the source code you'll get a better understanding of how the game is made. Better yet you can do the ttt tutorial at gametutorials.com.
Vicious
05-04-2002, 04:43 PM
After studying the source code.. I have come to a conclusion...
I need some tutorials on the basic things that you did tech.
Like the strings and arrays and stuff...
Anybody know where i can get these tutorials.
Oh.. that tutorial on www.gametutorials.com is WAY over my head!
If anybody wants to see... Here is my calculator source.
Vicious
05-04-2002, 04:47 PM
I tried to use that
grid[1][1] == 'X'
but my compiler wont accept it...
Like when i try to make colored text.. It finds no errors.. but it will not execute after it compiles...
So now what
:(
Vicious
05-04-2002, 05:06 PM
I got the SDL...
Now to figure out what to do with it...
:o
TechWins
05-04-2002, 05:09 PM
grid[1][1] == 'X'
Well, you only use == if it is inside of an 'if statement' (there might be other situations that I'm not aware of by the way). You use = if you want to actually declare that variable to equal the other side of the equation.
For example, I was hinting at using grid[1][1] = 'X' in this situation.
cout << "what square would like to check";
cin >> answer;
if(answer == 1
{
grid[0][0] == 'X';
}
else if(answer == 4)
{
grid[1][1] = 'X';
}
makegrid(); /*now when you display the grid, the very middle square will have an X in it if answer equaled 4 or if answer equaled 1 there would be an X in the very top left corner, etc...*/
That's a basic example of how you would get the user input and then put it in the appropriate spot in the array.
Anybody know where i can get these tutorials.
Well, I'd recommend buying a book instead of looking at tutorials if you feel that you aren't ready for this yet. Hey it took me a while too, so don't get down on yourself. If you do want to look at tutorials I would recommend this site's tutorials.
I have a few questions for you. Do you now know when you use '=' and when you use '=='? Do you know why I used else if? Do you know why I use grid[0][0] (or grid[1][1]) instead of using grid[1][1] (or grid[2][2] for the other example)?
About your calculator program, at least you have some practice with functions. When I first did my calculator I probably knew just as much as you do now (maybe a little more?), but by just trying many things and continuing to look over things in my book while making the game I was finally able to make the game.
TechWins
05-04-2002, 05:10 PM
I got the SDL...
Yeah, you can forget about using that for a while!;)
Vicious
05-04-2002, 05:25 PM
it still wont place the X
wat is the n00b doing wrong now?
#include <iostream.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
int player[2]={0,
0};
int mve;
char grid[3][3]={{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '}};
void Makegrid();
void move();
void Makegrid()
{
cout<<endl<<endl
<<"\t\t\t\t Toe-Tac-Tic \n\n\n\n\n"
<<"\t\t\t\t"<<grid[0][0]<<" | "<<grid[0][1]<<" | "<<grid[0][3]
<<"\n\t\t\t\t ------------ "
<<"\n\t\t\t\t"<<grid[1][0]<<" | "<<grid[1][1]<<" | "<<grid[1][3]
<<"\n\t\t\t\t ------------ "
<<"\n\t\t\t\t"<<grid[2][0]<<" | "<<grid[2][1]<<" | "<<grid[2][3]
<<"\n\n\t\t\t"<<endl;
move();
}
void move()
{
cout<<"Place your X: ";
cin>>mve;
if(mve == 1){
grid[0][0] == 'X';
}
else if(mve == 2){
grid[1][1] == 'X';
}
system("cls");
Makegrid();
}
int main (int argc, char *argv[])
{
cout<<"This Tic-Tac-Toe Game uses the mouse.\n\n"<<endl;
system("pause");
Makegrid();
getchar ();
return 0;
}
TechWins
05-04-2002, 05:34 PM
grid[0][0] == 'X';
That should be grid[0][0] = 'X'; The same goes for grid[1][1].
You use == when you are comparing two varialbes such as is done in an if statement. You use = when you actually want one variable to equal another varialbe such as with grid[0][0] and X.
So == are for comparisions and = is for setting two variables equal to each other.
Vicious
05-04-2002, 05:47 PM
FINALLY...
Now for the Ai...
NOOOOOOOOOOOOOOOOOOOO
:eek:
TechWins
05-04-2002, 06:06 PM
Now for the Ai...
Well, since I've already said a lot about AI in a few recent threads I'm going to give you the links to those threads instead of me just having to restate everything.:)
The second page of this thread (http://www.cprogramming.com/cboard/showthread.php?s=&threadid=15820&perpage=15&pagenumber=2) is filled with talk about AI, which is where the link directs you to.
This thread (http://www.cprogramming.com/cboard/showthread.php?s=&threadid=16147) thread also has a lot of talk about AI.
If you read both you will understand a lot more about AI for basic games.
Vicious
05-04-2002, 07:23 PM
Yes, i know this has been asked a thousand times...
But I cant get text colors and background colors to work in dev-c++.
Will SDL do this?
and should I just get a better compiller that supports all of these techniques and headers like Graphics.h
TechWins
05-04-2002, 07:44 PM
Will SDL do this?
You are NOT ready to use/learn an API yet.
But I cant get text colors and background colors to work in dev-c++.
#include <windows.h>
SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), 6 | FOREGROUND_INTENSITY);
Change the '6' to any number you want to change the color...test it out by changing the color...I believe 6 is for yellow. For more info just do a search on changing text colors and you will find a bunch of info. That's what I did.
BtW, I only use DevC++ myself. I used to use DevC++ 4.01, but now I use DevC++ 5_beta4.9.2. There are a few bugs with the v5 but I have found ways to work around them.
Vicious
05-04-2002, 11:05 PM
I finally got the grid fully functional....
Thanx to TechWins for all the help.
;)
Sigh.. now for other things...
Da-Spit
05-05-2002, 12:21 AM
I'm in the middle of making a TTT Game too. Maybe we could help each other out?
red_baron
05-05-2002, 08:07 AM
here's my first game :) i had fun making it for school, its in c but the only differences i noticed (at our level) is that
printf is coot
scanf is cin
or something like that, rest are almost identical.
(made it in dev c++ v4)
enjoy!
Vicious
05-05-2002, 10:02 PM
i completely re did the code...
it is real un-complex...
Ill post it asap.
:D
Vicious
05-05-2002, 10:15 PM
Sure... I actually know what im doing now i think...
:rolleyes:
No offence to tech... but my code is real simple compared to his.
let me show you how my grid is...
1 | 2 | 3
-----------
4 | 5 | 6
-----------
7 | 8 | 9
Place your X: _
if you mash 1 a X pops up where the 1 is..
how do you have your grid?
Vicious
05-05-2002, 10:20 PM
I just looked at your code...
It is similar... but im going to have 1 and 2 player...
Im only worried cause of how simple the code is
:(
If you look at mine and Techs it looks like I finished building a car with 5000 pieces left over.
:p
TechWins
05-05-2002, 11:54 PM
Granted I'll admitt that I typically code 'too much', but in this case I have a few good reasons.
1) I space my code out a lot so that creates a lot of extra lines, yet, not extra code.
2) I have AI in my game, as well as 2 player, which adds a lot of code.
3) There is no definate on when you'll go as the player, either 1st or 2nd. This adds a little bit more of code.
4) I have a score table, which adds more code.
5) You can play the game more than once without having to quit.
6) Another reason that isn't that obvious, is that I used row/col to decide where each piece should go. Whereas, most people use a single number for where each piece should go. My method creates a lot more code than the other method.
Even with all of these reasons I'm sure I could significantly detract some of my code without changing the program the least bit, but it doesn't matter to me anymore.
:)
The method of just having a single number to input is much better than doing the row/col thing like I did, IMO. Also, Vicious, I recommed doing AI with your game because you'll learn a lot from doing it, and it makes your whole experience (and game) that much better. It's pretty cool seeing your first AI respond to a human too.:cool:
Vicious
05-06-2002, 11:05 PM
Ive been soo busy with my program today...
The 2 player is fully functional and im almost through with the AI.
:rolleyes:
It has everything except score tracking.
;)
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.