From 145197c33e0f5225d8a16a4967089defb37c7ab4 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 6 Aug 2015 13:20:53 -0700 Subject: [PATCH] better job at showing hotspots. --- desktop/gametodos.txt | 33 +++ desktop/src-common/advent/#utils.clj# | 272 ------------------ .../advent/screens/rooms/outside_house.clj | 2 +- desktop/src-common/advent/screens/scene.clj | 10 +- desktop/src-common/advent/utils.clj | 16 +- 5 files changed, 52 insertions(+), 281 deletions(-) delete mode 100644 desktop/src-common/advent/#utils.clj# diff --git a/desktop/gametodos.txt b/desktop/gametodos.txt index 3c94339e..70c22b23 100644 --- a/desktop/gametodos.txt +++ b/desktop/gametodos.txt @@ -14,3 +14,36 @@ + Test new gandarf dialogue + sometimes you can walk on stuff + + +How do I start over? +"bod like mine" +jail asks about burning but candle isn't lit +Mama sheep and the carrot didn't trigger a few times +Should be able to put back or give back antique shops stuff +Two wools is a bit confusing, three? +Make a "Wool" joke if you try to clean the window +Computer cooks when I go in the wizards house +Double click scene jump +Don't also object with nothing interactions, makes it hard to tell if +I missed hot spot or it's the wrong solution + +Some games you have to try multiple times (make a joke about the multi +click puzzles) +hiding stuff in the hay so you don't get caught with it +putting out the candle +lighting the hay on fire + +mark the squeaky board a bit +after the prison break I have no clear goal + +some nattering noise while talking would be good +Didn't have the earplugs, I had the tapes, thief talked about the ear +plugs +"wit's end" +gang dude should pop the georgia dream + +put the clock in caldron before I knew why +you can drink the strength potion while in blood clots hand + +Add color text for wrong interactions diff --git a/desktop/src-common/advent/#utils.clj# b/desktop/src-common/advent/#utils.clj# deleted file mode 100644 index bb42ba11..00000000 --- a/desktop/src-common/advent/#utils.clj# +++ /dev/null @@ -1,272 +0,0 @@ -(ns advent.utils - (:refer-clojure :exclude [load]) - (:require [play-clj.core :refer :all] - [play-clj.ui :refer :all] - [play-clj.utils :refer :all] - [play-clj.math :refer :all] - [play-clj.g2d :refer :all] - [clojure.java.io :as io] - [clojure.edn :as edn]) - (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] - [com.badlogic.gdx.graphics.g2d TextureRegion] - [com.badlogic.gdx.utils.viewport FitViewport] - [com.badlogic.gdx.scenes.scene2d Actor Stage] - [java.lang Object])) - -(defn log-coords [screen entities] - (let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})] - (println (:input-x screen) (:input-y screen) "->" x y))) - -(def +all-cursors+ [:main :wool :mushrooms :carrot :right :down :left :up :flask :flask-with-contents :trophy :ladder :stick :cat-toy :balloon :frog-legs :teddy :portrait :recipe :glass-eye :motivational-tapes :used-earplugs :grass :slobber :flask-with-strength :medal :kiss :sword :hourglass :mandrake :ball-n-chain :key :rope :crowbar :note-1 :ash :sack-lunch :flies :spear :monocle :feather :spell-component :money :watch :broken-clock :slingshot :camera :walkie-talkies :alarm-clock :walkie-talkie :flask-water :flask-water-stuff :flask-water-stuff-2 :note-2 :magic-slingshot :active-main :shovel :broom]) - -(def settings (atom {:music-volume 50.0 - :sound-volume 75.0})) - -(defn current-music-volume [& [factor]] - (* (Math/pow (/ (:music-volume @settings) 100.0) 2) - 0.25 - (or factor 1.0))) - -(defn current-sound-volume [& [factor]] - (* (Math/pow (/ (:sound-volume @settings) 100.0) 2) - 0.5 - (or factor 1.0))) - -(defn cursor [filename which] - (let [scale 2 - base-cursor (pixmap filename) - target-width (* 16 scale) - target-height (* 16 scale) - resized (Pixmap. target-width target-height (.getFormat base-cursor)) - index (.indexOf +all-cursors+ which)] - #_(Pixmap/setFilter Pixmap$Filter/NearestNeighbour) - (pixmap! resized :draw-pixmap base-cursor (* index 16) 0 16 16 - 0 0 target-width target-height) - resized )) - -(defn save [entities] - (spit "save.edn" (entities :state))) - -(defn load [] - (assoc (edn/read-string (slurp "save.edn")) :active? true)) - -(defn load-settings! [] - (when (.exists (io/file "settings.edn")) - (reset! settings (edn/read-string (slurp "settings.edn"))))) - -(defn save-settings! [] - (spit "settings.edn" @settings)) - -(defn get-font [filename] - (let [font (bitmap-font filename) - tr (bitmap-font! font :get-region) - tx (.getTexture tr)] - (texture! tx :set-filter Texture$TextureFilter/Linear Texture$TextureFilter/Linear) - font)) - -(def +screen-width+ 320) -(def +screen-height+ 240) - -(defn scaler-fn-with-baseline [baseline minimum-size & [maximum-size]] - (let [maximum-size (or maximum-size 1.0)] - (fn [[_ y]] - (if (< y baseline) maximum-size - (let [percent-complete (- 1.0 (/ (- y baseline) (- +screen-height+ baseline))) - range (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)] - range))))) - -(defn get-scale-value [image x y] - (let [base-y (Math/floor (- 240 y)) - other-y (Math/ceil (- 240 y)) - base-amount (- y (Math/floor y)) - other-amount (- 1.0 base-amount) - base-v (-> image - (pixmap! :get-pixel x base-y) - color - (.r)) - other-v (-> image - (pixmap! :get-pixel x other-y) - color - (.r))] - (+ (* base-v base-amount) - (* other-v other-amount)))) - -(defn scaler-fn-from-image [image minimum-size maximum-size] - (let [image (pixmap image) - maximum-size (or maximum-size 1.0)] - (fn [[x y]] - (let [percent-complete (get-scale-value image x y)] - (if (< y 0) - maximum-size - (+ (* percent-complete (- maximum-size minimum-size)) minimum-size)))))) - -(defn dist [x1 y1 x2 y2 & {:keys [y-sign x-sign]}] - (let [y-sign (or y-sign 1.0) - x-sign (or x-sign 1.0) - dx (* (- x1 x2) x-sign) - dy (* y-sign (- y1 y2))] - (Math/sqrt (+ (* dx dx) (* dy dy))))) - - -(defn flip [anim] - (animation (animation! anim :get-frame-duration) - (for [src-frame (animation! anim :get-key-frames) - :let [frame (texture (texture! src-frame :get-texture))]] - (do - (texture! frame :set-region src-frame) - (texture! frame :flip true false) - frame)))) - -(defn split-texture [file [w h] frames] - (let [sheet (texture! (texture file) :split w h)] - (for [i frames] - (aget sheet 0 i)))) - -(defn make-anim [file [w h] speed frames] - (animation speed (split-texture file [w h] frames))) - - -(defn make-bird [screen p] - (let [bird-sheet (texture! (texture "outside-castle/bird.png") :split 1 2) - bird-stand (animation 0.15 (for [i [0 1]] - (aget bird-sheet 0 i)))] - (assoc (animation->texture screen bird-stand) - :x 0 - :y 0 - :baseline 21 - :anim bird-stand - :anim-start 0 - :path (catmull-rom-spline (map #(apply vector-2* %) p) true) - :update-fn (fn [screen entities entity] - (let [speed 0.05 - pos-f (- (* (:total-time screen) speed) (int (* (:total-time screen) speed))) - v (vector-2 0 0) - a (catmull-rom-spline! (:path entity) :value-at v pos-f)] - (assoc entity :x (vector-2! v :x) :y (vector-2! v :y))))))) - -(defn path-point [speed screen entities entity] - (* (- (:total-time screen) (:path-start-time entity 0.0)) speed)) - -(defn update-path-location [speed screen entities entity] - (let [pos-in-path (or (:pos-in-path entity) 0.1) - _ (println pos-in-path) - pos-in-path (min pos-in-path 1.0) - v (vector-2 0 0) - a (catmull-rom-spline! (:path entity) :derivative-at v pos-in-path) - pos-in-path (+ pos-in-path (/ (* (:delta-time screen) speed) (.len v)) ) - a (catmull-rom-spline! (:path entity) :value-at v pos-in-path) - ] - - (assoc entity :x (vector-2! v :x) :y (vector-2! v :y) :pos-in-path pos-in-path))) - -(defn find-override [entities [x y]] - (first (concat (filter #(and ((:mouse-in? %) entities x y) - - (:override %)) - (get-in entities [:room :interactions])) - (filter #(and (:mouse-in? %) - ((:mouse-in? %) entities x y) - (not= "ego" (:id %)) - (:script %)) - (vals (get-in entities [:room :entities]))) - (filter #(and ((:mouse-in? %) entities x y) - (:script %)) - (get-in entities [:room :interactions]))))) - - - -(defn remove-interaction [entities id] - (update-in entities [:room :interactions] (fn [i] (remove #(= id (:id %)) i)))) - - -(defn play-sound [snd] - (music! snd :play)) - -(defn stop-sound [snd] - (music! snd :stop)) - -(defn make-music [r] - (doto (music r) (music! :set-looping true))) - - - -(defn apply-tweens [screen entities tweens] - (reduce (fn [e f] - (f e (:total-time screen))) - entities - (vals tweens))) - -(defn intersects? [e [x y]] - (and (:object e) - (< (:x e) x (+ (:x e) (or (:width e) (.getWidth (:object e))))) - (< (:y e) y (+ (:y e) (or (:height e) (.getHeight (:object e))))))) - -(defn get-current-music [entities] - (let [time (get-in entities [:state :time]) - musics (:musics entities) - override-music (musics (get-in entities [:music-override :value])) - current-music (musics (get-in entities [:room :music])) - current-time-music (musics (get-in entities [:room :music time]))] - (or override-music current-music current-time-music))) - - -(defn setup-viewport [screen width height] - (let [cam (orthographic) - viewport (FitViewport. width height cam) - stage (Stage. viewport)] - (update! screen :renderer stage :viewport viewport :camera cam) - (.apply viewport) - [cam viewport stage])) - -(defn unproject - ([screen] - (unproject screen [(:input-x screen) (:input-y screen)]) ) - ([screen [x y]] - (let [pj (.unproject ^FitViewport (:viewport screen) (vector-2 x y)) - x (.x pj) - y (.y pj)] - [x y]))) - -(defn project - ([screen [x y]] - (let [pj (.project ^FitViewport (:viewport screen) (vector-2 x y)) - x (.x pj) - y (.y pj)] - [x y]))) - -(defn contains-point? [x1 y1 width height x y] - (and (< x1 x (+ x1 width)) - (< y1 y (+ y1 height)))) - -(defn update-override [screen entities] - (let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))] - (if (get-in entities [:state :active?]) - (if-let [mouse-override (find-override entities last-pos)] - (assoc-in entities [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) - (assoc-in entities [:cursor :override] nil)) - entities))) - -(def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0}) -(def default-night-merge-sprite {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 0.3 :hue-amount 0.4}) - -(defn clamp-volume [vol] - (max vol 0.005)) - -(defn proximity-volume [entities [x y] & {:keys [scale]}] - (-> (max 0.0 - (- 1.0 (/ (dist x y - (get-in entities [:room :entities :ego :x]) - (get-in entities [:room :entities :ego :y]) - :y-sign 2.0 - :x-sign (/ 1.0 (get-in entities [:room :entities :ego :scale-x]))) - 175.0))) - (* (or scale 1.0)) - (clamp-volume))) - -(defn fast-forward-particle [p] - (particle-effect! p :reset) - (particle-effect! p :start) - - (particle-effect! p :update 10.0) - (dotimes [_ 160] - (particle-effect! p :update 0.2))) diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 834f10d7..3806a1cf 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -578,7 +578,7 @@ (actions/transition-background entities :behind-house [122 140]) (actions/walk-to entities :ego [172 122])) :cursor :right} - :up-dir {:box [60 180 224 240] + :up-dir {:box [105 180 203 240] :script (actions/get-script entities (actions/walk-to entities :ego [137 204]) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index cc633876..72f4496a 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -611,11 +611,13 @@ void main() entities) entities)) -(defn update-cursor [screen {{:keys [current override last]} :cursor :as entities}] +(defn update-cursor [screen {{:keys [current override last active was-active]} :cursor :as entities}] (let [new-current (or override current)] - (when-not (= new-current - last) - (input! :set-cursor-image (utils/cursor "cursor.png" (or (:cursor new-current) new-current)) 0 0)) + (when-not (and (= new-current + last) + (= active was-active)) + (let [image-path (if active "cursor_light.png" "cursor.png")] + (input! :set-cursor-image (utils/cursor image-path (or (:cursor new-current) new-current)) 0 0))) (assoc-in entities [:cursor :last] new-current))) diff --git a/desktop/src-common/advent/utils.clj b/desktop/src-common/advent/utils.clj index 2d8bc3da..edad6557 100644 --- a/desktop/src-common/advent/utils.clj +++ b/desktop/src-common/advent/utils.clj @@ -6,8 +6,9 @@ [play-clj.math :refer :all] [play-clj.g2d :refer :all] [clojure.java.io :as io] - [clojure.edn :as edn]) - (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter] + [clojure.edn :as edn] + [clojure.string :as str]) + (:import [com.badlogic.gdx.graphics Pixmap Pixmap$Blending Pixmap$Filter Texture Texture$TextureFilter] [com.badlogic.gdx.graphics.g2d TextureRegion] [com.badlogic.gdx.utils.viewport FitViewport] [com.badlogic.gdx.scenes.scene2d Actor Stage] @@ -42,6 +43,7 @@ #_(Pixmap/setFilter Pixmap$Filter/NearestNeighbour) (pixmap! resized :draw-pixmap base-cursor (* index 16) 0 16 16 0 0 target-width target-height) + resized )) (defn save [entities] @@ -239,8 +241,14 @@ (let [last-pos (unproject screen (get-in entities [:cursor :last-pos]))] (if (get-in entities [:state :active?]) (if-let [mouse-override (find-override entities last-pos)] - (assoc-in entities [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) - (assoc-in entities [:cursor :override] nil)) + (-> entities + (assoc-in [:cursor :override] (or (:cursor mouse-override) (when (#{:main :active-main} (get-in entities [:cursor :last])) :active-main))) + (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) + (assoc-in [:cursor :active] true)) + (-> entities + (assoc-in [:cursor :override] nil) + (assoc-in [:cursor :was-active] (get-in entities [:cursor :active])) + (assoc-in [:cursor :active] false))) entities))) (def default-night-merge {:r 0.08 :g 0.1 :b 0.36 :multiply-amount 1.0 :hue-amount 1.0})