From abcaf09b12b1dcacb083913e4c59e7937ea01296 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Wed, 24 Oct 2018 14:08:13 +0200 Subject: [PATCH] fix image smoothing --- src/cljs/topdown2d/core.cljs | 11 ++++------- src/cljs/topdown2d/demoscene.cljs | 2 +- src/cljs/topdown2d/tileset.cljs | 2 -- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/cljs/topdown2d/core.cljs b/src/cljs/topdown2d/core.cljs index aa06b81..4000b4d 100644 --- a/src/cljs/topdown2d/core.cljs +++ b/src/cljs/topdown2d/core.cljs @@ -138,6 +138,7 @@ then, it calls itself again with a delay according to the target fps" [gamestate] (let [newstate (update-step gamestate)] + (set! (.-imageSmoothingEnabled (:ctx gamestate)) false) (draw-step newstate) (when-not @reloaded (.setTimeout js/window @@ -150,13 +151,9 @@ (defn init-scenes "initiates the scene data maps using their respective init functions" [] - (aset (:ctx gamestate) - "imageSmoothingEnabled" - false) - (aset (:canvas gamestate) - "width" (get-in gamestate [:dimensions :w])) - (aset (:canvas gamestate) - "height" (get-in gamestate [:dimensions :h])) + (as-> (:canvas gamestate) c + (set! (.-width c) (get-in gamestate [:dimensions :w])) + (set! (.-height c) (get-in gamestate [:dimensions :h]))) (update gamestate :scenes #(reduce diff --git a/src/cljs/topdown2d/demoscene.cljs b/src/cljs/topdown2d/demoscene.cljs index b8b8fdf..d8649ba 100644 --- a/src/cljs/topdown2d/demoscene.cljs +++ b/src/cljs/topdown2d/demoscene.cljs @@ -16,7 +16,7 @@ scenestate {:map-def {:images {:pokelike (by-id "demoscene-tileset")} :def nil - :zoom 4} + :zoom 3} :player {:x (- (/ (get-in gamestate [:dimensions :w]) 2) 32) :y (- (/ (get-in gamestate [:dimensions :h]) 2) 32) :d :s diff --git a/src/cljs/topdown2d/tileset.cljs b/src/cljs/topdown2d/tileset.cljs index 70a06f7..2bd922e 100644 --- a/src/cljs/topdown2d/tileset.cljs +++ b/src/cljs/topdown2d/tileset.cljs @@ -1,8 +1,6 @@ (ns topdown2d.tileset (:require [topdown2d.collision :as coll])) -(def ^:dynamic tileset) - (defn next-animation-cycle [animation curr-cycle] (let [curr-ix (.indexOf animation curr-cycle) next-ix (inc curr-ix)