Skip to content

Instantly share code, notes, and snippets.

View Ratstail91's full-sized avatar

Kayne Ruse Ratstail91

View GitHub Profile
#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
+ ---------------------------------------------------------------------------- +
| TODOS @ Sunday 20 April 2014 01:41 |
| 124 files scanned |
+ ---------------------------------------------------------------------------- +
## NOTE (4)
1. region_pager.hpp:53 don't change the sizes mid-program, it will cause issues
2. raster_font.cpp:43 This class can only take a raster font with 16*16 characters, and the
3. server_application.cpp:109 I might need to rearrange the init process so that lua & SQL can interact
4. server_application.cpp:300 assigning each field one-by-one so adding or moving a field doesn't break this code
diff --git a/common/network/serial.cpp b/common/network/serial.cpp
index 2aa88cb..5130841 100644
--- a/common/network/serial.cpp
+++ b/common/network/serial.cpp
@@ -21,7 +21,7 @@
*/
#include "serial.hpp"
-#include "map_generator.hpp"
+#include "map_allocator.hpp"
@Ratstail91
Ratstail91 / gist:a1facb724de18afc08ed
Created May 5, 2014 12:05
Me familiarizing myself with SQL. Good god this shit is irritating.
#include "sqlite3/sqlite3.h"
#include <iostream>
#include <string>
using namespace std;
const char* command = "CREATE TABLE accounts(username VARCHAR(100)); INSERT INTO accounts VALUES(\"Ratstail91\"); SELECT * FROM accounts;";
int main(int argc, char* argv[]) {
//check for collisions
for (int i = -6; i < 6; ++i) {
for (int j = -6; j < 6; ++j) {
Vector2 wallPoint = {
snapToBase(32.0, character.GetOrigin().x),
snapToBase(32.0, character.GetOrigin().y)
};
wallPoint.x += i * 32;
wallPoint.y += j * 32;
@Ratstail91
Ratstail91 / Container.h
Created July 27, 2014 04:31
This is a failed application for a game development job. I'm posting it here to display it on my blog.
/* Rules
* Write the implementation in Container.h, do not change ContainerTest.cpp.
* No memory allocation is allowed (implicit or explicit).
* Use of the STL (Standard Template Library) is not allowed.
* You can add member functions and variables.
* All storage management data structures must use the buffer memory, not additional member variables.
* You must test your solution in debug (or any configuration that have asserts enabled) so that the requirements are tested.
* Your solution must be efficient and scalable.
* Try to maximize the number of elements in the given buffer, and also perform well whether you have ten elements or thousands.
* Optionally, you can uncomment the _ADVANCED macro at the top of ContainerTest.cpp and implement the sorting algorithm.
@Ratstail91
Ratstail91 / hash_coordinates.cpp
Last active August 29, 2015 14:04
A simple hashing function, to emulate a procedural number generator for perlin noise.
unsigned hashuint(unsigned x) {
//found this on stack overflow
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = ((x >> 16) ^ x);
return x;
}
unsigned hashCoordinates(unsigned seed, int x, int y) {
//default values when 0 is a parameter
@Ratstail91
Ratstail91 / epic_quicksort.cpp
Created September 27, 2014 06:50
Stack-based, inplace, recursive quicksort. I'm quite proud of this, I think it's quite clever. Odd numbers are sorted to the front, BTW.
int CompareOddEven(int lhs, int rhs)
{
//lhs < rhs ? -1, 1, 0
//odd vs even
if (lhs % 2 == 1 && rhs % 2 == 0) {
return -1;
}
if (lhs % 2 == 0 && rhs % 2 == 1) {
return 1;