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
// A portable "coroutine"-like thing for implementing FSM and behavior-cycles. | |
// | |
// Original implementation by Noel Berry. | |
// See: https://gist.github.com/NoelFB/7a5fa66fc29dd7ed1c11042c30f1b00e | |
// | |
// Routine is a set of macros useful to implement Finite State Machine type of | |
// behaviors. It works really well for simpler behaviors with loops or cycles, | |
// and works especially well for anything resembling a cutscene. | |
// | |
// The macros here are wrappers around a switch statement. All of the `rt_***` |
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
/** | |
* 2D spatial hash implementation. | |
* | |
* The spatial hash is really good at representing grids in games. It only stores elements | |
* of the grid where items are inserted into the spacial hash, making it a memory-efficient | |
* option for grid games with lots of empty space between tiles/entities. | |
* | |
* Spatial hash queries are extremely fast for small queries covering low surface areas. | |
* | |
* Spatial hashes breakdown when queries cover large surface areas. This is because each |
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
-- Piorirty queue, used for implementing other algorithms such as | |
-- prioritized message queues, or the A* algorithm. | |
-- | |
-- Create a new priority q like so: | |
-- | |
-- q = prio_q() | |
-- | |
-- Add elements to the queue, each has a cost associated. THe cost is | |
-- used to sort the elements, where the lowest cost is considered the | |
-- highest priority (first out when pop() is called). |
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
WHAT IS THIS? | |
I get asked a lot about recommendations for self-taught or self-learning to become professional developer, so I | |
am slowly working on a curriculum someone could follow. If finished in earnest, you'd be at roughly bachelor degree | |
level of competence without any holes in your education. If anyone is interested, please do take a look and provide | |
feedback! The format is to collate really high quality links to references organized by major topic and sub-categories. | |
By design this is C/C++ centric. This encourages the learning of low level details and fundamental knowledge that | |
transcends technological fads, ensuring the knowledge won't ever go out of date, easily translatable to other higher | |
level languages, frameworks, granting sustainable flexibility in career potential. |
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
#ifndef _CRT_SECURE_NO_WARNINGS | |
# define _CRT_SECURE_NO_WARNINGS | |
#endif | |
#ifndef _CRT_NONSTDC_NO_DEPRECATE | |
# define _CRT_NONSTDC_NO_DEPRECATE | |
#endif | |
#include <vector> | |
// ------------------------------------------------------------------------------------------------- |
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
#ifndef _CRT_SECURE_NO_WARNINGS | |
# define _CRT_SECURE_NO_WARNINGS | |
#endif | |
#ifndef _CRT_NONSTDC_NO_DEPRECATE | |
# define _CRT_NONSTDC_NO_DEPRECATE | |
#endif | |
#include <vector> | |
// ------------------------------------------------------------------------------------------------- |
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
// Polymorphic hashtable API in C | |
// | |
// We get value semantics here for hset and hget (see comments below). | |
// An extra layer of indirection is internally used so we can sort {k,v} pairs, e.g. for priority queue. | |
// The main trick is the use of comma in C. Any statement in C takes on the value of the expression | |
// in the final comma, not any of the prior. We can use that to "return" a value in `hget` while running | |
// a few expressions beforehand. Since the user type is a pointer to a value we get polymorphism by | |
// the indirection or array operator `*h` or `h[0]`. | |
// | |
// Original inspired from these resources by Per Vognsen and Micha Mettke |
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
// Embedded some small file here. | |
int g_some_file_sz = 64; | |
unsigned char g_some_file_data[64] = { | |
0x10,0xaa,0x98,0xe0,0x10,0x5a,0x3e,0x63,0xe5,0xdf,0xa4,0xb5,0x5d,0xf3,0x3c,0x0a, | |
0x31,0x5d,0x6e,0x58,0x1e,0xb8,0x5b,0xa4,0x4e,0xa3,0xf8,0xe7,0x55,0x53,0xaf,0x7a, | |
0x4a,0xc5,0x56,0x47,0x30,0xbf,0xdc,0x22,0xc7,0x67,0x3b,0x23,0xc5,0x00,0x21,0x7e, | |
0x19,0x3e,0xa4,0xed,0xbc,0x0f,0x87,0x98,0x80,0xac,0x89,0x82,0x30,0xe9,0x95,0x6c | |
}; | |
// Creates an array like the one above. |
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
#ifndef ROUTINE_H | |
#define ROUTINE_H | |
#include <stdint.h> | |
// A portable "coroutine"-like thing for implementing FSM and behavior-cycles. | |
// | |
// Original implementation by Noel Berry. | |
// See: https://gist.github.com/NoelFB/7a5fa66fc29dd7ed1c11042c30f1b00e | |
// |
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
#ifndef _CRT_SECURE_NO_WARNINGS | |
# define _CRT_SECURE_NO_WARNINGS | |
#endif | |
#ifndef _CRT_NONSTDC_NO_DEPRECATE | |
# define _CRT_NONSTDC_NO_DEPRECATE | |
#endif | |
#include <vector> | |
// ------------------------------------------------------------------------------------------------- |
NewerOlder