src/clojurecraft/actions.clj @ 2e42d7f29dde
Moar docs.
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 10 Aug 2011 00:37:28 -0400 |
parents |
6f54b979c6b5 |
children |
43f02bd6b197 |
(ns clojurecraft.actions
(:use [clojurecraft.util])
(:require [clojurecraft.physics :as physics]))
(defn move [bot x-change y-change z-change]
(let [player (:player bot)]
(dosync
(let [location (:loc @player)
new-location (merge location
{:x (+ x-change (:x location))
:y (+ y-change (:y location))
:z (+ z-change (:z location))
:stance (+ y-change (:stance location))})]
(alter player merge {:loc new-location}))))
nil)
(defn jump [bot]
(let [player (:player bot)]
(dosync
(let [location (:loc @player)]
(alter player assoc-in [:loc :onground] false)
(alter player assoc :velocity physics/JUMP-VELOCITY))))
nil)