-
Posts
243 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Furbolg
-
-
Nope, for that case you have namespaces
-
You should name your #define macros like XXX_INPUT, where XXX stands for your project or your favorite name.
That's also a good scenario why c++ programmer use namespace and why "using namespace" shouldn't be in header files (if your #define would be a const int input = 0x01 for example and windows.h (or some other header) using the same variable name, you would have similiar problems).
Good to see, you could resolve your problem *cheers*
-
You got 3 possibilities in my opinion to achieve that :
- use pure lua ( just google for "c++ lua call function" e.g.: http://gamedevgeek.com/tutorials/calling-c-functions-from-lua/ )
- use luabind (c++ interface which allows classes (c'tor, d'tor, inheritance etc.) but you still have to do the hard coding)
- tolua++ (which creates the code for you, if i understand it right, never used it)
-
Strange, the winuser.h is an windows header, i don't think it's contained in leadwerks.
Did you tried to restart your computer ?
-
Hi Aggror,
it's a standard windows header file.
Try to Clean Solution + Rebuild Solution and restart Visual Studio before doing this.
-
No pre-coded system on the planet can know what I'm doing with my code better than my own flow of thought.
Auto completion is just suggesting what you probably want to write.
I dont understand these kind of guys like you, "i just use notepad" ... sure just do it if you want. But when you don't want to see to improvement in workflow with auto completion, high lighting and refactoring ... then sorry but you are living in the 80s (hungarian notation *wave*).
Why not use these helpers ? There is enaugh hard stuff to care about in programming, why not use this comfort and concentrate on the important stuff ?
-
Wow ... really good tutorial aggror
You are right about XML its a good format because you can change your level format in a minor way without messing up your loading routine. The problem with XML is its size, i would prefer a binary level format in the final result/game (with stream::writeint etc) because its faster to load.
// edit:
If you want to see a real bloated XML file, have a look at an animated complex Model in COLLADA Format... its the worst i've ever seen...
-
How about something basic like saving/loading own game format (level) ?
-
Hi Aggror,
good c++ classes tutorial, thanks for mentioning me Am i famous now ?
I just get some suggestions:
- when you speak from a class: it's definitely method not function
- you can use "using namespace leadwerks;" within cpp files (it's bad style to use it in a header because everyone that includes your header also get this "using namespace xxx;" to work with... within cpp files it doesnt matter)
- std::string::c_str() is from the Standard Template Library (STL) not c++ (im a bit of smart *** ) and stands for const string
Im a also doing something like this:
class foo() { // C'Tor / D'Tor public: foo(); ~foo(); // Methods public: void method(); };
-
Are we talking about a "simple" console ? Then use lua its the best choice for this kind of stuff, dont make your life harder then it needs to be
-
No problem.
Be careful, that your components dont lead you into "The diamond problem" http://en.wikipedia.org/wiki/Multiple_inheritance
-
Try this one:
CComponent
#ifndef CCOMPONENT #define CCOMPONENT class GameObject; class CComponent { public: CComponent(); CComponent(GameObject* parent); ~CComponent(); int ID; GameObject* parent; virtual void Init() = 0; virtual void Update() = 0; virtual void Draw() = 0 ; bool enabled; }; #endif
GameObject
#ifndef GAMEOBJECT #define GAMEOBJECT #include "Leadwerks.h" #include <list> #include "CComponent.h" class GameObject : public CComponent { public: GameObject(); GameObject(GameObject* parent); ~GameObject(); void Init(); void Update(); void Draw(); void RemoveComponent(CComponent* component); void AddComponent(CComponent* component); //holds all the components of that game object list<CComponent*> components; }; #endif
You have to add the GameObject Header include in the CComponent C++ File ( #include "gameobject.h" in ccomponent.cpp).
Sorry for double post
- 1
-
thanks for the help Rick.
I got rid of the error in the CComponent class, but the one in GameObject is still there. This is how the GameObject looks now:
#include "CComponent.h" class CComponent; class GameObject : public CComponent {
You done it the wrong way, as rick mentioned you cant use forward declaration (btw. you are using forward declaration and the CComponent header file... this can't work) as a normal class (inherit from it) just as a pointer.
Your CGameObject has to include CComponent the normal way but your CComponent has to use forward declaration.
Forward declaration works like this:
//test.h: class cgameobject; class ccomponent { public: ccomponent(cgameobject* obj); private: cgameobject* gameobject; }; // test.c++ #include "test.h" #include "cgameobject.h" ccomponent::ccomponent(cgameobject* obj) { this->gameobject = obj; }
-
Forward declaration is the solution but as rick mentioned you can only use pointers.
You should avoid circular dependencies whereever possible.
// Edit:
You should also avoid "using namespace xxx;" in your header files, it can happen that you use another library and as soon as you include your header it will have multiple classes / types with the same name.
Use "using namespace xxx;" only in c++ files.
(of course your code will work but its bad style and you CAN run into problems later)
- 1
-
Could you explain why it irritated you? Since it is static I figured it wouldn't really matter whether is was public or private.
I didnt realized it is a class
Ah thanks. I actually had a working sample of this in a school project. I simply forgot the class 'Test::' before the static variable in the cpp. I actually don't have to set it NULL. It works perfect like this as well:
Leadwerks::Window* Test::window;
Only in debug mode, try this in release mode and you will wonder what an uninitialized variable can do.
-
Can you post more / attach a sample project ?
Right now, im am wondering: why you declaring "window" two times (in *.h and *.cpp) ?
// Edit: (your "public:" irritated me )
Sorry my mistake, Rick is right you have to initialize the static variable and not just declare it because the static variable exists (or can exists) before your class does.
-
Hope to see your Angry Fruitman Ninja soon (Angry Birds + Fruit Ninja + Hangman)
-
Maybe have a look at your "competitors" and look what they did. Maybe you can gain some ideas from it
I mean you can do what you like, for example:
-Bomberman
-3D Tetris
-Counterstrike 2D
-Scrabble
-Yatzee
-Sodoku
-Four wins
(for the oldschool: Hangman)
etc..
-
You can also realize small parts of your game, for example networking (with some cubes), terrain/environment, ai... just split your big project in some smaller chunks and try to realize them.
Just my 10 cents.
-
Sounds like DVI-I ( http://en.wikipedia.org/wiki/Dvi ) ?
-
I see your problem, its like you want to store int, float, double and std::string in a single std::vector.
I dont have a solution right now, have you had a look at the c++ design patterns?
-
Typedef is just a shorter form / comfort:
(these example are from a dll (plugin system) and i dont put in c++ casts, they would make it harder to understand)
Typedef:
// define the type typedef int(__stdcall *CallBack)(void); // use it to load the method CallBack callme = (CallBack)::GetProcAddress(hDLL, "somecallback"); // call the method callme();
Without:
// use it int(__stdcall *CallBack)(void) = 0; CallBack = (int(__stdcall*)(void))::GetProcAddress(hDLL, "somecallback"); // call it CallBack();
-
Just try and post your statement in a c++ forum.... but take cover
Is it a problem ?
For c++ programmers (the guys who love c++ and not only use it because of speed/portability): yes
For the big part of this community: probably not
But you mentioned a messed up callstack, this can't be happening when used correct c++ patterns (mcp posted).
// edit:
Josh using the doc posted for object::addhook (link here http://www.leadwerks...ectaddhook-r759). My code now compiles but throws the above mentioned runtime error. MPC says this error needs to be fixed in the LE3 source code for OS X b/c it apprently works for windows according to rick.
It is working but the behavior is undefined, it can work on windows but dont work on *nix.
-
What else would they be? It's just a memory address.
If you argue this way then let me ask: whats the difference between integer and string ?
In theory (assembler) you are right josh but c++ has some patterns / behavior which define some basic rules. You can't just take the ones you like and ignore the rest.
// Edit:
LE3 is a C++ library now so there is no harm in doing this.
To be honest, its actually more C/C++ then C++... dont take it personal, please.
network support
in Programming
Posted
Besides the MMO(RPG) for Android/iOS thing (mmo in tablet/smartphone ?... really ?), where is the problem to write your own encapsulation of an UDP socket class in c++ ?