blob: 45e8b397160583c627c8ff26875b69e3f5000f34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
(use-modules (2d agenda)
(2d coroutine)
(2d game)
(2d sprite)
(2d vector2)
(2d window))
(load "common.scm")
(define window-width 640)
(define window-height 480)
(define sprite (load-sprite "images/p1_front.png"
#:position (vector2 320 240)))
;; Simple script that moves the sprite to a random location every
;; second.
(coroutine
(while #t
(set-sprite-position!
sprite
(vector2 (random window-width)
(random window-height)))
(wait game-agenda 15)
(set-sprite-rotation! sprite (random 360))
(wait game-agenda 15)))
(add-hook! draw-hook (lambda (dt alpha) (draw-sprite sprite)))
(with-window (make-window #:title "Coroutines"
#:resolution (vector2 window-width
window-height))
(run-game-loop))
|