end
</attack>
</item>
-<item name="Hunters Bow" type="Bow" drawOffset="5,16" maxStackSize="1" sprite="assets/items/bow.png" cooldown="600">
+<item name="Hunters Bow" type="Bow" drawOffset="5,16" maxStackSize="1" sound="assets/sounds/shortSwing.wav" sprite="assets/items/bow.png" cooldown="600">
<attack effect="assets/effects/starAttack.gif">
effect = function()
flash(255, 0, 255)
#include "base.hpp"
+#include <SDL2/SDL_mixer.h>
+
/**
* @struct Health
* @brief Gives and entity health and stuff.
int health; /**< The current amount of health */
int maxHealth; /**< The maximum amount of health */
+ Mix_Chunk* ouch; /**< Sound made when attacked */
void fromXML(XMLElement* imp, XMLElement* def) final {
(void)imp;
if (def->QueryIntAttribute("value", &health) != XML_NO_ERROR)
health = 1;
maxHealth = health;
+ auto o = def->Attribute("ouch");
+ if (o != nullptr)
+ ouch = Mix_LoadWAV(o);
+ else
+ ouch = nullptr;
}
};
auto frames = developFrame(def);
if (!frames.empty())
sprite = frames.at(0);
+ faceLeft = false;
}
Frame sprite;
{
static bool worldReset = false, worldDontReallyRun = false;
std::string worldActuallyUseThisXMLFile;
+ std::string worldActuallyUseThisXMLFolder;
// handle command line args
if (argc > 1) {
worldDontReallyRun = true;
else if (s == "--xml" || s == "-x")
worldActuallyUseThisXMLFile = argv[i + 1];
+ else if (s == "--folder" || s == "-f")
+ worldActuallyUseThisXMLFolder = argv[i + 1];
}
}
game::briceLoad();
game::briceUpdate();
+ if (!worldActuallyUseThisXMLFolder.empty())
+ game::config::xmlFolder = worldActuallyUseThisXMLFolder;
+
// read in all XML file names in the folder
std::list<std::string> xmlFiles;
if (getdir(std::string("./" + game::config::xmlFolder), xmlFiles))
int damage(lua_State* state) {
float d = lua_tonumber(state, 1);
- entity->component<Health>()->health -= d;
+ auto h = entity->component<Health>();
+ h->health -= d;
+ if (h->ouch != nullptr)
+ Mix_PlayChannel(0, h->ouch, 0);
return 0;
}
}
script("ground", {LuaVariable("height", h)});
if (h == -1.0f)
break;
+ if (h > 5000)
+ h = 5000;
script("grass", {LuaVariable("height", g[0])});
script("grass", {LuaVariable("height", g[1])});
world.data.push_back(WorldData {true, {g[0], g[1]}, h,
<layer path="bg/dirt.png"/>
<layer path="bg/grass.png"/>
</style>
- <generation width="1000"/>
+ <generation>
+ x = 0
+
+ ground = function()
+ if (x == 600) then
+ height = -1
+ else
+ height = 60 + math.random(0,6) / 2
+ end
+
+ x = x + 1
+ end
+
+ grass = function()
+ height = math.random(2, 5)
+ end
+ </generation>
<time>6000</time>
<link left="!town.xml"/>
</World>
</Sprite>
<Direction />
<Solid />
- <Illuminate radius="100" />
+ <Illuminate radius="75" />
<Wander>
countdown = 0
</npc>
<skirl>
- <Position value="300.0,100.0" />
+ <Position />
<Visible value="0.2" />
<Sprite>
<frame>
</frame>
</Sprite>
<Direction />
- <Health value="50" />
+ <Health value="200" ouch="assets/sounds/badOuch.wav" />
<Solid />
<Physics />
<Name value="SKIRL" />
end
hostile = function()
-
+
end
</Wander>
<Aggro/>
</chest>
<trigger>
- <Position value="200.0,100.0" />
- <Direction />
- <Solid value="1.0,1.0" />
+ <Position value="0.0,100.0" />
+ <Solid value="1.0,500.0" />
<Trigger />
</trigger>
--- /dev/null
+<include file="entities.xml" />
+<World>
+ <style bgm="assets/music/fight.ogg" folder="assets/style/classic/">
+ <layer path="bg/bg.png"/>
+ <layer path="bg/bgFarMountain.png"/>
+ <layer path="bg/forestTileFar.png"/>
+ <layer path="bg/forestTileBack.png"/>
+ <layer path="bg/forestTileMid.png"/>
+ <layer path="bg/forestTileFront.png"/>
+ <layer path="bg/dirt.png"/>
+ <layer path="bg/grass.png"/>
+ </style>
+ <generation>
+ x = 0
+
+ ground = function()
+ if (x == 240) then
+ height = -1
+ else
+ height = 1 / math.cos((x / 1.19 - 100) * 3.14 / 180)
+ if (height < 0 or height > 800) then
+ height = 800
+ else
+ height = height + 60
+ end
+ end
+
+ x = x + 1
+ end
+
+ grass = function()
+ height = math.random(2, 5)
+ end
+ </generation>
+ <time>6000</time>
+ <skirl />
+</World>