Design updates

This commit is contained in:
Nikita Lisitsa 2024-08-19 22:14:55 +03:00
parent d60af9ecd5
commit a3c008f807
2 changed files with 95 additions and 32 deletions

View file

@ -42,6 +42,7 @@ namespace gmtk
psemek_declare_enum(shape_type, std::uint32_t,
(circle)
(square)
(hexagon)
)
struct resource_type
@ -63,13 +64,13 @@ namespace gmtk
psemek_declare_enum(transformer_type, std::uint32_t,
(mixer)
(square_maker)
(reshaper)
(hue_shifter)
)
psemek_declare_enum(card_type, std::uint32_t,
(mixer)
(square_maker)
(reshaper)
(hue_shifter)
(crossing)
(zoomer)
@ -83,12 +84,12 @@ namespace gmtk
case color_type::white: return {255, 255, 255, 255};
case color_type::black: return {64, 64, 64, 255};
case color_type::gray: return {160, 160, 160, 255};
case color_type::red: return {255, 64, 64, 255};
case color_type::green: return {64, 255, 64, 255};
case color_type::blue: return {64, 64, 255, 255};
case color_type::cyan: return {64, 255, 255, 255};
case color_type::magenta: return {255, 64, 255, 255};
case color_type::yellow: return {255, 255, 64, 255};
case color_type::red: return {255, 96, 96, 255};
case color_type::green: return {96, 255, 96, 255};
case color_type::blue: return {96, 96, 255, 255};
case color_type::cyan: return {96, 255, 255, 255};
case color_type::magenta: return {255, 96, 255, 255};
case color_type::yellow: return {255, 255, 96, 255};
}
throw util::unknown_enum_value_exception{c};
@ -104,7 +105,7 @@ namespace gmtk
switch (type)
{
case transformer_type::mixer: return card_type::mixer;
case transformer_type::square_maker: return card_type::square_maker;
case transformer_type::reshaper: return card_type::reshaper;
case transformer_type::hue_shifter: return card_type::hue_shifter;
}
@ -116,7 +117,7 @@ namespace gmtk
switch (type)
{
case card_type::mixer: return transformer_type::mixer;
case card_type::square_maker: return transformer_type::square_maker;
case card_type::reshaper: return transformer_type::reshaper;
case card_type::hue_shifter: return transformer_type::hue_shifter;
default: return std::nullopt;
}
@ -126,7 +127,7 @@ namespace gmtk
struct recipe
{
boost::container::flat_set<resource_type> inputs;
boost::container::flat_multiset<resource_type> inputs;
resource_type output;
};
@ -139,10 +140,13 @@ namespace gmtk
{{{color_type::white, shape_type::circle}, {color_type::red, shape_type::circle}, {color_type::green, shape_type::circle}}, {color_type::yellow, shape_type::circle}},
{{{color_type::white, shape_type::circle}, {color_type::red, shape_type::circle}, {color_type::blue, shape_type::circle}}, {color_type::magenta, shape_type::circle}},
{{{color_type::white, shape_type::circle}, {color_type::green, shape_type::circle}, {color_type::blue, shape_type::circle}}, {color_type::cyan, shape_type::circle}},
{{{color_type::red, shape_type::square}, {color_type::green, shape_type::square}, {color_type::blue, shape_type::square}}, {color_type::white, shape_type::square}},
{{{color_type::cyan, shape_type::square}, {color_type::magenta, shape_type::square}, {color_type::yellow, shape_type::square}}, {color_type::black, shape_type::square}},
{{{color_type::white, shape_type::square}, {color_type::black, shape_type::square}}, {color_type::gray, shape_type::square}},
},
},
{
transformer_type::square_maker,
transformer_type::reshaper,
{
{{{color_type::gray, shape_type::circle}, {color_type::red, shape_type::circle}}, {color_type::red, shape_type::square}},
{{{color_type::gray, shape_type::circle}, {color_type::green, shape_type::circle}}, {color_type::green, shape_type::square}},
@ -150,6 +154,13 @@ namespace gmtk
{{{color_type::gray, shape_type::circle}, {color_type::cyan, shape_type::circle}}, {color_type::cyan, shape_type::square}},
{{{color_type::gray, shape_type::circle}, {color_type::magenta, shape_type::circle}}, {color_type::magenta, shape_type::square}},
{{{color_type::gray, shape_type::circle}, {color_type::yellow, shape_type::circle}}, {color_type::yellow, shape_type::square}},
// {{{color_type::white, shape_type::square}, {color_type::red, shape_type::square}}, {color_type::red, shape_type::hexagon}},
// {{{color_type::white, shape_type::square}, {color_type::green, shape_type::square}}, {color_type::green, shape_type::hexagon}},
// {{{color_type::white, shape_type::square}, {color_type::blue, shape_type::square}}, {color_type::blue, shape_type::hexagon}},
// {{{color_type::white, shape_type::square}, {color_type::cyan, shape_type::square}}, {color_type::cyan, shape_type::hexagon}},
// {{{color_type::white, shape_type::square}, {color_type::magenta, shape_type::square}}, {color_type::magenta, shape_type::hexagon}},
// {{{color_type::white, shape_type::square}, {color_type::yellow, shape_type::square}}, {color_type::yellow, shape_type::hexagon}},
},
},
{
@ -405,11 +416,17 @@ namespace gmtk
static stage_info stages[]
{
{{color_type::white, shape_type::circle}, 0, {}, {{color_type::white, shape_type::circle}}},
{{color_type::white, shape_type::circle}, 10, {card_type::mixer}, {{color_type::black, shape_type::circle}}},
{{color_type::gray, shape_type::circle}, 30, {card_type::hue_shifter, card_type::crossing}, {{color_type::red, shape_type::circle}}},
{{color_type::green, shape_type::circle}, 30, {card_type::square_maker, card_type::crossing}, {}},
{{color_type::white, shape_type::circle}, 15, {card_type::mixer}, {{color_type::black, shape_type::circle}}},
{{color_type::gray, shape_type::circle}, 15, {card_type::hue_shifter, card_type::crossing}, {{color_type::red, shape_type::circle}}},
{{color_type::green, shape_type::circle}, 15, {card_type::reshaper, card_type::crossing}, {}},
{{color_type::green, shape_type::square}, 30, {card_type::hue_shifter, card_type::crossing, card_type::zoomer}, {}},
{{color_type::blue, shape_type::square}, 30, {card_type::hue_shifter, card_type::crossing}, {}},
{{color_type::blue, shape_type::square}, 30, {card_type::mixer, card_type::crossing, card_type::zoomer}, {}},
{{color_type::yellow, shape_type::square}, 30, {card_type::zoomer}, {}},
{{color_type::magenta, shape_type::square}, 30, {}, {}},
{{color_type::cyan, shape_type::square}, 30, {card_type::reshaper, card_type::reshaper, card_type::zoomer}, {{color_type::black, shape_type::circle}}},
{{color_type::white, shape_type::square}, 45, {card_type::mixer, card_type::mixer, card_type::mixer, card_type::zoomer}, {{color_type::white, shape_type::circle}}},
{{color_type::black, shape_type::square}, 45, {card_type::mixer, card_type::mixer, card_type::reshaper, card_type::reshaper, card_type::reshaper, card_type::zoomer}, {{color_type::red, shape_type::circle}}},
{{color_type::gray, shape_type::square}, 60, {card_type::zoomer}, {}},
};
template <typename Component, util::uuid UUID>
@ -662,6 +679,21 @@ namespace gmtk
painter.rect(box, color);
}
break;
case shape_type::hexagon:
{
for (int i = 0; i < 2; ++i)
{
float r = (i == 0 ? 0.0875f : 0.0875f - 0.025f / std::sqrt(0.75f)) * scale;
auto c = (i == 0) ? bcolor : color;
for (int j = 0; j < 6; ++j)
{
float a = geom::rad(j * 60.f);
float b = geom::rad((j + 1) * 60.f);
painter.triangle(pos, pos + geom::direction(a) * r, pos + geom::direction(b) * r, c);
}
}
}
break;
}
}
@ -688,7 +720,7 @@ namespace gmtk
painter.triangle(box.corner(0.f, 0.5f), box.corner(1.f, 0.5f), box.corner(0.5f, 0.f), color);
painter.triangle(box.corner(0.f, 0.5f), box.corner(1.f, 0.5f), box.corner(0.5f, 1.f), color);
break;
case transformer_type::square_maker:
case transformer_type::reshaper:
painter.rect(box, color);
break;
case transformer_type::hue_shifter:
@ -717,7 +749,7 @@ namespace gmtk
draw_structure(bbox, crossing{}, painter);
break;
case card_type::mixer:
case card_type::square_maker:
case card_type::reshaper:
case card_type::hue_shifter:
draw_structure(bbox, transformer{card_to_transformer(type).value()}, painter);
break;
@ -900,8 +932,8 @@ namespace gmtk
return {"Mixer", "Mixes input colors"};
case card_type::hue_shifter:
return {"Hue shifter", "Shifts the hue of", " input colors"};
case card_type::square_maker:
return {"Squarer", "Turns circles into squares"};
case card_type::reshaper:
return {"Reshaper", "Turns circles into squares", " and squares into hexagons"};
case card_type::crossing:
return {"Bridge", "Allows belts to cross", " without merging"};
case card_type::zoomer:
@ -915,6 +947,7 @@ namespace gmtk
std::uint64_t make_seed()
{
return 15249261661545616321ull;
random::device d;
return (std::uint64_t(d()) << 32) | d();
}
@ -1002,7 +1035,7 @@ namespace gmtk
{
case card_type::mixer:
case card_type::hue_shifter:
case card_type::square_maker:
case card_type::reshaper:
map_.world.create(
vertex{*selected_},
transformer{card_to_transformer(*active_card_).value()}
@ -1114,6 +1147,21 @@ namespace gmtk
for (auto type : card_type_values())
map_.cards[type] += 10;
}
if (event.down && event.key == app::keycode::NUM_1)
{
time_speed_ = 1.f;
}
if (event.down && event.key == app::keycode::NUM_2)
{
time_speed_ = 2.f;
}
if (event.down && event.key == app::keycode::NUM_3)
{
time_speed_ = 3.f;
}
}
bool running() const override
@ -1128,7 +1176,7 @@ namespace gmtk
void update() override
{
float const dt = clock_.restart().count();
float const dt = clock_.restart().count() * time_speed_;
map_.spawn_timer += 3.f * dt;
if (map_.spawn_timer >= 1.f)
@ -1203,7 +1251,7 @@ namespace gmtk
map_.world.apply<vertex const, transformer>([&](vertex const & v, transformer & t)
{
boost::container::flat_map<resource_type, location> has_inputs;
boost::container::flat_multimap<resource_type, location> has_inputs;
auto c = v.location.down();
auto ce = map_.world.index<path_index>().get(c);
@ -1219,28 +1267,42 @@ namespace gmtk
if (auto occ = map_.world.get(*ne).get_if<occupied const>())
if (auto i = map_.world.get(occ->entity).get_if<item const>())
if (i->start == p)
has_inputs[i->type] = p;
has_inputs.insert({i->type, p});
}
bool crafted = false;
for (auto const & recipe : recipies.at(t.type))
{
bool has_all = true;
boost::container::flat_set<resource_type> input_types;
for (auto type : recipe.inputs)
has_all &= has_inputs.contains(type);
input_types.insert(type);
bool has_all = true;
for (auto type : input_types)
{
has_all &= (has_inputs.count(type) >= recipe.inputs.count(type));
}
if (!has_all)
continue;
for (auto type : recipe.inputs)
for (auto type : input_types)
{
auto l = has_inputs.at(type);
auto e = map_.world.index<path_index>().get(l);
auto re = map_.world.get(e).get<occupied>().entity;
auto it = has_inputs.lower_bound(type);
map_.world.detach<occupied>(e);
map_.world.destroy(re);
for (int i = 0; i < recipe.inputs.count(type); ++i)
{
auto l = it->second;
auto e = map_.world.index<path_index>().get(l);
auto re = map_.world.get(e).get<occupied>().entity;
map_.world.detach<occupied>(e);
map_.world.destroy(re);
++it;
}
}
auto r = map_.world.create(
@ -1754,6 +1816,7 @@ namespace gmtk
map map_;
util::clock<> clock_;
float time_speed_ = 1.f;
geom::vector<int, 2> screen_size_{1, 1};
geom::point<int, 2> mouse_{0, 0};

BIN
tree.xcf

Binary file not shown.