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
use std::{ | |
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, | |
time::{Duration, Instant}, | |
}; | |
use sdl2::{event::Event, rect::Rect, render::WindowCanvas, Sdl}; | |
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] | |
pub struct Vec2 { | |
pub x: i32, |
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
use sdl2::{event::Event, keyboard::Keycode}; | |
use slappy::{Colour, Draw, Input, Loop, TickState, Vec2}; | |
#[derive(Default)] | |
struct PongInput { | |
player_1_up: bool, | |
player_1_down: bool, | |
player_2_up: bool, | |
player_2_down: bool, | |
} |
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
use std::cell::UnsafeCell; | |
use std::sync::atomic::{spin_loop_hint, AtomicBool, AtomicU32, Ordering}; | |
use std::sync::{Barrier, Mutex}; | |
use std::ops::{Deref, DerefMut}; | |
use std::thread; | |
use parking_lot; | |
struct LockInner(AtomicBool); | |
const LOCKED: bool = true; |
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 "ring-buffer.h" | |
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
RingBuffer *rb_new(size_t size) | |
{ | |
RingBuffer *buf = malloc(sizeof(*buf)); | |
assert(buf != NULL); |
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 <elfutils/libdwfl.h> | |
#define UNW_LOCAL_ONLY | |
#include <libunwind.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdarg.h> | |
#include <unistd.h> | |
#include <errno.h> |
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
use std::fs::File; | |
use std::io::BufWriter; | |
use std::io::Write as IoWrite; | |
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; | |
use std::path::Path; | |
use rand::{Rng, SeedableRng}; | |
use rand_distr::{Distribution, UnitDisc, UnitSphere}; | |
use rand_pcg; |
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
let mapleader="," | |
" Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
call plug#begin('~/.local/share/nvim/plugged') | |
Plug 'godlygeek/tabular' | |
Plug 'rust-lang/rust.vim' | |
Plug 'ctrlpvim/ctrlp.vim' |
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
local sdl = require 'SDL' | |
local image = require 'SDL.image' | |
local ttf = require 'SDL.ttf' | |
local table, math, string = table, math, string | |
local status, err = sdl.init { | |
sdl.flags.Video | |
} | |
if not status then |
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
local sdl = require 'SDL' | |
local image = require 'SDL.image' | |
local ttf = require 'SDL.ttf' | |
local table, math, string = table, math, string | |
local status, err = sdl.init { | |
sdl.flags.Video | |
} | |
if not status then |
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
local function clear_tile_teams() | |
for i = 1, conf_map_num do | |
local tile = g_map[i] | |
local tile_type = tile.tile_type | |
if tile_type ~= 'water' and | |
tile_type ~= 'bridge' and | |
tile_type ~= 'rocks' and | |
tile_type ~= 'building' then | |
tile.team = nil | |
end |