Debian Codegraph @

demo/PyramidTopple.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 "ChipmunkDemo.h"cxx . . $ `<file>/demo/ChipmunkDemo.h`/
24
25 static void
26 updatecxx . . $ update(fa66a0a48611083e).(cpSpacecxx . . $ cpSpace# *space, double dt)
27 {
28 cpSpaceStepcxx . . $ cpSpaceStep(fa66a0a48611083e).(space, dt);
29 }
30
31 #define WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`! 4.0f
32 #define HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! 30.0f
33
34 static void
35 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(cpSpacecxx . . $ cpSpace# *space, cpVectcxx . . $ cpVect# pos, cpBoolcxx . . $ cpBool# flipped)
36 {
37 cpFloatcxx . . $ cpFloat# mass = 1.0f;
38 cpFloatcxx . . $ cpFloat# radius = 0.5f;
39 cpFloatcxx . . $ cpFloat# moment = cpMomentForBoxcxx . . $ cpMomentForBox(7678bba071383ab).(mass, WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!, HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!);
40
41 cpBodycxx . . $ cpBody# *body = cpSpaceAddBodycxx . . $ cpSpaceAddBody(1a8396fd971b33e7).(space, cpBodyNewcxx . . $ cpBodyNew(51915e6cc8310751).(mass, moment));
42 cpBodySetPositioncxx . . $ cpBodySetPosition(864e17bcbe059b08).(body, pos);
43
44 cpShapecxx . . $ cpShape# *shape = (flipped ? cpBoxShapeNewcxx . . $ cpBoxShapeNew(94c4f8982441e75a).(body, HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!, WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!, 0.0) : cpBoxShapeNewcxx . . $ cpBoxShapeNew(94c4f8982441e75a).(body, WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`! - radius*2.0f, HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!, radius));
45 cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, shape);
46 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 0.0f);
47 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 0.6f);
48 }
49
50 static cpSpacecxx . . $ cpSpace# *
51 initcxx . . $ init(1f0082e822a7ce76).(void)
52 {
53 cpSpacecxx . . $ cpSpace# *space = cpSpaceNewcxx . . $ cpSpaceNew(1f0082e822a7ce76).();
54 cpSpaceSetIterationscxx . . $ cpSpaceSetIterations(3274f250b6e81e27).(space, 30);
55 cpSpaceSetGravitycxx . . $ cpSpaceSetGravity(7561685522e3e327).(space, cpvcxx . . $ cpv(3142d57d978b2176).(0, -300));
56 cpSpaceSetSleepTimeThresholdcxx . . $ cpSpaceSetSleepTimeThreshold(fa66a0a48611083e).(space, 0.5f);
57 cpSpaceSetCollisionSlopcxx . . $ cpSpaceSetCollisionSlop(fa66a0a48611083e).(space, 0.5f);
58
59 // Add a floor.
60 cpShapecxx . . $ cpShape# *shape = cpSpaceAddShapecxx . . $ cpSpaceAddShape(a8063921f8ae51c0).(space, cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(cpSpaceGetStaticBodycxx . . $ cpSpaceGetStaticBody(d6ad68aaf406e51f).(space), cpvcxx . . $ cpv(3142d57d978b2176).(-600,-240), cpvcxx . . $ cpv(3142d57d978b2176).(600,-240), 0.0f));
61 cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(shape, 1.0f);
62 cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(shape, 1.0f);
63 cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(shape, NOT_GRABBABLE_FILTERcxx . . $ NOT_GRABBABLE_FILTER.);
64
65
66 // Add the dominoes.
67 int n = 12;
68 for(int i=0; i<n; i++){
69 for(int j=0; j<(n - i); j++){
70 cpVectcxx . . $ cpVect# offset = cpvcxx . . $ cpv(3142d57d978b2176).((j - (n - 1 - i)*0.5f)*1.5f*HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!, (i + 0.5f)*(HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! + 2*WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!) - WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`! - 240);
71 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(space, offset, cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!);
72 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(space, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(offset, cpvcxx . . $ cpv(3142d57d978b2176).(0, (HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! + WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!)/2.0f)), cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
73
74 if(j == 0){
75 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(space, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(offset, cpvcxx . . $ cpv(3142d57d978b2176).(0.5f*(WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`! - HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!), HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! + WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!)), cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!);
76 }
77
78 if(j != n - i - 1){
79 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(space, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(offset, cpvcxx . . $ cpv(3142d57d978b2176).(HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`!*0.75f, (HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! + 3*WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!)/2.0f)), cpTruecxx . . $ `include/chipmunk/chipmunk_types.h:183:10`!);
80 } else {
81 add_dominocxx . . $ add_domino(f29a2d9b353a950f).(space, cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(offset, cpvcxx . . $ cpv(3142d57d978b2176).(0.5f*(HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! - WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!), HEIGHTcxx . . $ `demo/PyramidTopple.c:32:9`! + WIDTHcxx . . $ `demo/PyramidTopple.c:31:9`!)), cpFalsecxx . . $ `include/chipmunk/chipmunk_types.h:188:10`!);
82 }
83 }
84 }
85
86 return space;
87 }
88
89 static void
90 destroycxx . . $ destroy(728b9c9a69722ef8).(cpSpacecxx . . $ cpSpace# *space)
91 {
92 ChipmunkDemoFreeSpaceChildrencxx . . $ ChipmunkDemoFreeSpaceChildren(728b9c9a69722ef8).(space);
93 cpSpaceFreecxx . . $ cpSpaceFree(728b9c9a69722ef8).(space);
94 }
95
96 ChipmunkDemocxx . . $ ChipmunkDemo# PyramidTopplecxx . . $ PyramidTopple. = {
97 "Pyramid Topple",
98 1.0/180.0,
99 initcxx . . $ init(1f0082e822a7ce76).,
100 updatecxx . . $ update(fa66a0a48611083e).,
101 ChipmunkDemoDefaultDrawImplcxx . . $ ChipmunkDemoDefaultDrawImpl(728b9c9a69722ef8).,
102 destroycxx . . $ destroy(728b9c9a69722ef8).,
103 };