Debian Codegraph @

demo/PyramidStack.c

raw symbols SCIP
1 /* Copyright (c) 2007 Scott Lembcke
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 * SOFTWARE.
20 */
21
22 #include "chipmunk/chipmunk.h"cxx . . $ `<file>/include/chipmunk/chipmunk.h`/
23 #include "chipmunk/chipmunk_unsafe.h"cxx . . $ `<file>/include/chipmunk/chipmunk_unsafe.h`/
24 #include "ChipmunkDemo.h"cxx . . $ `<file>/demo/ChipmunkDemo.h`/
25
26 static void
27 updatecxx . . $ update(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, double dt)
28 {
29 cpSpaceStepcxx . . $ cpSpaceStep(fa66a0a48611083e).(space, dt);
30 }
31
32 static cpSpacecxx . . $ cpSpace# *
33 initcxx . . $ init(1f0082e822a7ce76).(void)
34 {
35 cpSpacecxx . . $ cpSpace# *space = cpSpaceNewcxx . . $ cpSpaceNew(1f0082e822a7ce76).();
36 cpSpaceSetIterationscxx . . $ cpSpaceSetIterations(3274f250b6e81e27).(space, 30);
37 cpSpaceSetGravitycxx . . $ cpSpaceSetGravity(7561685522e3e327).(space, cpvcxx . . $ cpv(3142d57d978b2176).(0, -100));
38 cpSpaceSetSleepTimeThresholdcxx . . $ cpSpaceSetSleepTimeThreshold(fa66a0a48611083e).(space, 0.5f);
39 cpSpaceSetCollisionSlopcxx . . $ cpSpaceSetCollisionSlop(fa66a0a48611083e).(space, 0.5f);
40
41 cpBodycxx . . $ cpBody# *body, *staticBody = cpSpaceGetStaticBodycxx . . $ cpSpaceGetStaticBody(d6ad68aaf406e51f).(space);
42 cpShapecxx . . $ cpShape# *shape;
43
44 // Create segments around the edge of the screen.
45 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(-320,240), 0.0f));
46 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
47 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
48 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
49
50 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(320,240), 0.0f));
51 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
52 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
53 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
54
55 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(staticBody, cpvcxx . . $ cpv(3142d57d978b2176).(-320,-240), cpvcxx . . $ cpv(3142d57d978b2176).(320,-240), 0.0f));
56 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
57 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
58 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
59
60 // Add lots of boxes.
61 for(int i=0; i<14; i++){
62 for(int j=0; j<=i; j++){
63 body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(1.0f, cpMomentForBoxcxx . . $ cpMomentForBox(7678bba071383ab).(1.0f, 30.0f, 30.0f)));
64 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvcxx . . $ cpv(3142d57d978b2176).(j*32 - i*16, 300 - i*32));
65
66 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpBoxShapeNewcxx . . $ cpBoxShapeNew(94c4f8982441e75a).(body, 30.0f, 30.0f, 0.5f));
67 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
68 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.8f);
69 }
70 }
71
72 // Add a ball to make things more interesting
73 cpFloatcxx . . $ cpFloat# radius = 15.0f;
74 body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(10.0f, cpMomentForCirclecxx . . $ cpMomentForCircle(a539e2d95614f770).(10.0f, 0.0f, radius, cpvzerocxx . . $ cpvzero.)));
75 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, cpvcxx . . $ cpv(3142d57d978b2176).(0, -240 + radius+5));
76
77 shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpCircleShapeNewcxx . . $ cpCircleShapeNew(e5e4e3a52c89533b).(body, radius, cpvzerocxx . . $ cpvzero.));
78 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
79 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.9f);
80
81 return space;
82 }
83
84 static void
85 destroycxx . . $ destroy(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
86 {
87 ChipmunkDemoFreeSpaceChildrencxx . . $ ChipmunkDemoFreeSpaceChildren(728b9c9a69722ef8).(space);
88 cpSpaceFreecxx . . $ cpSpaceFree(728b9c9a69722ef8).(space);
89 }
90
91 ChipmunkDemocxx . . $ ChipmunkDemo# PyramidStackcxx . . $ PyramidStack. = {
92 "Pyramid Stack",
93 1.0/180.0,
94 initcxx . . $ init(1f0082e822a7ce76).,
95 updatecxx . . $ update(fa66a0a48611083e).,
96 ChipmunkDemoDefaultDrawImplcxx . . $ ChipmunkDemoDefaultDrawImpl(728b9c9a69722ef8).,
97 destroycxx . . $ destroy(728b9c9a69722ef8).,
98 };