Commit 71a6ae86 authored by Hugo Hörnquist's avatar Hugo Hörnquist

Optimizations.

parent cbd0f972
......@@ -209,21 +209,22 @@
(let ((x (x player))
(y (y player)))
(for-each (lambda (a)
(let ((cv (cos a))
(sv (sin a)))
(apply draw-line x y
(let loop ((dx 0)
(dy 0))
(let ((ix (int (+ x dx)))
(iy (int (+ y dy))))
(if (or (not (and (< -1 ix board-width)
(< -1 iy board-height)))
(eq? 'wall (array-ref game-map iy ix)))
(list (+ x dx) (+ y dy))
(loop (+ dx (* 0.1 cv)) (+ dy (* 0.1 sv)))))))))
(iota ray-count (- (a player) (/ (fov player) 2))
(/ (fov player) ray-count))))
(for-each
(lambda (a)
(apply draw-line x y
(let loop ((dx 0)
(dy 0))
(let ((nx (+ x dx))
(ny (+ y dy)))
(let ((ix (int nx))
(iy (int ny)))
(if (or (not (and (<= 0 nx board-width)
(<= 0 ny board-height)))
(eq? 'wall (array-ref game-map iy ix)))
(list nx ny)
(loop (+ dx (* 0.1 (cos a))) (+ dy (* 0.1 (sin a))))))))))
(iota ray-count (- (a player) (/ (fov player) 2))
(/ (fov player) ray-count))))
(set-draw-color 0 #xFF 0)
......@@ -232,19 +233,12 @@
(+ (cos (a player)) (x player))
(+ (sin (a player)) (y player)))
(let ((nt (get-t)))
(let ((surf (render-font-solid (current-font) (format #f "FPS: ~,2f" (/ 1000000 (- nt fps-time)))
(make-color 0 0 0 #xFF))))
(render-copy (current-renderer) (surface->texture (current-renderer) surf)
#:dstrect (list 1 1
(surface-width surf)
(surface-height surf))))
(set! fps-time nt))
;; (present)
)
(define texture #f)
(define (draw window rend)
(parameterize ((current-renderer rend))
(set-draw-color #xFF #xFF #xFF)
......@@ -264,12 +258,23 @@
(set-render-target! rend #f)
(render-copy rend texture #:dstrect (list 0 0 (* 16 (current-tile-size)) (* 10 (current-tile-size))))
;; (render-copy rend texture #:dstrect (list 0 0 (* 2 (current-tile-size)) (* 2 (current-tile-size))))
(render-copy rend texture #:dstrect (list 0 0 (* 2 (current-tile-size)) (* 2 (current-tile-size))))
(delete-texture! texture)
)
(let ((nt (get-t)))
(let ((surf (render-font-solid (current-font) (format #f "FPS: ~,2f" (/ 1000000 (- nt fps-time)))
(make-color 0 0 0 #xFF))))
(render-copy (current-renderer) (surface->texture (current-renderer) surf)
#:dstrect (list 1 1
(surface-width surf)
(surface-height surf))))
(set! fps-time nt))
(present)
))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment