Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 11 Apr 2004
Offline Last Active Apr 27 2014 10:16 AM

Topics I've Started

Game state management (C++)

30 July 2013 - 04:41 AM

Hi guys,


My gamestate management uses classes (gamestates) with a init(), run() and close() function,

When Changestate(state) gets run, it closes the old state, inits the new one and runs it.


Here is my problem, whenever I use Changestate() in my current state, e.g. someone presses the "Game Menu" button

so Changestate(gamemenu) is called, it still has to finish the old state. For instance take this example:


//some gamestate


The Changestate() makes a copy of the old gamestate (which will be removed using remove_old_gamestate() later, and inits the new one.

This is not very efficient as in this period the game needs about double the memory (old one is not closed down yet, new one is already initialized). However it is nessacary, because using "currentstate->close(); delete currentstate; currentstate = newstate" does not work, as soon as the ChangeState() function is over, the call stack goes back to where it was called: the old gamestate, and the draw function still has to be called, in a state already closed/deleted. I dont understand how I can overcome this problem without using gotos (which I prefer not to use).

Anyone has an idea?


[Lua] Installing/compiling and usage of Lua in Windows

03 April 2013 - 12:47 PM

Hello guys,


I was just wondering, I downloaded the newest source files, compiled them and ended up with a .dll file and the compiler and intepreter .exe files.

But don't I also need a .lib file to link with my program? (as right now I'm getting linking errors when compiling example files).

If so, how do I obtain this .lib file from the source? I am using Visual studio 2012 (btw I know I could just download the binaries).


Second, I was wondering why people use the LuaBind or other wrappers, the buildin C API seems quite easy to use, what are the advantages of using these third party wrappers? Wouldn't it give trouble with newer versions of Lua? (having to wait til these wrappers update as well).


Kinds regards,



Missing ' suggestions' VS feature in Code::Blocks

09 February 2012 - 12:14 PM

Hello all,

I always used to program in Visual Studio, but now I am playing around in Linux and I need a programming environment.
So I downloaded Code::Blocks but I really miss the features of automatically showing all class members and variables after pressing the class(.), class(->) or class(::). In VS, after you press either the . :: or the ->, VS shows a list of members that you can choose. I got used to this so much that I'm really feeling lost without it. It both saves time and informs you about all possible functions.

Is there an IDE in Linux that has a similar functionality?
The problem is that I don't know the word for this functionality so I cant realy google it :)


Make and Makefiles

06 February 2012 - 02:53 PM


I am confused about make and makefiles. I learned programming with visual studio, which uses convenient project files. VS lists all source files and when you press 'Build solution' it will be compiled and build and everything goes smoothly.

But sometimes I want to use code written by others like SDK's. Every now and than I come across some code that does not offer binaries, you have to build it yourself. They come with makefiles and as soon as I see the file "Makefile" I delete everything and search for an alternative. But today I want to find out how it works and understand why so many people use this horrible build system :)
So my knowledge so far:

Makefiles contain a set of instructions to build a particular program. Make is the program that reads the makefiles and builds the program based on the source files indicated by the makefile.

Questions i have:
- Make itself is not a compiler is it not? So what compiler is being used? How can you configure it?
- Lets say I download some source code that needs to be build first, it contains a Makefile. How do I proceed in Windows?
What programs do I need to download in order to build this code on Windows? I already downloaded GNUWin32, added the make to my system path but when I open cmd.exe and run the make command in the right directory I get an error (process_begin: CreateProcess(NULL, echo <etc etc> Please wait..., ...) failed. make (e=2): The system cannot find the file specified.).

Googleing doesn't really help me, neither did a search on gamedev. I heard something about cygwin, downloaded it but than I have to run some kind of Linux command screen which I don't understand too well. I also downloaded the gcc compiler, copied the files to the home directory and ran make inside this console, but than I got some other error again and I don't realy feel like using all this stuff, do people realy think this mess is any better than the goodworking convenient project files from visual studio?

I just can seem to figure out why people want to go through all this trouble to use makefiles instead of project files?
Are there any easy ways to build Makefile-projects in Windows? I hope anyone can push my in the right direction, all tutorials I can find on make and makefiles assume you use linux I guess.



02 January 2012 - 01:19 PM


I am trying to write a GUI for my game. I am using SFML for graphics.
I have already created some simple widgets, such as buttons. However, I'd like to have some more advanced widgets as well.
One of them includes "tabs", where I can click on like 4 different tabs, each with its own layout of widgets. And I want windows/dialog boxes that can be dragges, closed and perhaps minimized.

So, I came up with a design strategy and I was wondering whether people think it's ok to do it like this or if someone has a better idea.
Basicly, I will create a new class called GUIArea. This GUIArea can contain several widgets by composition. This GUIArea is a widget itself like any other widget with an Update() and Draw() function called by my GUIManager every frame. However, the widgets inside GUIArea are handled by this class itself and are only Updated and Drawed if the GUIArea IsVisible() returns true. This way, I can "switch on/off" the widgets by GUIArea as a group. GUITab is composed of several GUIArea's and that enable/disable them based on on which tab (basicly a radio button) is being active. GUIWindow works in the same way, it also contains one GUIArea that is enabled/disabled based on if the window is currently visible. The GUIWindow's draw function simple draws a rectangle and places a [x] button on the top right for closure, next it draws the widgets on top of it. The Update() function works in the same way. Whenever the window is being dragged, it will call the UpdatePosition(x,y) function that updates the position of all widgets in the window by the relative position in which the window has been dragged.

So, what about this design? Would this be fine or would it cause errors/performance problems?