Handbook
Glossary
chipmunk-world
Vocabulary
chipmunk
.
demo
Definition
USING:
game.worlds
;
IN:
chipmunk.demo
TUPLE:
chipmunk-world
<
game-world
space
;
Methods
USING:
accessors
chipmunk.demo
chipmunk.ffi
game.worlds
kernel
math
random
sequences
;
M::
chipmunk-world
begin-game-world
( world -- )
cpInitChipmunk
cpSpaceAlloc
cpSpaceInit
:>
space world space
>>space
drop
space 2.0 10000
cpSpaceResizeActiveHash
space 1
>>iterations
drop
image-height
<iota>
[|
y |
image-width
<iota>
[|
x |
x y
get-pixel
[
x
image-width
2
/
-
0.05
random-unit
*
+
2
*
image-height
2
/
y
-
0.05
random-unit
*
+
2
*
make-ball
:>
shape space shape
shape>>
body>>
cpSpaceAddBody
drop
space shape
cpSpaceAddShape
drop
]
when
]
each
]
each
space
cpBodyAlloc
1/0.
dup
cpBodyInit
cpSpaceAddBody
:>
body body -1000 -10
cpv
>>p
drop
body 400 0
cpv
>>v
drop
space
cpCircleShapeAlloc
[
body 8 0 0
cpv
cpCircleShapeInit
cpSpaceAddShape
drop
]
keep
:>
shape shape
shape>>
0
>>e
0
>>u
drop
;
USING:
accessors
alien
alien.c-types
alien.data
chipmunk.demo
chipmunk.ffi
classes.struct
kernel
opengl.gl
sequences
ui.gadgets.worlds
;
M::
chipmunk-world
draw-world*
( world -- )
1 1 1 0
glClearColor
GL_COLOR_BUFFER_BIT
glClear
GL_PROJECTION
glMatrixMode
glLoadIdentity
-320 320 -240 240 -1 1
glOrtho
0.5 0.5 0
glTranslatef
GL_VERTEX_ARRAY
glEnableClientState
world
space>>
:>
space 3
glPointSize
0 0 0
glColor3f
GL_POINTS
glBegin
space
bodies>>
[
num>>
]
[
arr>>
swap
void*
<c-direct-array>
]
bi
[
cpBody
memory>struct
p>>
[
x>>
]
[
y>>
]
bi
glVertex2f
]
each
glEnd
2
glPointSize
1 0 0
glColor3f
GL_POINTS
glBegin
space
arbiters>>
[
num>>
]
[
arr>>
swap
void*
<c-direct-array>
]
bi
[
cpArbiter
memory>struct
[
numContacts>>
]
[
contacts>>
>c-ptr
swap
cpContact
<c-direct-array>
]
bi
[
p>>
[
x>>
]
[
y>>
]
bi
glVertex2f
]
each
]
each
glEnd
;
USING:
accessors
chipmunk.demo
chipmunk.ffi
game.worlds
kernel
;
M:
chipmunk-world
end-game-world
space>>
[
cpSpaceFreeChildren
]
[
cpSpaceFree
]
bi
;
USING:
accessors
chipmunk.demo
chipmunk.ffi
game.worlds
generic
kernel
math
;
M:
chipmunk-world
tick-game-world
[
M\
chipmunk-world
tick-game-world
(call-next-method)
]
[
space>>
1.0 60.0
/
cpSpaceStep
]
bi
;