Flippers flip randomly instead of at predefined locations. Debug keys removed.
:flip-stride 1
:flip-max-angle 0
:flip-cur-angle 0
+ :flip-probability 0
:can-flip false
:shoot-probability 0
:type (EnemyEnum "NONE")
:flip-max-angle 0
:flip-cur-angle 0
:flip-permanent-dir nil
+ :flip-probability 0.015
:can-flip true
- :shoot-probability 0.005
+ :shoot-probability 0.004
))
(defn projectiles-after-shooting
[flipper]
(let [should-flip (and
(true? (:can-flip flipper))
- (or
- (= (:step flipper) 50)
- (= (:step flipper) 100)
- (= (:step flipper) 150)
- (= (:step flipper) (:steps (:level flipper)))
- )
- (= (:flip-dir flipper) (DirectionEnum "NONE")))
+ (= (:flip-dir flipper) (DirectionEnum "NONE"))
+ (or (<= (rand) (:flip-probability flipper))
+ (= (:step flipper) (:steps (:level flipper)))))
permanent-dir (:flip-permanent-dir flipper)
flip-dir (or permanent-dir (random-direction))
flip-seg-idx (segment-for-flip-direction flipper flip-dir)
(defn projectiles-after-collision
"Given an entity and a list of projectiles, returns the entity and updated
list of projectiles after collisions. The entity's hits-remaining counter
- is decremented on a collision, and the projectile is removed."
+ is decremented on a collision, and the projectile is removed. Small amount
+ of fudge factor (1 step += actual projectile location) to avoid narrow
+ misses in the collision algorithm."
[entity projectile-list]
((fn [entity projectiles-in projectiles-out was-hit?]
(if (empty? projectiles-in)
(let [bullet (first projectiles-in)
collision? (entity-between-steps
(:segment bullet)
- (:step bullet)
- (entity-next-step bullet)
+ (inc (:step bullet))
+ (dec (entity-next-step bullet))
entity)]
(if (and (not (:from-enemy? bullet)) collision?)
(recur (decrement-enemy-hits entity)
key-codes/LEFT (assoc game-state
:player
(assoc player :segment (segment-entity-cw player)))
- key-codes/UP (assoc game-state
- :player
- (assoc player :step (- (:step player) 10)))
- key-codes/DOWN (assoc game-state
- :player
- (assoc player :step (+ (:step player) 10)))
key-codes/SPACE (assoc game-state
:projectile-list
(add-player-projectile projectile-list player))