Skip to content

Instantly share code, notes, and snippets.

View McFunkypants's full-sized avatar
💭
Making games

Christer Kaitila McFunkypants

💭
Making games
View GitHub Profile
@kylemcdonald
kylemcdonald / three.js.shader.html
Last active March 27, 2023 00:45
Minimal three.js shader example.
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
overflow: hidden;
}
@xem
xem / readme.md
Last active July 14, 2024 10:15
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@Draknek
Draknek / zip-app.py
Last active March 27, 2024 15:21
Normally if you zip a .app directory on Windows and unzip it on Mac OS X, it won't run. This tool creates a zip file that should have the correct executable flags set to work correctly.
#!/usr/bin/env python3
import os
import sys
import time
import zipfile
startingdir = os.getcwd()
if (len(sys.argv) == 1):
print("Usage: " + os.path.basename(sys.argv[0]) + " path/to/application.app [path/to/output.zip]")
@xem
xem / JSGameFramework2020.html
Last active November 11, 2023 19:53
JS game framework 2020
<body style=margin:0>
<canvas id=a>
<script>
// initialize 2D canvas (c)
// initialize game state (s)
// initialize keys states (u,r,d,l for directions, k for all the keyboard)
c=a.getContext`2d`,k=[u=r=d=l=s=0]
// (initialize your global variables here)
@lewdev
lewdev / address-bar-code-editor-bookmarklet.md
Last active June 30, 2024 19:38
💻 Address Bar Code Editor Bookmarklet (743b)

💻 Address Bar Code Editor Bookmarklet (845b)

Copy-paste this into your address bar:

data:text/html,<title>code</title><link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 99 99"><text y="1em" font-size="72">&%23128187;</text></svg>'><textarea id=d spellcheck=false onkeypress=e=event;k=e.keyCode;(e.ctrlKey&&k==13)||k==10?f.srcdoc=d.value:0 style=resize:none;filter:invert(><p id=o></p>%0d<script>%0do.innerHTML = 0;%0d</script></textarea><iframe id=f></iframe><p id=p style=position:fixed;bottom:1;color:white;background:black></p><script>D=null,d.onkeyup=d.onclick=n=>{clearTimeout(D),D=setTimeout(n=>{A=d.selectionStart,B=d.selectionEnd,V=d.value,E=V.substr(0,B).split`\n`,p.innerHTML=`Ln:${E.length}, Col:${E.pop().length+1}, ${A==B?"Pos:"+B:"Sel:"+(B-A)}, Len:${V.length}`},99)}</script><style>*{box-sizing:border-box;margin:0}textarea,iframe{width:50%;height:100%;vertical-align:top}

In the latest iteration my code editor, I've made big practical improvements