Skip to content

Instantly share code, notes, and snippets.

@psema4
psema4 / incremental-game-loop.md
Created January 25, 2026 02:57 — forked from HipHopHuman/incremental-game-loop.md
How to make a game loop for your idle game

How do I make a game loop for my Idle Game?

Interval-Based Resource Generators

So, you want to build an idle/incremental game in JavaScript and you’ve read on the internet that setInterval is the way to go when it comes to handling resources that automatically generate over time.

You get started, you write down your setInterval function, you set it to trigger once every 1000 milliseconds, and every time it triggers, you add 1 to the player’s total resource count. Perfect. It works.

Uh-oh.

@psema4
psema4 / ExportTerrain2Mesh.cs
Created January 15, 2025 22:36 — forked from JauntyBear/ExportTerrain2Mesh.cs
Unity Export Terrain to Mesh
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.IO;
using System.Text;
enum SaveFormat { Triangles, Quads }
enum SaveResolution { Full = 0, Half, Quarter, Eighth, Sixteenth }
@psema4
psema4 / blocks.py
Created September 10, 2024 14:26 — forked from thomasahle/blocks.py
Manim heat exchange
from manim import *
import numpy as np
class HeatTransferAnimation(Scene):
def construct(self):
# Configuration
num_blocks = 10
block_size = 1
spacing = 0.1
@psema4
psema4 / List of in-browser VMs.md
Created April 9, 2024 11:36 — forked from SMUsamaShah/List of in-browser VMs.md
List of Javascript based virtual machines running in browser
@psema4
psema4 / JavaScript Analog Clock.html
Created April 20, 2023 23:23 — forked from stavrossk/JavaScript Analog Clock.html
Simple Analog Clock using HTML5 canvas and JavaScript.
<!doctype html>
<html>
<head>
<title>Analog Clock using Canvas</title>
</head>
<body>
@psema4
psema4 / Unicode table
Created September 11, 2022 15:15 — forked from ivandrofly/Unicode table
Unicode table - List of most common Unicode characters *
Unicode table - List of most common Unicode characters *
* This summary list contains about 2000 characters for most common ocidental/latin languages and most printable symbols but not chinese, japanese, arab, archaic and some unprintable.
Contains character codes in HEX (hexadecimal), decimal number, name/description and corresponding printable symbol.
What is Unicode?
Unicode is a standard created to define letters of all languages ​​and characters such as punctuation and technical symbols. Today, UNICODE (UTF-8) is the most used character set encoding (used by almost 70% of websites, in 2013). The second most used character set is ISO-8859-1 (about 20% of websites), but this old encoding format is being replaced by Unicode.
How to identify the Unicode number for a character?
Type or paste a character:
@psema4
psema4 / index.html
Last active February 23, 2022 02:40 — forked from bellbind/index.html
[threejs] simplified gltf2 loader example
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://unpkg.com/three"></script>
<script
src="https://unpkg.com/three/examples/js/loaders/GLTFLoader.js"
></script>
<script src="script.js" defer="defer"></script>
</head>
@psema4
psema4 / JSGameFramework2020.html
Created August 21, 2021 01:38 — forked from xem/JSGameFramework2020.html
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)
@psema4
psema4 / squirrel3.js
Created August 12, 2021 21:26
An implementation of the Squirrel3 Noise-based RNG
// Based on the GDC 2017 talk "Math for Game Programmers: Noise-Based RNG"
// https://www.youtube.com/watch?v=LWFzPP8ZbdU&ab_channel=GDC
const BIT_NOISE1 = 0xB5297A4D
const BIT_NOISE2 = 0x68E31DA4
const BIT_NOISE3 = 0x1B56C4E9
const PRIME1 = 198491317
const PRIME2 = 6542989
class Squirrel3 {
@psema4
psema4 / Has weird right-to-left characters.txt
Created April 15, 2021 16:31 — forked from endolith/Has weird right-to-left characters.txt
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶