View snake.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>A simple Snake Clone</title> | |
</head> | |
<body> | |
<canvas id="game" width="250" height="250" style="background: #000"></canvas> | |
<script> | |
const TIMEOUT = 125 | |
const SIZE = 25 |
View snake.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <SDL2/SDL.h> | |
#define TIMEOUT 150 | |
#define SIZE 25 | |
#define BOARD_COLS 10 | |
#define BOARD_ROWS 10 | |
#define BOARD_SIZE (BOARD_COLS * BOARD_ROWS) |
View game.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Testado no MinGW64 | |
// gcc -Wall -Wextra -Wpedantic -Wno-unused-parameter game.c `sdl2-config --cflags --libs` | |
#include <SDL.h> | |
SDL_Window* window; | |
SDL_Renderer* renderer; | |
SDL_bool quit = SDL_FALSE; | |
// A tecla está pressionada? |
View test.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Testado no MinGW64 | |
// gcc -Wall -Wextra -Wpedantic -Wno-unused-parameter game.c `sdl2-config --cflags --libs` | |
#include <SDL.h> | |
SDL_bool quit = SDL_FALSE; | |
// A tecla está pressionada? | |
SDL_bool isKeyPressed(int key) { | |
return SDL_GetKeyboardState(NULL) [key]; | |
} |
NewerOlder