Skip to content

Instantly share code, notes, and snippets.

View wldomiciano's full-sized avatar

Wellington Domiciano wldomiciano

View GitHub Profile
@wldomiciano
wldomiciano / test.c
Last active November 6, 2017 16:15
Demonstração das funções para lidar com eventos de teclado usando SDL 2 com logs no console
// 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];
}
@wldomiciano
wldomiciano / snake.html
Created April 22, 2018 20:36
A simple Snake clone implementation in JavaScript
<!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
@wldomiciano
wldomiciano / snake.c
Last active April 22, 2018 20:36
A simple Snake clone implementation in C with SDL 2
#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)
@wldomiciano
wldomiciano / snake.java
Created April 22, 2018 20:49
A simple Snake clone implementation in Java
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);
@wldomiciano
wldomiciano / compile.bat
Last active September 10, 2018 17:15
Comando para compilar um programa usando SDL 2 com o CL, o compilador do MSBuild
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
@wldomiciano
wldomiciano / sdl2-tff-exemplo-com-renderer.c
Created September 12, 2018 18:59
Exemplo usando SDL 2 com SDL_ttf usando renderer
// 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
@wldomiciano
wldomiciano / sdl2-ttf-exemplo-com-window-surface.c
Last active September 12, 2018 19:00
Exemplo usando SDL 2 com SDL_ttf usando window surface
// 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
@wldomiciano
wldomiciano / sdl2-ttf-basico.c
Last active September 12, 2018 19:01
Exemplo básico usando SDL 2 com SDL_ttf
// 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[]) {
// compiles with
// gcc vector.c -Wall -Wextra -Wpedantic `sdl2-config --cflags --libs` -lm
#include <SDL.h>
#include <math.h>
const double PI = 3.14159265358979323846264338327950288;
typedef struct {
double x, y;
@wldomiciano
wldomiciano / install-vscode-and-chrome.sh
Last active August 31, 2019 23:15
Script para instalar os Visual Studio Code e o Google Chrome no Ubuntu
#!/usr/bin/env sh
# Baixa a chave da Microsoft
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
# Baixa a chave do Google
wget -qO- https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
# Move a chave da Microsoft pro lugar certo e remove arquivo temporário
sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/ && rm packages.microsoft.gpg