numbers
This commit is contained in:
parent
b331907fa0
commit
a12a2d05fb
1 changed files with 28 additions and 13 deletions
37
main.scm
37
main.scm
|
@ -37,6 +37,8 @@
|
|||
(set-color-a! c a)
|
||||
c]))
|
||||
|
||||
(define WHITE (color 255 255 255 255))
|
||||
|
||||
;; (define c (color 1 2 3 4))
|
||||
;; (display (list (color-r c) (color-g c) (color-b c) (color-a c)))
|
||||
|
||||
|
@ -214,6 +216,8 @@
|
|||
|
||||
(define *skin-paths* '("./skins" "."))
|
||||
|
||||
; could be fun to do weird stuff with skins (randomly choosing, &c)
|
||||
|
||||
(define (load-skin filename)
|
||||
(define path
|
||||
(find file-exists?
|
||||
|
@ -227,25 +231,36 @@
|
|||
(with-output-to-string (lambda () (write *skin-paths*))))))
|
||||
(load-texture path))
|
||||
|
||||
(define skin-width 144)
|
||||
(define skin-height 122)
|
||||
|
||||
(define number-rects
|
||||
(let ([width (/ skin-width 9)])
|
||||
(list->vector
|
||||
(map (lambda (n)
|
||||
; the bottom and right sides are 1 pixel shy, it works out
|
||||
(rectangle (* n width) 0 width width))
|
||||
(iota 9)))))
|
||||
|
||||
(define (blit-number skin n pos)
|
||||
(let ([rect (vector-ref number-rects n)])
|
||||
(draw-texture-rec skin rect pos WHITE)))
|
||||
|
||||
(define (main)
|
||||
(init-window 100 100 "hello")
|
||||
(set-target-fps 60)
|
||||
|
||||
(let ([skin (load-texture "skins/xp-flowers.bmp")])
|
||||
(display skin)
|
||||
(newline)
|
||||
(let ([skin (load-skin "xp-flowers.bmp")])
|
||||
;; (display skin)
|
||||
;; (newline)
|
||||
|
||||
; with the actual game, we probably don't have to draw every time
|
||||
; with the actual game, we probably don't have to draw every time
|
||||
(until (window-should-close?)
|
||||
(with-draw
|
||||
(clear-background (color 245 245 245))
|
||||
(draw-texture-rec skin (rectangle 0 0 100) (vector2 0 0) (color 255 255 255))
|
||||
(draw-fps 0 0)
|
||||
(draw-text "wow awesome" 0 20 20 (color 0 0 0))))
|
||||
|
||||
(clear-background (color 0 0 0 0))
|
||||
(for-each (lambda (n)
|
||||
(blit-number skin n (vector2 (* 10 n) (* 10 n))))
|
||||
(iota 9))))
|
||||
(unload-texture skin)
|
||||
(close-window)))
|
||||
|
||||
(main)
|
||||
|
||||
|
|
Loading…
Reference in a new issue