I'm new to programming and I'm trying to follow a book I bought... but even following the book's code I can't make the program to run.
======== (main.cpp) ========
#include "Game.h"
Game* g_game = 0;
int main(int argc, char* argv[])
{
g_game = new Game();
g_game -> init("Titulo", 100, 100, 800, 600, 0);
while(g_game->running())
{
g_game->handleEvents();
g_game->update();
g_game->render();
}
g_game->clean();
return 0;
}
======== (Game.cpp) ========
#include "Game.h"
using namespace std;
bool Game::init(const char* titulo, int xpos, int ypos, int altura, int largura, int flags)
{
if (SDL_Init(SDL_INIT_EVERYTHING) == 0)
{
m_pWindow = SDL_CreateWindow(titulo, xpos, ypos, altura, largura, flags);
if (m_pWindow != 0)
{
g_pRenderer = SDL_CreateRenderer(m_pWindow, -1, 0);
if(m_pRenderer != 0)
{
SDL_SetRenderDrawColor(m_pRenderer, 255, 255,255, 255);
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
m_bRunning = true; //Começar o loop
return true;
}
======== (Game.h) ========
#ifndef _Game_
#define _Game_
#include <SDL.h>
class Game
{
public:
Game(){}
~Game(){}
void init() {m_bRunning = true; }
void render(){}
void update() {}
void handleEvents(){}
void clean(){}
bool running() { return m_bRunning; }
private:
SDL_Window* m_pWindow;
SDL_Window* m_pRenderer;
bool m_bRunning;
};
#endif /* defined(_Game_) */
But when I'm trying to compile I got the following error:
[Error] no matching function for call to 'Game::init(const char [7], int, int, int, int, int)'
[Note] candidate is: In file included from main.cpp
[Note] void Game::init()
[Note] candidate expects 0 arguments, 6 provided
Can someone help me and explain why did this happens? I read other topics about the missing of a default construct, but couldn't figure it out.