Skip to content

Instantly share code, notes, and snippets.

@nucleartide
nucleartide / controllers.application.js
Created December 10, 2017 23:57
notifyPropertyChange behavior
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();
@nucleartide
nucleartide / sketch.tsx
Last active March 28, 2018 14:14
<canvas> game dev API sketches
// Imperative, immediate-mode API. (Inspired by PICO-8.)
function _init() {
}
function _update() {
}
function _draw() {
cls(Color.Blue);
@nucleartide
nucleartide / fried_eggs.p8
Created November 13, 2018 16:38
You thought you liked breakfast...
u=64
x,y=u,u
es={}
c=circfill
f=abs
q=3
g=0
p=cos
o=sin
function _update()
@nucleartide
nucleartide / verbs.txt
Created January 3, 2019 09:30
interesting verbs
- [ ] swing
- [ ] blow
- [ ] shake whipped cream / screenshake
- [ ] wash dishes
- [ ] cut / chop
- [ ] roll
- [ ] punch
- [ ] blow up
- [ ] cook (by breathing fire)
- [ ] jump
@nucleartide
nucleartide / command.p8
Last active April 25, 2019 04:40
Command pattern in PICO-8 (basically, passing a callback)
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,
const verbs = [
'move horizontally',
'raise sword',
'lower sword',
'thrust sword',
]
const objects = [
'fencer with sword',
'piste',
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
@nucleartide
nucleartide / rrectfill.p8
Last active May 5, 2020 14:21
rounded rectfill for pico8
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)
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();
}