mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-06-11 06:29:31 +00:00
added firing of new shells to SHOT write-register function
This commit is contained in:
parent
206f44ed9e
commit
6be9e599e1
|
@ -1,5 +1,6 @@
|
|||
(ns robotwar.register
|
||||
(:use robotwar.constants))
|
||||
(:use [robotwar.constants])
|
||||
(:require [robotwar.shell :as shell]))
|
||||
|
||||
(def reg-names [ "DATA"
|
||||
"A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
|
||||
|
@ -98,7 +99,7 @@
|
|||
{:write-register
|
||||
(fn [{:keys [robot-idx field-name]} world data]
|
||||
(let [{:keys [pos-x pos-y aim shot-timer] :as robot}
|
||||
(get-in world (path-to-robot robot-idx))]
|
||||
(get-in world (path-to-robot robot-idx))]
|
||||
(if (> shot-timer 0)
|
||||
world
|
||||
(let [shells (:shells world)
|
||||
|
@ -106,18 +107,10 @@
|
|||
world
|
||||
(path-to-robot-field robot-idx :shot-timer)
|
||||
GAME-SECONDS-PER-SHOT)]
|
||||
; TODO: change this next line to something
|
||||
; that actually releases a shell. This is a
|
||||
; very temporary version to test the shot-timer.
|
||||
world-with-new-shot-timer))))})
|
||||
|
||||
;(conj shells (shell/new-shell
|
||||
; (:pos-x robot)
|
||||
; (:pox-y robot)
|
||||
; (:aim robot))
|
||||
; data))]
|
||||
|
||||
|
||||
(assoc
|
||||
world-with-new-shot-timer
|
||||
:shells
|
||||
(conj shells (shell/init-shell pos-x pos-y aim data)))))))})
|
||||
|
||||
(defn get-target-register
|
||||
"helper function for DataRegister record"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns robotwar.shell
|
||||
(:use [robotwar.constants]))
|
||||
|
||||
|
||||
(defn deg->rad
|
||||
[angle]
|
||||
(* angle (/ Math/PI 180)))
|
||||
|
@ -11,7 +10,7 @@
|
|||
{:x (Math/cos angle)
|
||||
:y (Math/sin angle)})
|
||||
|
||||
(defn new-shell
|
||||
(defn init-shell
|
||||
[pos-x pos-y aim distance]
|
||||
; TODO: make the starting point dependent upon the robot radius,
|
||||
; which should be in constants.
|
||||
|
|
Loading…
Reference in New Issue
Block a user