Experimento con emscripten y SDL
#ifndef ENGINE_H1#define ENGINE_H23#include <SDL2/SDL.h>4#include <SDL2/SDL_image.h>5#include <SDL/SDL_ttf.h>6#include <emscripten.h>7#include <stdbool.h>89#include "input_processor.h"10#include "sprite.h"11#include "actor.h"1213typedef struct engine engine;1415typedef enum DIRECTION16{17DIRECTION_N,18DIRECTION_E,19DIRECTION_S,20DIRECTION_W21} DIRECTION;2223enum24{25SAND_TEXTURE,26SPRITES_TEXTURE,27STATUS_BAR_TEXTURE,28NUM_TEXTURES29};3031typedef enum SPRITES_DECALS32{33TAIL_S,34TAIL_W,35HEAD_N,36HEAD_E,37BODY_SE,38BODY_SW,39BODY_NW,40BLANK,41TAIL_E,42TAIL_N,43HEAD_W,44HEAD_S,45BODY_N,46BODY_E,47BODY_NE,48APPLE,49NUM_SPRITES_DECALS50} SPRITES_DECALS;5152enum {53MAX_SNAKE_SEGMENTS = 50,54TILE_DIMENSION = 40,55STATUS_BAR_HEIGHT = 2, // given in tiles56STATUS_TEXT_SIZE = 3057};5859#define STATUS_TEXT_FONT "assets/edosz.ttf"6061#define INITIAL_SNAKE_SECONDS_PER_UPDATE 0.262#define MINIMUM_SNAKE_SECONDS_PER_UPDATE 0.00563#define SNAKE_SECONDS_PER_UPDATE_INCREMENT 0.016465#include "apple_actor.h"66#include "snake_actor.h"67#include "background_actor.h"6869struct engine70{71unsigned int fps;72unsigned int current_frame;73SDL_Window *window;74SDL_Renderer *renderer;75unsigned int w;76unsigned int h;7778Uint32 start_time;79bool should_start_logic_loop;80unsigned int whole_frames_to_do;8182actor_list *render_list;83actor_list *logic_list;8485SDL_Texture *textures[NUM_TEXTURES];86decal sprites_decals[NUM_SPRITES_DECALS];87decal sand_decal;8889apple_actor apple_actor;90background_actor background_actor;91// status_bar_actor status_bar_actor;92snake_actor snake_actor;9394unsigned int score;95unsigned int *occupied_gridpoints;96int grid_width;97int grid_height;98};99100engine eng;101102engine *engine_init(103unsigned int w,104unsigned int h);105106void engine_destroy();107108void engine_start();109110void engine_reset();111112void engine_get_grid_coord(const int *pixel_coord, int *grid_coord);113void engine_get_pixel_coord(const int *grid_coord, int *pixel_coord);114void engine_apply_boundary_conditions(int *grid_coords);115116#endif117118119