summaryrefslogtreecommitdiff
path: root/README.org
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-07-19 18:32:22 -0400
committerDavid Thompson <dthompson2@worcester.edu>2013-07-19 18:32:22 -0400
commit63f0d14bc6f3a61a90c4776517b4adf2255b5f4d (patch)
tree68839214dc54007ef524e49e892129705dea0a56 /README.org
parent617ee3d5c397dabf775f68a710ea0dfdc830a547 (diff)
Fix typos and elaborate on coroutine example.
Diffstat (limited to 'README.org')
-rw-r--r--README.org26
1 files changed, 18 insertions, 8 deletions
diff --git a/README.org b/README.org
index 41480e7..e3f1ae7 100644
--- a/README.org
+++ b/README.org
@@ -63,7 +63,8 @@
** Features
*** Sprites
- Sprites encapsulate the presentation of a image or a region of an image.
+ Sprites encapsulate the presentation of an image or a region of an
+ image.
The simplest way to get started with sprites is to use the
=load-sprite= procedure. All arguments except the filename are
@@ -78,8 +79,7 @@
same keyword arguments in =load-sprite= are also available here.
#+BEGIN_SRC scheme
- (define texture
- (define sprite (make-sprite (load-texture "cirno.png"))))
+ (define sprite (make-sprite (load-texture "cirno.png")))
#+END_SRC
Position, scale, rotation, color, and anchor are mutable.
@@ -143,13 +143,23 @@
such that it does not halt further program execution.
#+BEGIN_SRC scheme
- (while #t
- (walk 'up)
- (wait 60)
- (walk 'down)
- (wait 60))
+ (agenda-schedule
+ (colambda ()
+ (while #t
+ (walk 'up)
+ (wait 60)
+ (walk 'down)
+ (wait 60))))
+
#+END_SRC
+ =colambda= is a useful macro that is syntactic sugar for a lambda
+ expression executed as a coroutine. =agenda-schedule= accepts a
+ thunk (a procedure that takes 0 arguments) and schedules it to be
+ executed later. In this example we do not provide a second
+ argument to =agenda-schedule=, which means that the thunk will be
+ executed upon the next game update.
+
Since guile-2d enforces a fixed timestep and updates 60 times per
second, waiting for 60 updates means that the NPC will wait one
second in between each step.