#include "main.h" void gravity(GameState *gameState) { gameState->man.y += gameState->man.dy; gameState->man.dy += GRAVEDAD; } int main(int argc, char *argv[]) { GameState gameState; SDL_Window *window = NULL; // Declare a window SDL_Renderer *renderer = NULL; // Declare a renderer SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2 gameState.man.x = 44; gameState.man.y = 100; gameState.man.dy = 0; gameState.man.dx = 0; gameState.man.w = 42; gameState.man.h = 53; gameState.salto = 0; gameState.man.facing_left = 0; for(int i = 0; i < 3; i++) { gameState.camara[i].x = i*43 + 1; gameState.camara[i].y = 1; gameState.camara[i].w = gameState.man.w; gameState.camara[i].h = gameState.man.h; } for (int i; i < NUM_CAJAS; i++) { gameState.suelo[i].x = i*44; gameState.suelo[i].y = 400; gameState.suelo[i].w = 44; gameState.suelo[i].h = 44; } gameState.suelo[9].x = 0; gameState.suelo[9].y = 356; gameState.suelo[8].x = 0; gameState.suelo[8].y = 312; //Create an application window with the following settings: window = SDL_CreateWindow("Game Window", // window title SDL_WINDOWPOS_UNDEFINED, // initial x position SDL_WINDOWPOS_UNDEFINED, // initial y position 640, // width, in pixels 480, // height, in pixels 0 // flags ); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if(window == NULL || renderer == NULL) { printf("SDL no pudo ejecutarse o no esta instalado"); } gameState.renderer = renderer; loadScreen(&gameState,renderer); // The window is open: enter program loop (see SDL_PollEvent) int done = 0; //Event loop while(!done) { //Check for events done = processEvents(window, &gameState); ///Ejecutar gravedad gravity(&gameState); ///Deteccion de Coliciones collisionDetect(&gameState); if(gameState.i / 3 >= 3) gameState.i = 0; //Render display doRender(renderer, &gameState); if(gameState.man.walking == 1) { gameState.i++; gameState.man.walking = 0; } else gameState.i = 0; } SDL_DestroyTexture(gameState.player); // Close and destroy the window SDL_DestroyWindow(window); SDL_DestroyRenderer(renderer); // Clean up SDL_Quit(); return 0; }