Skip to content

Instantly share code, notes, and snippets.

View dmoa's full-sized avatar

Stan Osipenko dmoa

View GitHub Profile
{
// } // {
"git.enabled": false,
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": false,
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"workbench.editor.showIcons": false,
void Bullets::Update(Enemies* enemies) {
for (int i = 0; i < MAX_BULLETS; i++) {
Bullet* b = & bullets[i];
if (b->unused) continue;
// Bullet will be deleted because it exits screen or collides.
// If we're out of bounds, fuck the death animation if there is one because
// nobody's going to see an off screen death animation.
from memcache import Client
from time import time
n = 100000
def benchtime(fn):
oldtime = time()
fn()
return time() - oldtime
mc = Client(['127.0.0.1:11211'])
@dmoa
dmoa / SDL_Setup.txt
Last active January 12, 2022 00:15
Setup SDL project without Visual Studio or CMake (Windows)
1. Download Compiler
2. Add Compiler to Path
3. Download SDL
4. Use SDL
$. Extras
1. Download compiler:
@dmoa
dmoa / main.cpp
Created September 10, 2021 22:46
OpenGL Holy Grail
// This example loads an image and a shader that are used to draw the image.
#include <math.h>
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_opengl.h>
#define print SDL_Log
@dmoa
dmoa / sketch.js
Last active June 17, 2021 15:26
Polygon + Point Collision Detection
let polygon = [
[200, 100], [400, 130], [350, 300], [250, 300]
];
function setup() {
createCanvas(800, 800);
}
function draw() {
background(0);
@dmoa
dmoa / shader.frag
Created March 29, 2020 20:31
Attempt at lighting shader
#define M_PI 3.1415926535897932384626433832795
#define NUM_LIGHTS 32
struct Light {
vec2 position;
// color of the light
vec3 diffuse;
// power of the light
float power;
};
def lerp(a, b, t)
return a + (b - a) * t
end
crtShader = lg.newShader([[
extern float elapsed;
extern float colorI;
vec2 radialDistortion(vec2 coord, float dist) {
vec2 cc = coord - 0.5;
dist = dot(cc, cc) * dist + cos(elapsed * .3) * .01;
return (coord + cc * (1.0 + dist) * dist);
}
function love.draw()
local canvas, x, y, width, height, rotation, scaleX, scaleY, offsetX, offsetY = Scene:getRender()
love.graphics.setShader(crtShader)
love.graphics.draw(canvas, x, y, width, height, rotation, scaleX, scaleY, offsetX, offsetY)
end
scene.getRender = function (self, drawArg)
love.graphics.setColor(1,1,1)
love.graphics.setCanvas({self.threeCanvas, depth=true})
love.graphics.clear(0,0,0,0)