beginning on inventory screen.
This commit is contained in:
BIN
desktop/resources/cat-tree/inventory.png
Normal file
BIN
desktop/resources/cat-tree/inventory.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 11 KiB |
BIN
desktop/resources/inventory-overlay.png
Normal file
BIN
desktop/resources/inventory-overlay.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
BIN
desktop/resources/inventory-overlay.psd
Normal file
BIN
desktop/resources/inventory-overlay.psd
Normal file
Binary file not shown.
BIN
desktop/resources/inventory.png
Normal file
BIN
desktop/resources/inventory.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
desktop/resources/inventory.psd
Normal file
BIN
desktop/resources/inventory.psd
Normal file
Binary file not shown.
@@ -5,6 +5,7 @@
|
||||
[play-clj.g2d :refer :all]
|
||||
[advent.screens.scene :as scene]
|
||||
[advent.screens.dialogue :as dialogue]
|
||||
[advent.screens.inventory :as inventory]
|
||||
[clojure.pprint]
|
||||
[advent.pathfind])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
@@ -15,4 +16,4 @@
|
||||
(defgame advent
|
||||
:on-create
|
||||
(fn [this]
|
||||
(set-screen! this scene/scene dialogue/talking-screen)))
|
||||
(set-screen! this scene/scene dialogue/talking-screen inventory/inventory-screen)))
|
||||
|
||||
50
desktop/src-common/advent/screens/inventory.clj
Normal file
50
desktop/src-common/advent/screens/inventory.clj
Normal file
@@ -0,0 +1,50 @@
|
||||
(ns advent.screens.inventory
|
||||
(:require [play-clj.core :refer :all]
|
||||
[play-clj.ui :refer :all]
|
||||
[play-clj.utils :refer :all]
|
||||
[play-clj.g2d :refer :all]
|
||||
[clojure.pprint]
|
||||
[advent.pathfind])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
[com.badlogic.gdx.scenes.scene2d.utils Align]
|
||||
[com.badlogic.gdx Application Audio Files Game Gdx Graphics Input
|
||||
InputMultiplexer InputProcessor Net Preferences Screen]))
|
||||
|
||||
|
||||
(defscreen inventory-screen
|
||||
:on-show
|
||||
(fn [screen entities]
|
||||
(update! screen :renderer (stage) :camera (orthographic))
|
||||
{:overlay (assoc (texture "inventory-overlay.png" ) :x 0 :y 0)
|
||||
:fade (assoc (texture "black.png")
|
||||
:scale-x 20
|
||||
:scale-y 20
|
||||
:opacity 0.4)
|
||||
:shown? false
|
||||
:start-showing? false})
|
||||
|
||||
:on-render
|
||||
(fn [screen [entities]]
|
||||
(let [entities (if (:start-showing? entities)
|
||||
(-> entities
|
||||
(assoc :start-showing? false)
|
||||
(assoc :shown? true))
|
||||
entities)]
|
||||
|
||||
(when (:shown? entities)
|
||||
(render! screen [(:fade entities) (:overlay entities)]))
|
||||
entities))
|
||||
|
||||
:show-screen (fn [screen [entities]]
|
||||
(assoc entities :start-showing? true))
|
||||
|
||||
:on-touch-down (fn [screen [entities]]
|
||||
(when (:shown? entities)
|
||||
(-> entities
|
||||
(assoc :shown? false)
|
||||
(assoc :start-showing? false))))
|
||||
|
||||
:on-resize (fn [screen entities]
|
||||
(size! screen 320 240)
|
||||
entities))
|
||||
@@ -9,6 +9,7 @@
|
||||
[advent.zone :as zone]
|
||||
[advent.utils :as utils]
|
||||
[advent.screens.dialogue :refer [talking-screen]]
|
||||
[advent.screens.inventory :refer [inventory-screen]]
|
||||
[clojure.core.async :refer [put! <! <!! >! chan go thread take! alts!!]])
|
||||
(:import [com.badlogic.gdx.graphics Pixmap Pixmap$Filter Texture Texture$TextureFilter GL20 GL30]
|
||||
[com.badlogic.gdx.graphics.g2d TextureRegion]
|
||||
@@ -40,21 +41,28 @@
|
||||
(satisfies? ICursorOverridable %))
|
||||
(get-in entities [:background :interactions]))))
|
||||
|
||||
(defn open-inventory [screen entities]
|
||||
(run! inventory-screen :show-screen))
|
||||
|
||||
|
||||
(defn left-click [screen entities]
|
||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})
|
||||
interaction (first (filter #(mouse-in? % [x y])
|
||||
(get-in entities [:background :interactions])))
|
||||
;; TODO - hacky way of resetting queue
|
||||
entities (if-let [current-action (get-in entities [:actions :current])]
|
||||
(assoc (actions/terminate current-action screen entities)
|
||||
:actions {:channel (chan) :current nil :started? false})
|
||||
entities)
|
||||
script (or (when interaction
|
||||
(get-script interaction [x y]))
|
||||
(get-script default-interaction [x y]))]
|
||||
|
||||
(script entities)
|
||||
entities))
|
||||
(let [{:keys [x y]} (input->screen screen {:x (:input-x screen) :y (:input-y screen)})]
|
||||
(if ((:mouse-in? (:inventory entities)) x y)
|
||||
(open-inventory screen entities)
|
||||
|
||||
(let [interaction (first (filter #(mouse-in? % [x y])
|
||||
(get-in entities [:background :interactions])))
|
||||
;; TODO - hacky way of resetting queue
|
||||
entities (if-let [current-action (get-in entities [:actions :current])]
|
||||
(assoc (actions/terminate current-action screen entities)
|
||||
:actions {:channel (chan) :current nil :started? false})
|
||||
entities)
|
||||
script (or (when interaction
|
||||
(get-script interaction [x y]))
|
||||
(get-script default-interaction [x y]))]
|
||||
|
||||
(script entities)
|
||||
entities))))
|
||||
|
||||
(defn flip [anim]
|
||||
(animation (animation! anim :get-frame-duration)
|
||||
@@ -242,7 +250,7 @@
|
||||
:cursor :down}}
|
||||
:layers [(assoc (texture "cat-tree/background.png") :x 0 :y 0 :baseline 0)
|
||||
(assoc (texture "cat-tree/tree-and-rock.png") :x 0 :y 0 :baseline 161)
|
||||
(assoc (texture "cat-tree/sillhoute.png") :x 0 :y 0 :baseline 9000)]
|
||||
(assoc (texture "cat-tree/sillhoute.png") :x 0 :y 0 :baseline 240)]
|
||||
:entities {}
|
||||
:collision "cat-tree/collision.png"
|
||||
:scale-fn (scaler-fn-with-baseline 110 0.10 1.20))
|
||||
@@ -302,6 +310,8 @@
|
||||
:override nil}
|
||||
:background (assoc-in (:outside-house backgrounds)
|
||||
[:entities :ego] (get-ego screen))
|
||||
:inventory (assoc (texture "inventory.png") :x 278 :y 0 :baseline 9000
|
||||
:mouse-in? (zone/box 278 0 320 42))
|
||||
:fps (assoc (label "0" (color :white) ) :x 5 :baseline 9000)}))
|
||||
|
||||
:on-render
|
||||
|
||||
Reference in New Issue
Block a user