Skip to content

Instantly share code, notes, and snippets.

View christianblunden's full-sized avatar
👋
hello

Christian Blunden christianblunden

👋
hello
View GitHub Profile
@christianblunden
christianblunden / clojurebridge-shapes.cljs
Created February 20, 2020 16:54 — forked from londonclojurians/clojurebridge-shapes.cljs
ClojureBridge learning path using Maria.cloud - fork me and explore Clojure using shapes, colours and animation
;; # Colours and Shapes in Clojure
;; This web page allows you to ask your computer to do tasks for you, specifically draw one or more shapes and change the colour of those shapes. We ask the computer to do these tasks in a programming language called Clojure.
;; Clojure is a functional programming language. The behaviour of your code is expressed by calling one or more functions.
;; Each function has a particular thing it does when you call it. We will discover functions that:
;; * draw particular shapes
(ns tron.xianralph
(:require [tron.core :as tron]))
(defn move [[x y] [dx dy]] [(+ x dx) (+ y dy)])
(defn up [point] (move point [0 1]))
(defn down [point] (move point [0 -1]))
(defn right [point] (move point [1 0]))
(defn left [point] (move point [-1 0]))
(def directions #{up down right left})