This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro chance [& body] | |
(let [r (gensym "chance") | |
pairs (sort-by first (partition 2 body)) | |
odds (map first pairs) | |
exprs (map last pairs) | |
sum (apply + odds) | |
fracs (map #(float (/ % sum)) odds) | |
frac-pairs (partition 2 (interleave fracs exprs))] | |
`(let [~r (rand)] | |
(cond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns snake.core | |
(:use | |
[arcadia.core] | |
[hard.core] | |
[hard.input] | |
[hard.tween])) | |
(declare get-input) | |
(arcadia.core/defcomponent Pumper [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns game.ghost | |
(:use arcadia.core | |
nasser.linear) | |
(:require [nasser.proto :as proto] | |
[nasser.component :refer [component]]) | |
(:import [UnityEngine Transform Component Time Vector3 Debug Color])) | |
(defn fly-towards! [^Transform tf ^Vector3 p ^double speed ^double turn-rate] | |
(let [ds (* speed Time/deltaTime) | |
target-dir (Vector3/Normalize (v- p (.. tf position)))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import chicken scheme) | |
(use hypergiant srfi-42 miscmacros) | |
;;; | |
;;; Game logic | |
;;; | |
;; Turns | |
(define turn (make-parameter 'black)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns user | |
(:use arcadia.core) | |
(:import [UnityEngine | |
Vector3 | |
Time | |
Gizmos | |
Color | |
Debug | |
Plane | |
Mathf])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns biology.squid | |
(:use hard.core hard.input hard.tween unity.messages) | |
(:require unity.core)) | |
(defn squid-start [this]) | |
(defn squid-update [this] | |
(let [h (get-axis :horizontal) | |
v (get-axis :vertical) |
Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.
Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.
I think it's really, really sleek, and this is what it looks like:
function dog(spec) {
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
NewerOlder