{ id: "conveyor_belt_dungeon", editor_info: { category: "platforms", var: [ { name: "x_1", type: "x", value: "x", }, { name: "y_1", type: "y", value: "y", }, { name: "x_2", type: "x", value: "x+200", }, { name: "y_2", type: "y", value: "y", }, { name: "right_edge", type: "x", value: "x+200", }, { name: "speed", value: 2, }, ], }, zorder:-5, hidden_in_game: true, properties: { length: "length(x_1,y_1,x_2,y_2)", wheel_radius: "27/2", actB: "max(abs(x_2-x_1),abs(y_2-y_1)*2)" }, on_create: "[fire_event('setup'),set(activation_border,actB)]", on_setup: "[ spawn(me.type+'.belt',x_1,y_1,facing,[set(vars.supports, child), add(child.z,-6), set(child.animation, 'supports')]), spawn(me.type+'.belt',x_1,y_1,facing,[set(vars.bottom, child), add(child.z,-5), set(child.animation, 'bottom')]), spawn(me.type+'.belt',x_1,y_1,facing,[set(vars.top, child),add(child.z,-5)]), spawn(me.type+'.wheel',x_1,y_1,facing,[set(vars.wheel_left, child),add(z,-2)]), spawn(me.type+'.wheel',x_2,y_2,facing,[set(vars.wheel_right, child),add(z,-2)]), fire_event('calculate_segments')]", on_editor_changed_variable: "[ if(vars.top, [map([vars.top,vars.bottom,vars.supports,vars.wheel_left,vars.wheel_right], remove_object(value)), fire_event('setup')]), fire_event('calculate_segments'), ]", on_calculate_segments: "[set(top.custom_draw, //The list of points around, with concentration on the curves on each end. (items + map(items, 2 + value) where items = [v*curve_len/10.0 | v <- range(11)] + [(1.0 - curve_len) + v*curve_len/10.0 | v <- range(11)]) + //the vertical offsets, creating a curve at each end. (vertical_offsets + reverse(vertical_offsets) where vertical_offsets = map(range(11), [0,22 - sqrt(22.0^2 - ((value-22.0)^2))]) + map(reverse(range(11)), [0,(vars.wheel_right.y - vars.wheel_left.y) + 22 - sqrt(22.0^2 - ((value-22.0)^2))]))), set(bottom.custom_draw, [0,1,2,3, [0,0], [0,voffset], [0,voffset], [0,0]] where voffset = vars.wheel_right.y - vars.wheel_left.y), set(supports.custom_draw, [0,1,2,3, [0,0], [0,voffset], [0,voffset], [0,0]] where voffset = vars.wheel_right.y - vars.wheel_left.y), set(platform_motion_x, vars.speed*67), set(platform_offsets, [0,y_2-y_1]), set(platform_area, [0,0,abs(x_2-x_1)/2 + 1.5*wheel_radius,1]), if(bottom.set_ends, [ //Needed for the editor. bottom.set_ends(x_1,y_1+wheel_radius - 16,x_2,y_2-wheel_radius*2.5), top.set_ends(x_1 - wheel_radius*2,y_1-wheel_radius*2.5 - 24,x_2 + wheel_radius*2,y_2-wheel_radius*2.5), supports.set_ends(x_1,y_1+wheel_radius - 44,x_2,y_2-wheel_radius*2.5), ]) ] where curve_len = wheel_radius*2.0/ (wheel_radius*4.0 + (x_2 - x_1)), vertical_adj = 16.0, vertical_off = vars.wheel_right.y - vars.wheel_left.y", on_process: "[ set(xy,[x_1-wheel_radius*1.5, y_1-wheel_radius*2.5]), add(progress,vars.speed), top.set_offset(-(cycle*vars.speed)/4), fire_event(top, 'update_draw_area'), bottom.set_offset((cycle*vars.speed)/4), fire_event(bottom, 'update_draw_area'), fire_event(supports, 'update_draw_area'), add(wheel_left.rotate, vars.speed), add(wheel_right.rotate, vars.speed), ]", platform_area: [0,0,200,1], animation: { id: "normal", image: "effects/particles.png", x: 86, y: 73, w: 28, h: 28, collide: [0,0,28,28], frames: 1, duration: 1000, palettes: "@include data/palettes.cfg:dungeon_palettes", }, object_type: [ { id: "wheel", animation: { id: "normal", image: "props/dungeon-conveyor-belt-wheel.png", x: 0, y: 0, w: 27, h: 27, palettes: "@include data/palettes.cfg:dungeon_palettes", }, }, { id: "belt", properties: { length: "length(x_1,y_1,x_2,y_2)", set_ends: "def(new_x1,new_y1,new_x2,new_y2) [set(vars.x_1,new_x1),set(vars.y_1,new_y1),set(vars.x_2,new_x2),set(vars.y_2,new_y2),fire_event(me,'create'),]", set_offset: "def(pixels) execute(me, [set(draw_area, [0, pixels, img_w/2, length/2]), set(offset_counter, pixels%img_w)])", }, on_create: "[ set(x, x_1), set(y, y_1), fire_event('update_draw_area'), set(activation_area, [min(x_1,x_2) -200, min(y_1,y_2) -200, abs(x_1-x_2) +200, abs(y_1-y_2) +200]), #xywh# ]", on_update_draw_area: "set(draw_area, [offset_counter, 0, (x_2 - x_1)/2, img_h/2])", animation: [ { id: "normal", image: "props/dungeon-conveyor-belt-top.png", x: 0, y: 0, w: 16, h: 16, palettes: "@include data/palettes.cfg:dungeon_palettes", }, { id: "bottom", image: "props/dungeon-conveyor-belt-bottom.png", x: 0, y: 0, w: 16, h: 16, palettes: "@include data/palettes.cfg:dungeon_palettes", }, { rect: [0,0,31,15], id: "supports", image: "props/dungeon-conveyor-belt-supports.png", palettes: "@include data/palettes.cfg:dungeon_palettes", }, ], }, ], }