fix image smoothing

master
Josha von Gizycki 6 years ago
parent dddbec48c6
commit abcaf09b12

@ -138,6 +138,7 @@
then, it calls itself again with a delay according to the target fps" then, it calls itself again with a delay according to the target fps"
[gamestate] [gamestate]
(let [newstate (update-step gamestate)] (let [newstate (update-step gamestate)]
(set! (.-imageSmoothingEnabled (:ctx gamestate)) false)
(draw-step newstate) (draw-step newstate)
(when-not @reloaded (when-not @reloaded
(.setTimeout js/window (.setTimeout js/window
@ -150,13 +151,9 @@
(defn init-scenes (defn init-scenes
"initiates the scene data maps using their respective init functions" "initiates the scene data maps using their respective init functions"
[] []
(aset (:ctx gamestate) (as-> (:canvas gamestate) c
"imageSmoothingEnabled" (set! (.-width c) (get-in gamestate [:dimensions :w]))
false) (set! (.-height c) (get-in gamestate [:dimensions :h])))
(aset (:canvas gamestate)
"width" (get-in gamestate [:dimensions :w]))
(aset (:canvas gamestate)
"height" (get-in gamestate [:dimensions :h]))
(update gamestate (update gamestate
:scenes :scenes
#(reduce #(reduce

@ -16,7 +16,7 @@
scenestate scenestate
{:map-def {:images {:pokelike (by-id "demoscene-tileset")} {:map-def {:images {:pokelike (by-id "demoscene-tileset")}
:def nil :def nil
:zoom 4} :zoom 3}
:player {:x (- (/ (get-in gamestate [:dimensions :w]) 2) 32) :player {:x (- (/ (get-in gamestate [:dimensions :w]) 2) 32)
:y (- (/ (get-in gamestate [:dimensions :h]) 2) 32) :y (- (/ (get-in gamestate [:dimensions :h]) 2) 32)
:d :s :d :s

@ -1,8 +1,6 @@
(ns topdown2d.tileset (ns topdown2d.tileset
(:require [topdown2d.collision :as coll])) (:require [topdown2d.collision :as coll]))
(def ^:dynamic tileset)
(defn next-animation-cycle [animation curr-cycle] (defn next-animation-cycle [animation curr-cycle]
(let [curr-ix (.indexOf animation curr-cycle) (let [curr-ix (.indexOf animation curr-cycle)
next-ix (inc curr-ix) next-ix (inc curr-ix)

Loading…
Cancel
Save