Skip to content

Commit 0145c6c

Browse files
author
andrea96
committedJan 6, 2018
added a scheduler sketch
1 parent 0bb6780 commit 0145c6c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
 

‎Scheduler.scm

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(module Scheduler
2+
((addActor)
3+
(tick))
4+
(import chicken scheme)
5+
(use srfi-1)
6+
7+
8+
(define actors '())
9+
10+
(define (addActor actionPoints callback)
11+
(set! actors (append! actors `((,actionPoints ,actionPoints ,callback)))))
12+
13+
(define (tick)
14+
(when (not (null? actors))
15+
(let* ((actor (car actors))
16+
(maxAP (car actor)) (actualAP (cadr actor)) (callback (caddr actor)))
17+
(if (= (- actualAP 1) 0)
18+
(begin
19+
(set! actors (append! actors `((,maxAP ,maxAP ,callback))))
20+
(callback))
21+
(set! actors (append! actors `((,maxAP ,(- actualAP 1) ,callback)))))
22+
(set! actors (cdr actors)))))
23+
24+
)

‎scmrl.setup

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
(compile -s -j Dungeon Dungeon.scm )
33
(compile -s -j Fov Fov.scm )
44
(compile -s -j Terminal Terminal.scm )
5+
(compile -s -j Scheduler Scheduler.scm )
56
(compile scmrl.scm)

0 commit comments

Comments
 (0)
Please sign in to comment.