Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed up the conveyor belt

  • Loading branch information...
commit dbce1da593ce3aa3175725ed730ef7e99c68b63d 1 parent 5ab7efd
@davewx7 davewx7 authored
View
181 data/level/test.cfg
@@ -5,7 +5,7 @@
"background_offset": [0,0],
"character": [
{
- "_addr": "0x1185a00",
+ "_addr": "0x10e05e50",
"current_frame": "normal",
"custom": "yes",
"cycle": 5351,
@@ -21,7 +21,7 @@
"y": 352
},
{
- "_addr": "0x22e7d800",
+ "_addr": "0x10e064f8",
"current_frame": "normal",
"custom": "yes",
"cycle": 5351,
@@ -37,7 +37,7 @@
"y": 384
},
{
- "_addr": "0x1f491000",
+ "_addr": "0x10e06998",
"activation_area": [-1028,252,-509,515],
"current_frame": "normal",
"custom": "yes",
@@ -62,7 +62,7 @@
"y": 352
},
{
- "_addr": "0x1f490800",
+ "_addr": "0x10e06e38",
"activation_area": [-1412,92,-893,355],
"current_frame": "normal",
"custom": "yes",
@@ -87,7 +87,7 @@
"y": 192
},
{
- "_addr": "0x1f490c00",
+ "_addr": "0x10e0a328",
"current_frame": "stand",
"custom": "yes",
"cycle": 7095,
@@ -154,7 +154,7 @@
"y": 320
},
{
- "_addr": "0x1f492000",
+ "_addr": "0x10e0d940",
"current_frame": "normal",
"custom": "yes",
"face_right": 1,
@@ -177,7 +177,7 @@
"zorder": 1
},
{
- "_addr": "0x22e85a00",
+ "_addr": "0x10e0dde0",
"current_frame": "normal",
"custom": "yes",
"face_right": 1,
@@ -200,7 +200,7 @@
"zorder": 2
},
{
- "_addr": "0x22e8c600",
+ "_addr": "0x10e20e98",
"current_frame": "normal",
"custom": "yes",
"face_right": 1,
@@ -213,25 +213,170 @@
"y": 320
},
{
- "_addr": "0x22e8cc00",
+ "_addr": "0x10e21540",
"current_frame": "normal",
"custom": "yes",
"face_right": 1,
- "label": "_6a014e7c",
+ "label": "_1cc11c37",
"time_in_frame": 0,
"type": "conveyor_belt_dungeon",
"vars": {
- "right_edge": -56,
- "speed": 3,
- "x_1": -256,
- "x_2": 298,
- "y_1": 91,
- "y_2": 192
+ "bottom": "@eval deserialize('0x11a72c70')",
+ "right_edge": 40,
+ "speed": 2,
+ "supports": "@eval deserialize('0x11939200')",
+ "top": "@eval deserialize('0x119078f0')",
+ "wheel_left": "@eval deserialize('0x118e09a0')",
+ "wheel_right": "@eval deserialize('0x11a88f40')",
+ "x_1": -160,
+ "x_2": 165,
+ "y_1": 234,
+ "y_2": 173
},
"velocity_x": 0,
"velocity_y": 0,
- "x": -256,
- "y": 192
+ "x": -160,
+ "y": 96
+ },
+ {
+ "_addr": "0x10e21be8",
+ "current_frame": "dungeon-conveyor-belt-bottom",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_29e46499",
+ "time_in_frame": 0,
+ "type": "rope_angled_controller",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -164,
+ "y": 92,
+ "zorder": -4
+ },
+ {
+ "_addr": "0x10e27620",
+ "current_frame": "dungeon-conveyor-belt-supports",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_7fefa10a",
+ "time_in_frame": 0,
+ "type": "rope_angled_controller",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -164,
+ "y": 92,
+ "zorder": -3
+ },
+ {
+ "_addr": "0x10e27cc8",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_3552c6b3",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.belt",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -176,
+ "y": 176,
+ "zorder": -1
+ },
+ {
+ "_addr": "0x10e28370",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_159fd08e",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.wheel",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -187,
+ "y": 165,
+ "zorder": -2
+ },
+ {
+ "_addr": "0x10e28810",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_62089704",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.wheel",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": 211,
+ "y": 69,
+ "zorder": -2
+ },
+ {
+ "_addr": "0x11a72c70",
+ "current_frame": "dungeon-conveyor-belt-bottom",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_1b848454",
+ "time_in_frame": 0,
+ "type": "rope_angled_controller",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -164,
+ "y": 92,
+ "zorder": -4
+ },
+ {
+ "_addr": "0x11939200",
+ "current_frame": "dungeon-conveyor-belt-supports",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_7dee709e",
+ "time_in_frame": 0,
+ "type": "rope_angled_controller",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -164,
+ "y": 92,
+ "zorder": -3
+ },
+ {
+ "_addr": "0x119078f0",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_60ecddf4",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.belt",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -176,
+ "y": 218,
+ "zorder": -1
+ },
+ {
+ "_addr": "0x118e09a0",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_3fa258ff",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.wheel",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": -187,
+ "y": 207,
+ "zorder": -2
+ },
+ {
+ "_addr": "0x11a88f40",
+ "current_frame": "normal",
+ "custom": "yes",
+ "face_right": 1,
+ "label": "_a1d3b6f",
+ "time_in_frame": 0,
+ "type": "conveyor_belt_dungeon.wheel",
+ "velocity_x": 0,
+ "velocity_y": 0,
+ "x": 138,
+ "y": 146,
+ "zorder": -2
}
],
"dark_color": [0,1,2,3],
View
3  data/objects/effects/control/rope_angled_controller.cfg
@@ -7,6 +7,7 @@ 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,(offset_counter+pixels)%img_w)])",
+ offset: { get: "vars.offset_counter", set: "set(vars.offset_counter, value%img_w)" }
},
vars: {
@@ -105,4 +106,4 @@ animation: [
h: 16,
},
],
-}
+}
View
119 data/objects/props-interactive/obstacles/conveyor_belt_dungeon.cfg
@@ -3,86 +3,96 @@ 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,
- },
+ { 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",
},
-
-
-on_start_level: "[fire_event('setup')]",
+//on_start_level: "[fire_event('setup')]",
+on_editor_added: "[fire_event('setup')]",
on_setup: "[
- spawn('rope_angled_controller',x,y,facing,[set(animation,'dungeon-conveyor-belt-top'),set(vars.top, child),set(z,z-2)]),
- spawn('rope_angled_controller',x,y,facing,[set(animation,'dungeon-conveyor-belt-bottom'),set(vars.bottom, child),set(z,z-3)]),
- spawn('rope_angled_controller',x,y,facing,[set(animation,'dungeon-conveyor-belt-supports'),set(vars.supports, child),set(z,z-2)]),
-
- spawn(me.type+'.belt',x_1,y_1,facing,[set(vars.tttop, child),set(z,z-1)]),
- spawn(me.type+'.wheel',x_1,y_1,facing,[set(vars.wheel_left, child),set(z,z-1)]),
- spawn(me.type+'.wheel',x_2,y_2,facing,[set(vars.wheel_right, child),set(z,z-1)]),
- fire_event('on_calculate_segments')]",
+ spawn('rope_angled_controller',x,y,facing,[set(animation,'dungeon-conveyor-belt-bottom'),set(vars.bottom, child),add(z,-4)]),
+ spawn('rope_angled_controller',x,y,facing,[set(animation,'dungeon-conveyor-belt-supports'),set(vars.supports, child),add(z,-3)]),
+ spawn(me.type+'.belt',x_1,y_1,facing,[set(vars.top, child),add(z,-1)]),
+
+ 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: "[map([vars.top,vars.bottom,vars.supports,vars.wheel_left,vars.wheel_right], remove_object(value)), fire_event('setup')]",
-on_calculate_segments: "[ set(xy,[x_1-wheel_radius*1.5, y_1-wheel_radius*2.5]),
+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,16 - sqrt(16.0^2 - ((value-16.0)^2))]) +
+ map(reverse(range(11)), [0,(vars.wheel_right.y - vars.wheel_left.y) + 16 - sqrt(16.0^2 - ((value-16.0)^2))])))
+ 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]),
set(platform_area, [0,0,abs(x_2-x_1)/2 + 1.5*wheel_radius,1]),
set(platform_motion_x, vars.speed*67),
- set(progress,vars.speed),
+ add(progress,vars.speed),
+
+ top.set_offset(-cycle/2),
- top.set_offset(progress),
- top.set_ends(x_1,y_1-wheel_radius*2.5,x_2,y_2-wheel_radius*2.5),
+ top.set_ends(x_1 - wheel_radius*2,y_1-wheel_radius*2.5 - 16,x_2 + wheel_radius*2,y_2-wheel_radius*2.5),
- tttop.set_offset(progress),
- tttop.set_ends(x_1,y_1-wheel_radius*2.5,x_2,y_2-wheel_radius*2.5),
+ (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,16 - sqrt(16.0^2 - ((value-16.0)^2))]) +
+ map(reverse(range(11)), [0,(vars.wheel_right.y - vars.wheel_left.y) + 16 - sqrt(16.0^2 - ((value-16.0)^2))])))
+ 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),
supports.set_ends(x_1,y_1-wheel_radius*2.5 +24,x_2,y_2-wheel_radius*2.5+24),
- bottom.set_offset(progress),
+ set(bottom.offset, -progress/3),
bottom.set_ends(x_2,y_2+wheel_radius,x_1,y_1+wheel_radius),
- set(wheel_left.rotate, (wheel_left.rotate + progress)%360),
- set(wheel_right.rotate, (wheel_right.rotate + progress)%360),
+ add(wheel_left.rotate, vars.speed),
+ add(wheel_right.rotate, vars.speed),
set(platform_offsets, [0,y_2-y_1]),
]",
-on_process: "fire_event('calculate_segments')",
-
platform_area: [0,0,200,1],
animation: {
id: "normal",
@@ -112,14 +122,13 @@ object_type: [
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,(offset_counter+pixels)%img_w)])",
+ 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),
- set(draw_area, [offset_counter, 0, length/2, img_h/2]),
+ set(draw_area, [offset_counter, 0, (x_2 - x_1)/2, img_h/2]),
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#
- set(custom_draw, [0.0,1.0,2.0,3.0, [0,0], [length,(y_2-y_1)], [length,(y_2-y_1)+16], [0,0+16]])
]",
animation: {
View
6 src/formula_function.cpp
@@ -1156,6 +1156,12 @@ namespace {
}
};
+FUNCTION_DEF(reverse, 1, 1, "reverse(list): reverses the given list")
+ std::vector<variant> items = args()[0]->evaluate(variables).as_list();
+ std::reverse(items.begin(), items.end());
+ return variant(&items);
+END_FUNCTION_DEF(reverse)
+
FUNCTION_DEF(head, 1, 1, "head(list): gives the first element of a list, or null for an empty list")
const variant items = args()[0]->evaluate(variables);
if(items.num_elements() >= 1) {
View
9 src/variant.cpp
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <iostream>
#include <string.h>
+#include <sstream>
#include "boost/lexical_cast.hpp"
@@ -1181,7 +1182,13 @@ void variant::throw_type_error(variant::TYPE t) const
loc = formatter() << " at " << *info->filename << " " << info->line << " (column " << info->column << "\n";
}
- generate_error(formatter() << "type error: " << " expected " << variant_type_to_string(t) << " but found " << variant_type_to_string(type_) << " " << write_json() << loc);
+ std::ostringstream fmt;
+ try {
+ fmt << "type error: " << " expected " << variant_type_to_string(t) << " but found " << variant_type_to_string(type_) << " " << write_json() << loc;
+ } catch(...) {
+ fmt << " (COULD NOT SERIALIZE TYPE)\n";
+ }
+ generate_error(fmt.str());
}
void variant::serialize_to_string(std::string& str) const
Please sign in to comment.
Something went wrong with that request. Please try again.