Chào các anh chị, em đang học về SDL, em có đoạn code và bị lỗi :prototype for "bool game:: init does not match any in class
Anh chị giúp em với, em cám ơn.
#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED
#include <SDL2/SDL.h>
#include <windows.h>
using namespace std;
class game
{
public:
game(){};
~game(){};
void init()
{
r_running=true;
}
void render();
void update();
void handevents();
void clean();
bool running()
{
return r_running;
}
public:
bool r_running;
SDL_Window*Window;
SDL_Renderer*r_render;
};
bool game::init(const char*title,int xpos,int ypos,int width,int heigth,int flags)
{
if (SDL_Init(SDL_INIT_EVERYTHING)==0)
{
cout<<"SDL suggess";
Window=SDL_CreateWindow(title,xpos,ypos,width,heigth,flags);
if (Window!=0)
{
cout<<"window create suggess";
r_render=SDL_CreateRenderer(Window,-1,0);
if (r_render!=0)
{
cout << "render suggess";
SDL_SetRenderDrawColor(render,255,255,255,255);
}
else
{
cout<<"render fail";
return false;
}
}
else
cout<<"window init fail";
}
else
{
count<<"SDL fail";
}
count "init suggess";
r_running=true;
return true;
}
void game::render()
{
SDL_RenderClear(r_render);
SDL_RenderPresent(r_render);
}
void game::handevents()
{
SDL_Event event;
if(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_Quit():
r_running=false;
break;
default:
break;
}
}
}
void game ::clean()
{
count <<"clean game";
SDL_DestroyWindow(Window);
SDL_DestroyRenderer(r_render);
SDL_Quit()
}
#endif // GAME_H_INCLUDED