1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
[object_type]
id="bridge"
on_child_spawned="switch(child.type,
'bridge.anchor', [set(anchor, child), spawn('bridge.part', midpoint_x + (child.midpoint_x - midpoint_x)/2, midpoint_y + (child.midpoint_y - midpoint_y)/2, facing, [ set_var('left', me), set_var('right', child), set_var('spring_constant', spring_constant) ])],
'bridge.part', [set(parts, parts + [child]), if(parts.size < nparts - 1, spawn('bridge.part', midpoint_x + (anchor.midpoint_x - midpoint_x)/2, midpoint_y + (anchor.midpoint_y - midpoint_y)/2, facing, [set_var('left', child), set_var('right', anchor), set_var('spring_constant', spring_constant)])), if(parts.size > 0, set(rightmost.right,child))])"
on_create="spawn('bridge.anchor',other_x,other_y,facing)"
[editor_info]
category="crazy-stuff"
[var]
name="other_x"
type="x"
value="x + 100"
[/var]
[var]
name="other_y"
type="y"
value="y"
[/var]
[var]
name="nparts"
value="5"
[/var]
[var]
name="spring_constant"
value="5"
[/var]
[/editor_info]
[properties]
right_x="midpoint_x"
rightmost="parts[parts.size - 1]"
[/properties]
[vars]
anchor=""
parts="[]"
[/vars]
[animation]
frame_info="0,0,1,1,871,523,16,16"
id="normal"
image="compiled-0.png"
rect="871,523,887,539"
[/animation]
[object_type]
id="anchor"
[properties]
left_x="midpoint_x"
[/properties]
[animation]
id="normal"
image="props/spikedball.png"
rect="25,2,41,18"
[/animation]
[/object_type]
[object_type]
id="part"
on_process="[
#start comment##
set(force_x, 0), set(force_y, 0),
set_var('dx', (left.right_x - left_x) + (right.left_x - right_x)),
set_var('dy', (left.y - y) - (right.y _y)),
set_var('force', sqrt(dx^2 + dy^2)),
if(dy > 0, set_var('angle', acos(dx*10/dy)), set_var('angle',
TODO: trigonometric math here
##end comment#
set(force_x, (left.right_x - left_x)*spring_constant + (right.left_x - right_x)*spring_constant),
set(force_y, (left.y - y)*spring_constant + (right.y - y)*spring_constant + if(level.player.standing_on = me, PLAYER_WEIGHT, 0) + PART_WEIGHT),
set(velocity_x, velocity_x/2 + force_x),
set(velocity_y, velocity_y/2 + force_y)
]"
platform_area="0,3,48,10"
[consts]
PART_WEIGHT="25"
PLAYER_WEIGHT="150"
X_ADJUST="20"
[/consts]
[properties]
left_x="midpoint_x - X_ADJUST"
right_x="midpoint_x + X_ADJUST"
[/properties]
[vars]
force_x="0"
force_y="0"
[/vars]
[animation]
h="31"
id="normal"
image="props/rope.png"
w="48"
x="502"
y="144"
[/animation]
[/object_type]
[/object_type]
|