Skip to content

Instantly share code, notes, and snippets.

View Ratstail91's full-sized avatar

Kayne Ruse Ratstail91

View GitHub Profile
@Ratstail91
Ratstail91 / network_queue.cpp
Last active December 18, 2015 13:29
I want to push a network packet onto the deque in networkQueue(), and pop the first packet in getPacket()
#include "network_queue.hpp"
#include "service_locator.hpp"
#include "udp_network_utility.hpp"
#include "SDL/SDL_thread.h"
#include <deque>
static SDL_sem* lock = SDL_CreateSemaphore(1);
@Ratstail91
Ratstail91 / vector2.hpp
Last active December 19, 2015 07:29
Vector2 hopefully reduced to a POD type. I got this definition of a C++ POD from Wikipedia. A friend says it shouldn't have the functions like Length(), etc. but my compiler seems to allow it, and Wikipedia doesn't say it can't have them. I'm still not sure if this is actually a POD.
/* Copyright: (c) Kayne Ruse 2013
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
@Ratstail91
Ratstail91 / gist:5975662
Created July 11, 2013 13:57
oh dear god, what have I done?
void openCustomLibraries(lua_State* L) {
//-------------------------
// Define the map library for lua
//-------------------------
//push the initial table
lua_newtable(L);
lua_pushcfunction(L, [](lua_State* l) -> int {
//require 4 parameters
@Ratstail91
Ratstail91 / USBBackup.bat
Created August 10, 2013 08:26
My first personal utility "program". I used this to update changes to a USB I used to carry around with me. It requires that the USB in question has a copy of _this_ file on it, and the "backup" folder needs to exist, to prevent backing up the wrong USB. This also copies changes to the "master" version into the process as well. The "master" copy…
@ECHO OFF
ECHO USB Backup Utility designed by Kayne Ruse.
SET folder=USBBackup
ECHO Instructions
ECHO.
ECHO 1) There must be a folder called "%folder%" in this directory.
ECHO 2) The USB must have a copy of this file in it's root directory.
ECHO.
int main(int, char**) {
try {
//set up
RegionPager pager;
pager.SetWidth(40*32);
pager.SetHeight(40*32);
pager.SetOnNew([](Region* const ptr){
printf("(%d, %d)\n", ptr->GetX(), ptr->GetY());
@Ratstail91
Ratstail91 / slither.txt
Created October 13, 2013 04:06
The slither algorithm, as outlined in this video: http://youtu.be/Gx5D09s5X6U This is not a valid language, it's just a simple pseudocode outline.
enum Turn:
left, right, straight
end
enum Direction:
north, south, east, west
end
class Segment:
Segment* next = null,
#config
INCLUDES=
CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES))
LIB=-lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
#source
SRC=$(wildcard *.cpp)
#objects
OBJDIR=obj
#include <iostream>
#include <cstring>
using namespace std;
union Foo {
enum class Type {
INT,
FLOAT
}type;
//this checks the pseudo-distance from the edge of the screen
function CheckDistance(region):
//locations relative to the camera
x = region.x - camera.x
y = region.y - camera.y
//if the region is visible, return 0
if (-pager.w < x < screen.w) return 0
if (-pager.h < y < screen.h) return 0
@Ratstail91
Ratstail91 / dump
Created April 11, 2014 15:28
Across is the attack value, and down the left shows the defence value.
10 20 30 40 50 60 70 80 90 100
10 20 61 85 145 169 199 227 301 340 369
20 10 56 92 122 148 164 195 250 266 298
30 7 37 63 91 122 171 219 255 300 337
40 1 30 61 92 111 178 222 268 280 296
50 1 21 65 105 125 137 190 209 296 275
60 1 12 54 94 119 138 165 198 285 244
70 1 1 34 47 78 163 154 187 247 293
80 1 1 17 44 102 122 157 232 254 232