src/clojurecraft/actions.clj @ 6f54b979c6b5
Gravity. Thanks, Mineflayer!
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 09 Aug 2011 21:55:15 -0400 |
parents |
c41de2845803 |
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)