wiggle proof

This commit is contained in:
mehbark 2023-12-23 13:22:25 -05:00
parent d981990978
commit 4f0756cbe9

View file

@ -158,12 +158,26 @@
(define (set-vector2-x! vec2 x) (ftype-set! Vector2 (x) vec2 (exact->inexact x)))
(define (set-vector2-y! vec2 y) (ftype-set! Vector2 (y) vec2 (exact->inexact y)))
(define (vector2-x vec2) (ftype-ref Vector2 (x) vec2))
(define (vector2-y vec2) (ftype-ref Vector2 (y) vec2))
(define (vector2 x y)
(define vec2 (make-ftype-pointer Vector2 (foreign-alloc (ftype-sizeof Vector2))))
(set-vector2-x! vec2 x)
(set-vector2-y! vec2 y)
vec2)
(define (vector2+-bin a b)
(vector2 (+ (vector2-x a)
(vector2-x b))
(+ (vector2-y a)
(vector2-y b))))
(define (vector2+ . vs)
(fold-left vector2+-bin
(vector2 0 0)
vs))
; adapted from https://github.com/Yunoinsky/chez-raylib/blob/main/src/raylib.sls
(define load-image
(let ([f (foreign-procedure #f "LoadImage"
@ -368,10 +382,11 @@
gap
gap))
(define *t* 0.0)
(define (blit-from-skin skin rect pos)
;; (display skin) (display " ") (display rect) (display " ") (display pos)
;; (newline)
(draw-texture-rec skin rect pos WHITE))
(draw-texture-rec skin rect (vector2+ pos (vector2 (* (random 4) (sin *t*)) (* (random 4) (cos *t*)))) WHITE))
(define (blit-number skin n pos)
(let ([rect (vector-ref number-rects n)])
@ -443,9 +458,12 @@
; with the actual game, we almost certainly don't have to redraw everything every time
(until (window-should-close?)
(set! h (+ 1 h))
(set! *t* (+ *t* (get-frame-time)))
(with-draw
(clear-background (color-from-hsv h 1.0 1.0))
(redraw-skin skin)))
(unload-texture skin)
(close-window)))
; let's save playing with shaders for later