Hi!
I am newbie in programming. I would create simple turned game on android. Unfortunately I stopped my work on create a struct of program. I not understand why no detect finger events. I programming without console interpreter (ide on android i waiting for update)
Fragment my code is here:
SDL_Window *window;
SDL_Event event;
vec2i screenSize;
camera *cam;
Engine *engine;
Map *map;
touch *touches;
void programInit()
{
screenSize = vec2i(2640, 1200);
SDL_Init(SDL_INIT_EVERYTHING);
// We use OpenGL ES 2.0
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// We want at least 8 bits per color
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
window = SDL_CreateWindow(
"myGame",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
screenSize.x, screenSize.y,
SDL_WINDOW_OPENGL
);
// We will not actually need a context created, but we should create one
SDL_GL_CreateContext(window);
}
int main(int argc, char *argv[])
{
programInit();
triangle_init(); // init to drawTriangles
initTournament(); // init Game
while (isTournament != false)
{
while (SDL_PollEvent(&event))
{
vec2f pos;
// touches
if(event.type == SDL_FINGERDOWN )
{
pos.x = event.tfinger.x;
pos.y = event.tfinger.y;
touches ->add(pos, screenSize);
cam->move(touches->getDelta());
}
else if(event.type == SDL_FINGERMOTION)
{
pos.x = event.tfinger.x;
pos.y = event.tfinger.y;
touches ->add(pos, screenSize);
cam->move(touches->getDelta());
}
else if(event.type == SDL_FINGERUP)
{
pos.x = event.tfinger.x;
pos.y = event.tfinger.y;
touches ->add(pos, screenSize);
cam->move(touches->getDelta());
}
};
engine->start();
map->draw(engine);
};
programEnd();
return 0;
}