Fix some performance issues
This commit is contained in:
parent
d778b863ac
commit
72029078b7
4 changed files with 3 additions and 53 deletions
Binary file not shown.
|
@ -100,6 +100,8 @@
|
|||
(var newseed (+ (love.timer.getTime) mx my))
|
||||
(state.setSeed newseed)
|
||||
(set-mode :mode-play))
|
||||
(when (= key "f")
|
||||
(love.window.setFullscreen (not (love.window.getFullscreen))))
|
||||
(when (= key "x")
|
||||
(love.event.quit)))
|
||||
:mousemoved
|
||||
|
|
|
@ -52,58 +52,6 @@
|
|||
; Draw a big thing before everything else
|
||||
; (love.graphics.draw (. skybox 1 :t) -20 -20)
|
||||
|
||||
; CEILING/FLOOR CASTING
|
||||
(var cf-f-tex-num (. walls 2))
|
||||
(var cf-c-tex-num (. walls 2))
|
||||
; (var floor-texel (love.graphics.newQuad 0 0 1 1 (. cf-f-tex-num :w) (. cf-f-tex-num :h)))
|
||||
(for [i (/ screen-height 2) screen-height]
|
||||
; Set ray-dir for left-most (i = 0) and right-most (i = screen-width) rays
|
||||
(var (cf-ray-dir-x0 cf-ray-dir-y0) (values (- dirx planex) (- diry planey)))
|
||||
(var (cf-ray-dir-x1 cf-ray-dir-y1) (values (+ dirx planex) (+ diry planey)))
|
||||
|
||||
; Current y position compared to horizon
|
||||
(var cf-p (math.floor (/ (- i screen-height) 2)))
|
||||
|
||||
; Vertical position of the camera
|
||||
(var cf-pos-z (* 0.5 screen-height))
|
||||
|
||||
; Horizontal distance from camera to floor for current row
|
||||
(var cf-row-distance (/ cf-pos-z cf-p))
|
||||
|
||||
; Calculate step vectors
|
||||
(var cf-floor-step-x (/ (* cf-row-distance (- cf-ray-dir-x1 cf-ray-dir-x0)) screen-width))
|
||||
(var cf-floor-step-y (/ (* cf-row-distance (- cf-ray-dir-y1 cf-ray-dir-y0)) screen-width))
|
||||
|
||||
; Coordinates of left-most column, updated stepping to the right
|
||||
(var (cf-floor-x cf-floor-y) (values (+ posx (* cf-row-distance cf-ray-dir-x0))
|
||||
(+ posy (* cf-row-distance cf-ray-dir-y0))))
|
||||
|
||||
; Draw floor and ceiling
|
||||
(for [j 0 screen-width]
|
||||
; Get cell
|
||||
(var (cf-cell-x cf-cell-y) (values (math.floor cf-floor-x) (math.floor cf-floor-y)))
|
||||
|
||||
; Get texture coordinate from fractional part
|
||||
; CPP Code: wtf is the & doing there?
|
||||
; (var (cf-tx cf-ty) (values (math.floor (% (* tex-width (- cf-floor-x cf-cell-x)) tex-width))
|
||||
; (math.floor (% (* tex-height (- cf-floor-y cf-cell-y)) tex-height))))
|
||||
(var (cf-tx cf-ty) (values (math.floor (* tex-width (- cf-floor-x cf-cell-x)))
|
||||
(math.floor (* tex-height (- cf-floor-y cf-cell-y)))))
|
||||
|
||||
;; Draw the texture
|
||||
; (var tex-num cf-f-tex-num)
|
||||
; (love.graphics.draw (. tex-num :t)
|
||||
; (love.graphics.newQuad cf-tx 0 1 (. tex-num :h) (. tex-num :w) (. tex-num :h))
|
||||
; i cf-ty 0 1 (/ line-height (. tex-num :h)))
|
||||
; (love.graphics.draw (. cf-f-tex-num :t)
|
||||
; floor-texel
|
||||
; j i 0 1 1)
|
||||
|
||||
; Step
|
||||
(set cf-floor-x (+ cf-floor-x cf-floor-step-x))
|
||||
(set cf-floor-y (+ cf-floor-y cf-floor-step-y))
|
||||
)
|
||||
)
|
||||
; WALL CASTING
|
||||
(for [i 0 screen-width]
|
||||
; Calculate ray position and direction
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
; The Map table holds the map meta-data
|
||||
; [n] number of cells
|
||||
; [h w] hall and wall widths
|
||||
(var map {:n 10 :h 2 :w 2})
|
||||
(var map {:n 10 :h 3 :w 4})
|
||||
|
||||
{:getSeed (fn getSeed [] game.seed)
|
||||
:setSeed (fn setSeed [x] (set game.seed x))
|
||||
|
|
Loading…
Reference in a new issue