memory leak slowed but still unacceptable
This commit is contained in:
parent
710bcdd2ce
commit
2658e75183
1 changed files with 17 additions and 12 deletions
29
main.scm
29
main.scm
|
@ -67,7 +67,8 @@
|
||||||
(foreign-procedure #f "BeginDrawing" () void))
|
(foreign-procedure #f "BeginDrawing" () void))
|
||||||
|
|
||||||
(define end-drawing
|
(define end-drawing
|
||||||
(foreign-procedure #f "EndDrawing" () void))
|
; doesn't help, but i'm pretty sure this *is* collect safe
|
||||||
|
(foreign-procedure __collect_safe "EndDrawing" () void))
|
||||||
|
|
||||||
; timing
|
; timing
|
||||||
(define set-target-fps
|
(define set-target-fps
|
||||||
|
@ -172,10 +173,11 @@
|
||||||
(vector2-x b))
|
(vector2-x b))
|
||||||
(+ (vector2-y a)
|
(+ (vector2-y a)
|
||||||
(vector2-y b))))
|
(vector2-y b))))
|
||||||
|
(define vector2-origin (vector2 0 0))
|
||||||
|
|
||||||
(define (vector2+ . vs)
|
(define (vector2+ . vs)
|
||||||
(fold-left vector2+-bin
|
(fold-left vector2+-bin
|
||||||
(vector2 0 0)
|
vector2-origin
|
||||||
vs))
|
vs))
|
||||||
|
|
||||||
; mouse
|
; mouse
|
||||||
|
@ -584,13 +586,6 @@
|
||||||
(square-flagged?-set! mouse-square (not (square-flagged? mouse-square))))
|
(square-flagged?-set! mouse-square (not (square-flagged? mouse-square))))
|
||||||
redraw?)
|
redraw?)
|
||||||
|
|
||||||
(define (draw-game-squares game skin pos)
|
|
||||||
(game-squares-for-each
|
|
||||||
(lambda (x y)
|
|
||||||
(let ([pos (vector2+ pos (vector2 (* x square-width) (* y square-width)))])
|
|
||||||
(blit-square skin (game-square-type-at game x y) pos)))
|
|
||||||
game))
|
|
||||||
|
|
||||||
(define (draw-write obj x y size color)
|
(define (draw-write obj x y size color)
|
||||||
(draw-text (with-output-to-string (lambda () (write obj)))
|
(draw-text (with-output-to-string (lambda () (write obj)))
|
||||||
x y size color))
|
x y size color))
|
||||||
|
@ -640,11 +635,19 @@
|
||||||
(draw-write `(middle released . ,(button-released? 'middle)) 1 90 10 color)
|
(draw-write `(middle released . ,(button-released? 'middle)) 1 90 10 color)
|
||||||
(draw-write `(right released . ,(button-released? 'right)) 1 100 10 color))
|
(draw-write `(right released . ,(button-released? 'right)) 1 100 10 color))
|
||||||
|
|
||||||
|
(define (draw-game-squares game skin pos)
|
||||||
|
(game-squares-for-each
|
||||||
|
(lambda (x y)
|
||||||
|
(let ([pos (vector2 (+ (vector2-x pos) (* x square-width))
|
||||||
|
(+ (vector2-y pos) (* y square-width)))])
|
||||||
|
(blit-square skin (game-square-type-at game x y) pos)))
|
||||||
|
game))
|
||||||
|
|
||||||
(define (game-draw game skin)
|
(define (game-draw game skin)
|
||||||
(draw-game-squares game skin (vector2 0 0)))
|
(draw-game-squares game skin vector2-origin))
|
||||||
; draw-game-over as a separate thing would be nice
|
; draw-game-over as a separate thing would be nice
|
||||||
|
|
||||||
; the game shows -99 when you (- num-mines num-flagged) is less than -99
|
; the game shows -99 when (- num-mines num-flagged) is less than -99
|
||||||
(define (run-game mines width height)
|
(define (run-game mines width height)
|
||||||
(init-window (* width square-width) (* height square-width) "mineschemer")
|
(init-window (* width square-width) (* height square-width) "mineschemer")
|
||||||
(set-target-fps 60)
|
(set-target-fps 60)
|
||||||
|
@ -662,7 +665,9 @@
|
||||||
; this saves a lot of resources
|
; this saves a lot of resources
|
||||||
(when (game-tick! game)
|
(when (game-tick! game)
|
||||||
; something leaks memory. huh!
|
; something leaks memory. huh!
|
||||||
(clear-background BLACK)
|
; methinks it's all those foreign vector2s
|
||||||
|
; seems so
|
||||||
|
;; (clear-background BLACK)
|
||||||
(game-draw game skin))
|
(game-draw game skin))
|
||||||
#;(draw-mouse-info BLACK)
|
#;(draw-mouse-info BLACK)
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in a new issue