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]; | |
} |
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? |
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) |
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 |
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
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.*; | |
class Game extends JPanel implements ActionListener { | |
final int TIMEOUT = 125; | |
final int SIZE = 25; | |
final int BOARD_COLS = 10; | |
final int BOARD_ROWS = 10; | |
final int BOARD_SIZE = (BOARD_COLS * BOARD_ROWS); |
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
set SDL2=\path\to\sdl | |
@rem Use %SDL2%\lib\x64 for x64 builds | |
set SDL2LIB=%SDL2%\lib\x86 | |
@rem Put on PATH the DLLs | |
set PATH=%PATH%;%SDL2LIB% | |
@rem Alternative subsystem: /SUBSYSTEM:WINDOWS | |
cl yourcode.c /OUT yourprogram /I %SDL2%\include /LINK /LIBPATH:%SDL2LIB% SDL2.lib SDL2main.lib /SUBSYSTEM:CONSOLE |
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 com MinGW64: | |
// gcc -Wall -Wextra -Wpedantic -Wno-unused-parameter test1.c `sdl2-config --cflags --libs` -lSDL2_ttf | |
#include <SDL.h> | |
#include <SDL_ttf.h> | |
SDL_Window *window; | |
SDL_Surface *surface; | |
TTF_Font *font; | |
#define MAX_LENGTH 1024 |
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 com MinGW64: | |
// gcc -Wall -Wextra -Wpedantic -Wno-unused-parameter test0.c `sdl2-config --cflags --libs` -lSDL2_ttf | |
#include <SDL.h> | |
#include <SDL_ttf.h> | |
SDL_Window *window; | |
SDL_Surface *surface; | |
TTF_Font *font; | |
int main(int argc, char *argv[]) { |
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 com MinGW64: | |
// gcc -Wall -Wextra -Wpedantic -Wno-unused-parameter test1.c `sdl2-config --cflags --libs` -lSDL2_ttf | |
#include <SDL.h> | |
#include <SDL_ttf.h> | |
SDL_Window *window; | |
SDL_Renderer *renderer; | |
TTF_Font *font; | |
#define MAX_LENGTH 1024 |
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 <SDL.h> | |
SDL_Window* window; | |
SDL_Renderer* renderer; | |
void drawCircle(int xc, int yc, int x, int y) { | |
SDL_RenderDrawPoint(renderer, xc + x, yc + y); | |
SDL_RenderDrawPoint(renderer, xc - x, yc + y); | |
SDL_RenderDrawPoint(renderer, xc + x, yc - y); |
OlderNewer