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
|
[object_type]
id=wheel_rolling
zorder=-5
[editor_info]
category=platforms
[var]
name=left_x
type=x
value="x"
[/var]
[var]
name=right_x
type=x
value="x + img_w"
[/var]
[var]
name=nplatforms
value="3"
[/var]
# Inertia: the higher this is, the less frogatto will accellerate the wheel
[var]
name=inertia
value="20"
[/var]
# FIXME: friction is a misnomer, the higher the value, the more time it takes to slow down
# However, I can't think of a better name, with inertia already being taken
[var]
name=friction
value="10"
[/var]
[/editor_info]
[consts]
CENTER_OFFSET=40
# Rough math:
# radius = 40, circumference = 40 * 2 * pi ~ 250
# 250 / 360 ~ 1
# yeah, that's pretty ugly and almost 50% off
DISTANCE_PER_ANGLE=1
PLATFORM_X_DISTANCE=72
PLATFORM_Y_ADJUST=30
[/consts]
[vars]
shadow="[]"
platforms="[]"
rotation_speed="0"
[/vars]
[properties]
center_x=x+CENTER_OFFSET
[/properties]
on_create="[
map(
range(vars.nplatforms),
spawn('rope_platform',x,y,facing)
),
spawn('wheel_rolling_shadow',midpoint_x-10,midpoint_y-4,facing, [set('zorder', zorder-2)])
]"
on_child_spawned="[
if(child.type = 'rope_platform', set(vars.platforms, vars.platforms + [child])),
if(child.type = 'wheel_rolling_shadow', set(vars.shadow, [child]))
]"
# We only react to the player
# Original plan was to make the rotation speed cumulative,
# noncumulative seems to work better though
on_process="[
if((cycle%inertia) = 0, set(vars.rotation_speed, vars.rotation_speed - if(vars.rotation_speed > 0, 1, if(vars.rotation_speed < 0, -1, 0)))),
map(
vars.platforms,
'platform',
if(level.player.standing_on = platform,
set(vars.rotation_speed, #vars.rotation_speed + #(platform.x - center_x)/vars.inertia)
)
),
set(rotate, rotate + vars.rotation_speed),
set(x, x + vars.rotation_speed * DISTANCE_PER_ANGLE),
if(x < vars.left_x, set(x, vars.left_x)),
if(x > vars.right_x, set(x, vars.right_x)),
map(vars.shadow, 'shadow', [
set(shadow.rotate, rotate),
set(shadow.x, x)
]),
map(vars.platforms, 'platform', [
set(platform.midpoint_x, context.midpoint_x + (wave((if(angle <= 180, angle, angle - vars.rotation_speed)*1000)/360 + 250)*PLATFORM_X_DISTANCE)/1000),
set(platform.midpoint_y, PLATFORM_Y_ADJUST + context.midpoint_y + (wave((if(angle <= 180, angle, angle - vars.rotation_speed)*1000)/360)*PLATFORM_X_DISTANCE)/1000)
] where angle = (rotate + (index*360/vars.nplatforms))%360
)
]"
[animation]
image=props/wooden-wheel.png
id=normal
x=104
y=4
w=80
h=80
[/animation]
[/object_type]
|