Commit 26c42d3d authored by Hugo Hörnquist's avatar Hugo Hörnquist

Minimap.

parent 3c59d986
......@@ -144,8 +144,8 @@
((s) (set! (y player) = (+ (* dt 0.000003))) ret)
((a) (set! (x player) = (- (* dt 0.000003))) ret)
((d) (set! (x player) = (+ (* dt 0.000003))) ret)
((j) (set! (a player) = (- (* dt 0.000001))) ret)
((p) (set! (a player) = (+ (* dt 0.000001))) ret)
((j) (set! (a player) = (- (* dt 0.000003))) ret)
((p) (set! (a player) = (+ (* dt 0.000003))) ret)
(else ret)
))
#f (keys-down))
......@@ -154,8 +154,7 @@
(define (draw)
(define (draw-map)
(set-draw-color #xFF #xFF #xFF)
(clear)
......@@ -198,30 +197,58 @@
(+ (cos (a player)) (x player))
(+ (sin (a player)) (y player)))
(present))
;; (present)
)
(define (draw window rend)
(parameterize ((current-renderer rend))
(set-draw-color #xFF #xFF #xFF)
(clear)
(let ((texture (make-texture rend 'rgba8888 'target
(* 8 (current-tile-size))
(* 5 (current-tile-size)))))
(set-render-target! rend texture)
(set-draw-color #xFF #xFF #xFF)
(draw-map)
#;
(parameterize ((current-tile-size 16))
)
(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))))
(delete-texture! texture)
)
(present)
))
(define (main-loop window)
(define rend (make-renderer window))
(define last-t (get-t))
(parameterize ((current-renderer rend)
(current-tile-size 16))
(let loop ((counter 0))
(usleep (int (/ 1000000 (* 60 60))))
;; (sigaction SIGINT (lambda (sig) (set! looping #f)))
(if (= counter 60)
(begin (draw) (loop 0))
(begin (let ((dt (let ((t (get-t)))
(let ((dt (- t last-t)))
(set! last-t t)
dt))))
(format #t "Δr = ~a~%" dt)
(if (update dt)
'return
(loop (1+ counter)))))))))
(let loop ((counter 0))
(usleep (int (/ 1000000 (* 60 60))))
;; (sigaction SIGINT (lambda (sig) (set! looping #f)))
(if (= counter 60)
(begin (draw window rend) (loop 0))
(begin (let ((dt (let ((t (get-t)))
(let ((dt (- t last-t)))
(set! last-t t)
dt))))
(format #t "Δr = ~a~%" dt)
(if (update dt)
'return
(loop (1+ counter))))))))
(sdl-init)
......
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