Jump to content

  • Log In with Google      Sign In   
  • Create Account


Dennisvb

Member Since 22 Sep 2012
Offline Last Active Apr 23 2013 01:44 PM

Topics I've Started

Loading resources location.

13 April 2013 - 03:52 PM

Let's say I am making a game using Slick2d and eclipse and have a file player.png which I want to load. I have 2 folders: one source folder and one resource folder. How would I do this, where should I put the resource folder?

Staying motivated.

05 March 2013 - 01:38 PM

I really want to be good at game programming, but I keep getting distracted. Any tips?

Game instantly quits.

03 March 2013 - 08:43 AM

This is my Game.cpp file:

#include "Game.h"

bool quit = false;

// Starts the game
void Game::Start() {

	if ( Game::Init() == 1 ) {
			std::cout << SDL_GetError();
			quit = true;
		}
	
	while( !quit ) {
		if ( Game::Update() == 1 ) {
			std::cout << SDL_GetError();
			quit = true;
		}

		if ( Game::Draw() == 1 ) {
			std::cout << SDL_GetError();
			quit = true;
		}
	}

	SDL_Quit();
}

int Game::Init() {
	SDL_Init( SDL_INIT_EVERYTHING );

	return 0;
}

int Game::Update() {

	while (SDL_PollEvent( &event ) ) {
		if ( event.type == SDL_QUIT ) {
			quit = true;
		}
	}

	return 0;
}

int Game::Draw() {

	return 0;
}

 

Game::Start(); is called from main.cpp, but it quits instantly now. I hope somebody can help!

Thanks.


[SOLVED] 'Game' does not compile.

03 March 2013 - 06:21 AM

Hello,

 

I have my main.cpp:

#include "Game.h"

int main( int argc, char* args[] )
{
	Game game;
	game.Start();

	return 0;
}

 

My Game.cpp:

#include "Game.h"

class Game
{
	// Starts the game
	void Game::Start()
	{
		SDL_Init( SDL_INIT_EVERYTHING );

		SDL_Quit();
	}
};

 

And my Game.h:

#ifndef _GAME_H_
#define _GAME_H_

#include "SDL.h"
#include "SDL_image.h"

class Game
{
public:
	void Game::Start();
};

#endif // _GAME_H_

 

But when I compile I get this error:

1>------ Build started: Project: Pong Clone, Configuration: Debug Win32 ------
1>  main.cpp
1>  Game.cpp
1>c:\users\dennis\documents\visual studio 2012\projects\pong clone\pong clone\game.cpp(4): error C2011: 'Game' : 'class' type redefinition
1>          c:\users\dennis\documents\visual studio 2012\projects\pong clone\pong clone\game.h(8) : see declaration of 'Game'
1>  Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

How can I fix this?


Different source files.

01 March 2013 - 02:44 PM

Hello,

I want to have my Init, Update, Draw and CleanUp functions all in different source files, so when the game gets larger I don't end up with long compiling times. Do I need to put every function in a different class, or do I create a class called for example Game and define the functions in different source files like this: Game::Init() etc.?
Thanks,
Have a nice day!

PARTNERS