Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑

Jason Tu nucleartide

🥑
View GitHub Profile
View ModelViewPresenterUnity.cs
class EnemyModel
{
public ReactiveProperty<long> CurrentHp { get; private set; }
public ReactiveProperty<bool> IsDed { get; private set; }
public EnemyModel(int initialHp)
{
CurrentHp = new ReactiveProperty<long>(initialHp);
IsDead = CurrentHp.Select(x => x <= 0).ToReactiveProperty();
}
@nucleartide
nucleartide / rrectfill.p8
Last active May 5, 2020
rounded rectfill for pico8
View rrectfill.p8
function rrectfill(x0, y0, x1, y1, col, corners)
local tl = corners and corners.tl
local tr = corners and corners.tr
local bl = corners and corners.bl
local br = corners and corners.br
local new_x0 = x0 + max(tl, bl)
local new_y0 = y0 + max(tl, tr)
local new_x1 = x1 - max(tr, br)
local new_y1 = y1 - max(bl, br)
View weighted_choice.lua
function weighted_choice(choices)
local total_weight = 0
local thresholds = {}
for choice, weight in pairs(choices) do
add(thresholds, {total_weight, choice})
total_weight += weight
end
local selection = rnd(total_weight)
for i=1,#thresholds-1 do
View fencing.js
const verbs = [
'move horizontally',
'raise sword',
'lower sword',
'thrust sword',
]
const objects = [
'fencer with sword',
'piste',
@nucleartide
nucleartide / command.p8
Last active Apr 25, 2019
Command pattern in PICO-8 (basically, passing a callback)
View command.p8
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
-- here's a simple player class:
function player(o)
return {
x=64,
y=64,
on_input=o.on_input,
@nucleartide
nucleartide / verbs.txt
Created Jan 3, 2019
interesting verbs
View verbs.txt
- [ ] swing
- [ ] blow
- [ ] shake whipped cream / screenshake
- [ ] wash dishes
- [ ] cut / chop
- [ ] roll
- [ ] punch
- [ ] blow up
- [ ] cook (by breathing fire)
- [ ] jump
@nucleartide
nucleartide / fried_eggs.p8
Created Nov 13, 2018
You thought you liked breakfast...
View fried_eggs.p8
u=64
x,y=u,u
es={}
c=circfill
f=abs
q=3
g=0
p=cos
o=sin
function _update()
@nucleartide
nucleartide / sketch.tsx
Last active Mar 28, 2018
<canvas> game dev API sketches
View sketch.tsx
// Imperative, immediate-mode API. (Inspired by PICO-8.)
function _init() {
}
function _update() {
}
function _draw() {
cls(Color.Blue);
@nucleartide
nucleartide / controllers.application.js
Created Dec 10, 2017
notifyPropertyChange behavior
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
// this.foo = { bar: { baz: 4 } };
let foo = Ember.Object.create();