Skip to content

Commit

Permalink
Add another block (jumpthru)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlevasseur committed Feb 8, 2016
1 parent e7d6eff commit fb9fc0f
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 17 deletions.
66 changes: 53 additions & 13 deletions game/resources/level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,83 @@ level = {
},
objects = { --The entities template instances with their parameter fulfilled
{
id = 2,
template = "kenney_block",
id = 1,
template = "kenney_block_grass",
values = {
x = 80,
y = 350,
}
},
{
id = 3,
template = "kenney_block",
id = 2,
template = "kenney_block_grass",
values = {
x = 144,
y = 350,
}
},
{
id = 4,
template = "kenney_slope45",
id = 3,
template = "kenney_block_grass",
values = {
x = 208,
y = 286,
y = 350,
}
},
{
id = 5,
template = "kenney_block",
id = 4,
template = "kenney_block_grass",
values = {
x = 272,
y = 286,
y = 350,
}
},
{
id = 5,
template = "kenney_block_grass_center",
values = {
x = 80,
y = 414,
}
},
{
id = 6,
template = "kenney_block",
template = "kenney_block_grass_center",
values = {
x = 144,
y = 414,
}
},
{
id = 7,
template = "kenney_block_grass_center",
values = {
x = 208,
y = 414,
}
},
{
id = 8,
template = "kenney_block_grass_center",
values = {
x = 272,
y = 414,
}
},
{
id = 9,
template = "kenney_block_wood_platform",
values = {
x = 336,
y = 222,
x = 144,
y = 230,
}
},
{
id = 10,
template = "kenney_block_wood_platform",
values = {
x = 208,
y = 230,
}
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entity_template = {
name = "kenney_block",
name = "kenney_block_grass",
friendlyname = "Friendly name of template",

parameters = {
Expand Down
68 changes: 68 additions & 0 deletions game/resources/templates/kenney/block_grass_center.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
entity_template = {
name = "kenney_block_grass_center",
friendlyname = "Friendly name of template",

parameters = {
x = {
name = "X position",
component = "Position",
type = "number",
attribute = "x",
},
y = {
name = "Y position",
component = "Position",
type = "number",
attribute = "y",
},
},

components = {
["Position"] = {
x = 0,
y = 0,
width = 64,
height = 64
},
["Platform"] = {

},
["Hitbox"] = {
polygon = {
points = {
{
x = 0,
y = 0
},
{
x = 64,
y = 0
},
{
x = 64,
y = 64
},
{
x = 0,
y = 64
},
}
}
},
["Render"] = {
texture = "spritesheet_complete.png",
current_animation = "default",
animations = {
["default"] = {
total_duration = 1,
frames = {
{
rect = { left = 1690, top = 390, width = 128, height = 128},
relative_duration = 1,
},
},
},
},
}
}
}
68 changes: 68 additions & 0 deletions game/resources/templates/kenney/block_wood_platform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
entity_template = {
name = "kenney_block_wood_platform",
friendlyname = "Friendly name of template",

parameters = {
x = {
name = "X position",
component = "Position",
type = "number",
attribute = "x",
},
y = {
name = "Y position",
component = "Position",
type = "number",
attribute = "y",
},
},

components = {
["Position"] = {
x = 0,
y = 0,
width = 64,
height = 64
},
["Platform"] = {
platform_type = "Jumpthru",
},
["Hitbox"] = {
polygon = {
points = {
{
x = 0,
y = 0
},
{
x = 64,
y = 0
},
{
x = 64,
y = 16
},
{
x = 0,
y = 16
},
}
}
},
["Render"] = {
texture = "spritesheet_complete.png",
current_animation = "default",
animations = {
["default"] = {
total_duration = 1,
frames = {
{
rect = { left = 2340, top = 0, width = 128, height = 128},
relative_duration = 1,
},
},
},
},
}
}
}
4 changes: 2 additions & 2 deletions game/resources/templates/kenney/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ entity_template = {
points = {
{
x = 12,
y = 0
y = 50
},
{
x = 52,
y = 0
y = 50
},
{
x = 52,
Expand Down
13 changes: 12 additions & 1 deletion game/src/Components/PlatformComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ std::string PlatformComponent::getName() const

void PlatformComponent::registerComponent(lua::LuaState& state)
{
meta::MetadataStore::registerClass<PlatformComponent>();
meta::MetadataStore::registerClass<PlatformComponent>()
.setExtraLoadFunction([](PlatformComponent* platform, const sol::object& luaObject)
{
const sol::object& platformTypeLua = luaObject.as<sol::table>().get<sol::object>("platform_type");
if(platformTypeLua.is<std::string>())
{
if(platformTypeLua.as<std::string>() == "Platform")
platform->platformType = PlatformComponent::Platform;
else if(platformTypeLua.as<std::string>() == "Jumpthru")
platform->platformType = PlatformComponent::Jumpthru;
}
});

lua::EntityHandle::declareComponent<PlatformComponent>("Platform");

Expand Down

0 comments on commit fb9fc0f

Please sign in to comment.