Skip to content

Instantly share code, notes, and snippets.

@Introscopia
Introscopia / SDL_Text.c
Created March 31, 2024 23:36
Text rendering for SDL without fonts or any other dependencies.
#include "SDL_Text.h"
void SDL_RenderChar( SDL_Renderer *R, char C, float scale, float x, float y ){
switch(C){
case '!':
SDL_RenderFillRectF(R, &(SDL_FRect){(2*scale)+x, (2*scale)+y, 4*scale, 3*scale} );
SDL_RenderFillRectF(R, &(SDL_FRect){(3*scale)+x, (1*scale)+y, 2*scale, 1*scale} );
SDL_RenderFillRectF(R, &(SDL_FRect){(3*scale)+x, (5*scale)+y, 2*scale, 2*scale} );
SDL_RenderFillRectF(R, &(SDL_FRect){(3*scale)+x, (8*scale)+y, 2*scale, 2*scale} );
break;
@Introscopia
Introscopia / MGT.c
Last active March 10, 2024 17:01
Statistical study for a "top X d6 out of Y >= CT" game mechanic.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <stdarg.h>
#include "multidimensional.h"
/* "MAXIMUM GREATER THAN" */
@Introscopia
Introscopia / dice_poker.c
Last active March 10, 2024 17:00
Statistical study for a 6d6-based "Dice Poker"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include "multidimensional.h"
int compare_ints (const void * a, const void * b){
@Introscopia
Introscopia / spiral_2048.pde
Last active December 15, 2023 16:39
spiral-2048
// reverse engineering of:
// https://twitter.com/kitasenjudesign/status/1732795192934338954
int W = 32;
float e;
int [][] values;
int [][] copy;
int cx, cy, dir;
boolean spiraling = true;
int[] dx = { 1, 0, -1, 0 };
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
typedef int bool;
typedef struct{
/*
Testing Binary tree searches against straight floating point multiplication
specifically for the purpose of placing coordinates into 'zones' (grid cells)
*/
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <string.h>
@Introscopia
Introscopia / approximate_heading.c
Created March 4, 2023 10:18
Calculate the approximate heading of a 2D vector at 3 different levels of precision using binary trees
typedef struct vec2d_struct{
double x, y;
} vec2d;
double v2d_rough_heading8(vec2d v){
if( v.x > 0 ){
if( v.y > 0 ){
if( v.x < v.y ) return 1.1780972450961724;// 3/8 PI
else return 0.3926990816987241;// 1/8 PI;
}
@Introscopia
Introscopia / mazes.c
Created December 27, 2022 02:54
maze generation
#define UP 1
#define RIGHT 2
#define DOWN 4
#define LEFT 8
#define DEAD 16
#define MASKED 32
#define white 0xffffffff
#define black 0xff000000
#define transparent 0x00000000
float theta;
boolean over;
void setup() {
size(400, 400);
theta = HALF_PI;
over = true;
}
void draw() {
background(0);
/*
Simple Binary Clock in Processing.
Relogio Binario simples em Processing.
*/
float tx, ty, dx, dy;
void setup() {
size(400, 350);
tx = width / 9f;
ty = height / 3f;