beginning on inventory screen.

This commit is contained in:
2014-09-20 22:26:46 -07:00
parent d45d4de403
commit 19fb2e6ebe
9 changed files with 77 additions and 16 deletions

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

View File

@@ -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)))

View 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))

View File

@@ -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