Skip to content

Instantly share code, notes, and snippets.

@pokepetter
pokepetter / monohex_font.py
Created November 25, 2023 08:44
monohex_font.py
glyphs = {
'a' : ([(.5, .75), (0, 1), (-.5, .75), (-.5, .25), (0, 0), (.5, .25), (.5, .75), (.5, 1), (.5, 0)], ),
'b' : ([(-.5, 2), (-.5, 0), (-.5, 0), (-.5, .75), (0, 1), (.5, .75), (.5, .25), (0, 0), (-.5, .25), (-.5, .75)], ),
'c' : ([(.5, .75), (0, 1), (-.5, .75), (-.5, .25), (0, 0), (.5, .25)], ),
'd' : ([(.5, .75), (0, 1), (-.5, .75), (-.5, .25), (0, 0), (.5, .25), (.5, .75), (.5,2), (.5,0)], ),
'e' : ([(-.5, .5), (.5, .5), (.5, .5), (.5, .75), (0, 1), (-.5, .75), (-.5, .25), (0, 0), (.5, .25)], ),
'f' : ([(.5, 1.75), (.25, 2), (0, 1.75), (0, 1.75), (0, 0)], [(.4, 1), (-.4, 1)], ),
'g' : ([(.5, .75), (0, 1), (-.5, .75), (-.5, .25), (0, 0), (.5, .25), (.5, .75), (.5, 1), (.5, 1), (.5, -.75), (0, -1), (-.5, -.75), (-.5, -.75)], ),
'h' : ([(-.5, 2), (-.5, 0), (-.5, 0), (-.5, .75), (0, 1), (.5, .75), (.5, .0)], ),
'i' : ([(0, 1), (0, 0)], [(0, 1.5), (.05, 1.45), (0, 1.4), (-.05, 1.45), (0, 1.5)], ),
from ursina import *
from ursina.prefabs.grid_editor import GridEditor, PixelEditor
import re
class Tilemap(GridEditor):
def __init__(self, tilemap='', tileset='', tileset_size=(8,8), **kwargs):
if isinstance(tilemap, str):
self.tilemap = load_texture(tilemap)
self.grid = [[self.tilemap.get_pixel(x,y) for y in range(self.tilemap.height)] for x in range(self.tilemap.width)]
# items.py
mana_potion = Item('Mana Potion', "Replenishes 5 mana")
def use(user, target):
target.mana += 5
mana_potion.use = use
from ursina import *
import pyperclip
app = Ursina()
window.color = color.black
Text.default_font = 'VeraMono.ttf'
from ursina import *
# override the built in round to easily round Vec3 and tuples/lists
builtin_round = round
def round(value, decimals=0):
if isinstance(value, Vec3):
return Vec3(builtin_round(value[0],decimals), builtin_round(value[1],decimals), builtin_round(value[2],decimals))
if isinstance(value, list):
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@pokepetter
pokepetter / git_fetcher.py
Created October 30, 2017 16:52
Shows git commit messages without having to manually fetch all the time.
from dulwich.repo import Repo
from dulwich import porcelain
from dulwich.patch import write_tree_diff
from dulwich import index
from dulwich.client import LocalGitClient, HttpGitClient
import sys
import datetime
import time
@pokepetter
pokepetter / TreeGenerator.cs
Created September 21, 2017 11:38
Unity3D editor script for adding leaves to a base mesh.
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
[SelectionBase]
public class TreeGenerator : MonoBehaviour {
import os
import numpy
import struct
import math
dir = os.path.dirname(__file__)
path = os.path.join(dir, 'Philip Glass - Evening Song Act III Pt. 3 (Satyagraha).mid')
print('file:', path)
data = numpy.fromfile(path, dtype=numpy.uint8)
pointer = 0