Skip to content

Instantly share code, notes, and snippets.

View wldomiciano's full-sized avatar

Wellington Domiciano wldomiciano

View GitHub Profile
@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 / 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.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 / 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];
}