Created
November 11, 2014 05:36
-
-
Save nasser/de0707f9cb23f7804054 to your computer and use it in GitHub Desktop.
Cleaned up code from the Nov 10 ClojureNYC Meetup
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 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