Skip to content

Instantly share code, notes, and snippets.

struct Entity { id: int }
struct World { entities: Vec<Entity> }
impl World {
fn get_entities(&self) -> Vec<Entity> {
return self.entities; // KABOOM
}
}
@shakesoda
shakesoda / main.rs
Last active February 16, 2017 12:20
// Apparently, this needs to be *before* I actually import the fucking mod
// wat.
use player::*;
mod player;
fn main() {
let mut stats = vec![
Stat::new("HP".to_string(), player::default_advancer_fn),
Stat::new("SP".to_string(), player::default_advancer_fn),
Stat::new("ATK".to_string(), player::default_advancer_fn),
mod player {
type AdvancerFn = fn(exp: uint) -> uint;
pub struct Stat {
pub skill: String,
pub exp: uint,
pub level: uint,
advancer: AdvancerFn,
}
// insert exp, receive current level
@shakesoda
shakesoda / timer.h
Last active October 25, 2015 21:16
simple high resolution timer w/SDL2
/* USAGE:
* Timer foo; // Start the timer
* const TimeData &time = foo.touch(); // Update and return TimeData (delta being the time since last touch)
* const TimeData &time_peek = foo.peek(); // returns current TimeData only updating the current time (does not reset!)
* SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION
*
* I haven't actually tested peek, but it looks right... */
#pragma once
#include <SDL.h>
@shakesoda
shakesoda / gist:9506865
Last active August 29, 2015 13:57
Skullgirls command line options (the probably useful/public looking ones, at least)
-c config_file
-defaultkeys
-log (enable logging to a file)
-fs (fullscreen)
-fw (fullscreen windowed)
-res blahxblah (set screen resolution)
-sc 1.0 (screen scale)
-ignorefocus (take input in the background)
-vjoyfix (always poll joystick pov hats? I don't know the context of this. irc says ps3 controllers)
-noonlineconfirm (disable confirm message when picking character online)
@shakesoda
shakesoda / thing.cpp
Created February 20, 2014 20:46
sdl example for missingno
#include <GLXW/glxw.h>
#include <SDL2/SDL.h>
class DisplaySystem {
public:
DisplaySystem() {
window = SDL_CreateWindow(
"thingy",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
1280, 720,
@shakesoda
shakesoda / gist:8552233
Created January 22, 2014 01:57
Tegra 3 GLES extensions
GL_NV_platform_binary
GL_OES_rgb8_rgba8
GL_OES_EGL_sync
GL_OES_fbo_render_mipmap
GL_NV_depth_nonlinear
GL_NV_draw_path
GL_NV_texture_npot_2D_mipmap
GL_OES_EGL_image
GL_OES_EGL_image_external
GL_OES_vertex_half_float
local _lfsgdi = love.filesystem.getDirectoryItems or love.filesystem.enumerate
function love.filesystem.getDirectoryItems(dir, callback)
if not callback then
return _lfsgdi(dir)
else
local files = _lfsgdi(dir)
for i, path in ipairs(files) do
callback(path)
end
end
@shakesoda
shakesoda / ouya_mappings.txt
Created January 9, 2014 05:32
Ouya controller mappings (Android + SDL2 + Love2D)
D-Pad Up 1
D-Pad Down 2
D-Pad Left 3
D-Pad Right 4
O 6
U 9
Y 10
A 7
@shakesoda
shakesoda / waveframe.rsm
Created January 8, 2014 19:22
WaveFrame's RS format spec
waveframe's .rs format
----------------------
Waveframe's implementation of the .rs format is nothing more than a specific
definition of what Waveframe looks for. It may or may not match shakesoda's
wishes for the format, though it tries to stay as close to the spec as possible.
=={ Standard Sections }==
These standard sections may include nonstandard elements.
See each section's intro text for more information.