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)
|
(set-color-a! c a)
|
||||||
c]))
|
c]))
|
||||||
|
|
||||||
|
(define WHITE (color 255 255 255 255))
|
||||||
|
|
||||||
;; (define c (color 1 2 3 4))
|
;; (define c (color 1 2 3 4))
|
||||||
;; (display (list (color-r c) (color-g c) (color-b c) (color-a c)))
|
;; (display (list (color-r c) (color-g c) (color-b c) (color-a c)))
|
||||||
|
|
||||||
|
@ -214,6 +216,8 @@
|
||||||
|
|
||||||
(define *skin-paths* '("./skins" "."))
|
(define *skin-paths* '("./skins" "."))
|
||||||
|
|
||||||
|
; could be fun to do weird stuff with skins (randomly choosing, &c)
|
||||||
|
|
||||||
(define (load-skin filename)
|
(define (load-skin filename)
|
||||||
(define path
|
(define path
|
||||||
(find file-exists?
|
(find file-exists?
|
||||||
|
@ -227,25 +231,36 @@
|
||||||
(with-output-to-string (lambda () (write *skin-paths*))))))
|
(with-output-to-string (lambda () (write *skin-paths*))))))
|
||||||
(load-texture path))
|
(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)
|
(define (main)
|
||||||
(init-window 100 100 "hello")
|
(init-window 100 100 "hello")
|
||||||
(set-target-fps 60)
|
(set-target-fps 60)
|
||||||
|
|
||||||
(let ([skin (load-texture "skins/xp-flowers.bmp")])
|
(let ([skin (load-skin "xp-flowers.bmp")])
|
||||||
(display skin)
|
;; (display skin)
|
||||||
(newline)
|
;; (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?)
|
(until (window-should-close?)
|
||||||
(with-draw
|
(with-draw
|
||||||
(clear-background (color 245 245 245))
|
(clear-background (color 0 0 0 0))
|
||||||
(draw-texture-rec skin (rectangle 0 0 100) (vector2 0 0) (color 255 255 255))
|
(for-each (lambda (n)
|
||||||
(draw-fps 0 0)
|
(blit-number skin n (vector2 (* 10 n) (* 10 n))))
|
||||||
(draw-text "wow awesome" 0 20 20 (color 0 0 0))))
|
(iota 9))))
|
||||||
|
|
||||||
(unload-texture skin)
|
(unload-texture skin)
|
||||||
(close-window)))
|
(close-window)))
|
||||||
|
|
||||||
(main)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue