Skip to content

Instantly share code, notes, and snippets.

@nasser
Created November 11, 2014 05:36
Show Gist options
  • Save nasser/de0707f9cb23f7804054 to your computer and use it in GitHub Desktop.
Save nasser/de0707f9cb23f7804054 to your computer and use it in GitHub Desktop.
Cleaned up code from the Nov 10 ClojureNYC Meetup
(ns flappy.bird
(:use arcadia.core)
(:import [UnityEngine Vector2 Input Time Vector3]))
(defcomponent Bird [^Vector2 force]
(Update [this]
;; flap on any keypress
(if Input/anyKeyDown
(.. this rigidbody2D
(AddForce force ForceMode2D/Impulse)))))
(defcomponent Pipe [^float speed]
(Update [this]
;; move left
(.. this transform (Translate (* (.speed this)
Time/deltaTime) 0 0))
;; reset position
(if (< (.. this transform position x)
-1.0)
(set! (.. this transform position)
(Vector3. 1
(+ (.. this transform position y)
(* 0.1 (rand)))
0)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment