Skip to content

Instantly share code, notes, and snippets.

View quephird's full-sized avatar

danielle quephird

View GitHub Profile
@quephird
quephird / Complex.purs
Created March 29, 2015 03:50
Just a dopey implementation of a Complex type in PureScript
module Data.Complex where
data Complex = Complex Number Number
instance showComplex :: Show Complex where
show (Complex x y) = show x ++ " + " ++ show y ++ "i"
instance eqComplex :: Eq Complex where
(==) (Complex x y) (Complex x' y') = (x == x') && (y == y')
(/=) (Complex x y) (Complex x' y') = (x /= x') || (y /= y')
@quephird
quephird / bndm.clj
Last active August 29, 2015 14:13
A really rough first cut of a string searching function using the so-called BNDM algorithm
(defn bndm [pattern string]
"Searches for the pattern in the string using the BNDM algorithm;
it returns a list of the indices where there is a match."
(let [uniq-letters (set pattern)
indexed-letters (map-indexed vector pattern)
bitmasks (into {}
(for [c uniq-letters]
[c (reduce + (map (fn [[idx c']] (if (= c c') (bit-shift-left 1 idx) 0)) indexed-letters))]))]
(loop [d 0 idx 0 acc []]
(cond
OK... so for my DoDonPascii game I can generate waves of baddies, each with different sprites
and attack patterns. But now, I want to be able to associate potential powerups with certain
waves of baddies. One of the common idioms/cliches in shmups is having to wait for the red
planes to come out; if you shoot them all then a powerup is dropped. If even one escapes,
the opportunity is gone and you have to wait for the next wave of red planes to come out.
Here are the rules that I think I want to try to enforce:
* The powerup is _only_ associated with a specific wave when comes out.
* The powerup _only_ becomes available when all of the baddies in that wave are destroyed.
@quephird
quephird / twitter_names.txt
Last active April 25, 2025 03:44
A critical document listing the display names I've used on Twitter. Hey, this is important stuff.
pɹoɟɟǝʞ ǝןןǝıuɐp
ⅅ₳ℕⅈⅇℒℒⅇ Ҝⅇℱℱʘℝⅅ
danielleᵏᵉᶠᶠᵒʳᵈ
ᗝ ᗉ Z — Ш ⅃ ⅃ Ш
ᗰ Γ Γ ᗰ — Z ᗆ ᗜ
java -XmsMerry
⣏⡱⡮⢵⡗⢼⡇⣟⣋⣇⣀⣇⣀⣟⣋
ḋäṅïëḷḷë ḳëḟḟöṙḋ
刀丹れ工モㄥㄥモ ケモ下下ロ尺刀
(cons danielle butt)
@quephird
quephird / Things_that_make_everything_better.txt
Last active January 3, 2025 02:25
Things that make everything better
Things that make everything better:
• 🟪 Purple
• 🍫 Chocolate
• 🧱 LEGO
• ✨ Glitter
• () LISP
• 👗 Velvet
• ❌ Cancelled meetings
• 🌶 Spicy food

The struggle I'm having isn't that I can't do I/O; it's that I can! ;P

Seriously, though, it's that I can do so in places that I'm pretty sure that I shouldn't. That is, my understanding is that things that are dirty, like anything involving I/O, should be sectioned off from everything else that is pure, as much as possible. This makes more of your code understandable, testable, and reusable.

Indeed, I have striven to do that but there are places where I have taken the easy way out in the middle of routines that "update" state. Below is an example from my game (you can look at the entire source here, https://github.com/quephird/space-invaders/blob/master/src/space_invaders/core.clj):

(defn key-pressed [{{sound :sound} :player-bullets :as state}
                    {key           :key
                     key-code      :key-code       :as event}]

"Primary hook to return new version of game state taking into account:

(ns fake-cubes
(:require [quil.core :as q :include-macros true]))
(defn fake-cube [x y s]
(let [h (q/random 30 100)
sa (q/random 127 255)]
(q/push-matrix)
(q/translate x y)
(dotimes [i 3]
(q/fill h sa (/ 255 (inc i)))
@quephird
quephird / orb-sprial.clj
Created October 28, 2014 22:23
A re-interpretation of this post by the venerable Bees & Bombs: http://beesandbombs.tumblr.com/post/96776703769/orb-spiral
(ns orb-spiral
(:use quil.core))
(def screen-w 800)
(def screen-h screen-w)
(defn setup []
(smooth)
; (fill 250)
(color-mode :hsb 1)
(ns circle-race
(:require [quil.core :as q :include-macros true]))
(defn setup []
(q/smooth)
(q/color-mode :hsb))
(defn draw []
(let [fc (q/frame-count)
w (q/width)
@quephird
quephird / splats.clj
Created October 10, 2014 00:27
First cut at simulating paint splatters.
(ns fun-with-quil.splats
(:require [quil.core :as q :include-macros true]))
; TODO: Introduce paint streaks
(defn splat [x y d h]
(let [lobes (+ 5 (rand-int 10))]
(q/fill h 127 255)
(q/translate x y)
(q/ellipse 0 0 d d)
(q/rotate (q/random q/PI))