idiot question :)
idiot question :)
hey all!
i know this is an idiot question, How can i clear the scene to start a new level in my game?
i know this is an idiot question, How can i clear the scene to start a new level in my game?
(\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
answer
thx! but that's not what i ment
in c++, how can i set up the project so i can for example make a cpp file for each leve, i'm not a good c++ programmer, is there is any place for tutorials on this subject??
in c++, how can i set up the project so i can for example make a cpp file for each leve, i'm not a good c++ programmer, is there is any place for tutorials on this subject??
(\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
-
- Posts: 34
- Joined: Sat Mar 31, 2007 8:38 pm
Re: answer
Hey BeshrBeshr wrote:thx! but that's not what i ment
in c++, how can i set up the project so i can for example make a cpp file for each leve, i'm not a good c++ programmer, is there is any place for tutorials on this subject??
In actuality, you can just make functions for each level, and of course put those functions in the said cpp files. The viability of this depends on what kind of game you are making. What kind of game are you making?
answer
my game is about a ball that i need to move to take to some place. it's not about actully the type of the game i think. my point is when i make another funtion let's say for level 2, when i call it it tell me this:
i know that this is because i have them already defined, but if i didn't define them, it tells me that it's an undeclared identifier.
Code: Select all
Linking...
Game_initialize.obj : error LNK2005: "class irr::video::IVideoDriver * driver" (?driver@@3PAVIVideoDriver@video@irr@@A) already defined in Game.obj
Game_initialize.obj : error LNK2005: "class irr::newton::World * p_world" (?p_world@@3PAVWorld@newton@irr@@A) already defined in Game.obj
Game_initialize.obj : error LNK2005: "class irr::scene::ISceneManager * smgr" (?smgr@@3PAVISceneManager@scene@irr@@A) already defined in Game.obj
(\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Re: answer
You might give Irrwizard a look. It will give you a basic framework to start off with.Beshr wrote: in c++, how can i set up the project so i can for example make a cpp file for each leve, i'm not a good c++ programmer, is there is any place for tutorials on this subject??
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
Works equally poorly on all systems.
-- unknown
i thought this prevents creating another instances of variables
Code: Select all
#ifndef _h_file_
#define _h_file_
<...some code...>
#endif
what ? the variable are supposed to be defined in the .h along with the functions (unless you want to "hide" them), arn't they ?hybrid wrote:Don't define variables in .h files, but only in .cpp (and thus later on in .o) files. Because every inclusion of the .h file will create another instance of the variable, with the same name and scope.
if headers are ment to be class definition files, how come headers are used with plain c too?
headers are declaration files, but general, not restricted to classes.
Back to the subject, the problem is that if you declare a variable in a cpp-file, the compiler assigns a name to the space where the variable will be in your program, so that it can be refered to using that name. (sortof). If you have another variable of the same name in another cpp file, it will get the same name. So far so good.
But when the linker kicks in, the problem arise, because there are 2 memory areas with the same name. (sortof).
The solution is to define your variable in a way that doesn't make the compiler assign the name a new memory area, but instead just use the name, and let the linker do the linking between name and memory area.(sortof).
example:
EDIT: Hehe, i messed up here. The variables need to be extern in .h-files too.
sortof.
As i've understood it, definitions are the actual code or variable-objects, while declarations are maps to how we use the code/objects. sortof.
So multiple definitions is a problem, but multiple declarations should not be a problem.
Hope it helps a little
headers are declaration files, but general, not restricted to classes.
Back to the subject, the problem is that if you declare a variable in a cpp-file, the compiler assigns a name to the space where the variable will be in your program, so that it can be refered to using that name. (sortof). If you have another variable of the same name in another cpp file, it will get the same name. So far so good.
But when the linker kicks in, the problem arise, because there are 2 memory areas with the same name. (sortof).
The solution is to define your variable in a way that doesn't make the compiler assign the name a new memory area, but instead just use the name, and let the linker do the linking between name and memory area.(sortof).
example:
Code: Select all
//File1.cpp
int x; //Global int x
//File2.cpp
int x; //global int x
//This produces that error, since there are 2 global "x"-objects
Code: Select all
//File1.cpp
int x; //Global int x
//File2.cpp
extern int x; //Global in x, which's object/memory is in another .cpp
Code: Select all
//file1.cpp
#include "File3.h"
int x;
//File 2.cpp
#include "File3.h"
//X was declared in file3.h
//File3.h
#ifndef _h_file_ //Protection!
#define _h_file_
extern int x;
#endif
As i've understood it, definitions are the actual code or variable-objects, while declarations are maps to how we use the code/objects. sortof.
So multiple definitions is a problem, but multiple declarations should not be a problem.
Hope it helps a little
Last edited by Luben on Tue Apr 10, 2007 5:26 pm, edited 2 times in total.
If you don't have anything nice to say, don't say anything at all.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
They should be declared in .h files, but not defined. Even header protections won't help with definitions, as these will be put into each .o files which includes the .h file.eneru wrote:what ? the variable are supposed to be defined in the .h along with the functions (unless you want to "hide" them), arn't they ?hybrid wrote:Don't define variables in .h files, but only in .cpp (and thus later on in .o) files. Because every inclusion of the .h file will create another instance of the variable, with the same name and scope.