2016-09-07 04:16:25 +00:00
|
|
|
# Moonfall #
|
2015-01-22 08:26:53 +00:00
|
|
|
|
2016-07-10 06:11:26 +00:00
|
|
|
Moonfall is the name of a game engine that I spent several months developing back in 2008. It leveraged SDL for
|
|
|
|
graphics, Lua for in-game scripting, and wxWidgets for the built-in developer tools. The cross-platform engine was
|
|
|
|
written using the Code::Blocks IDE, but Visual Studio project files are also available.
|
2015-01-22 08:26:53 +00:00
|
|
|
|
2016-07-10 06:11:26 +00:00
|
|
|
The game was partially inspired by [Harvest Moon](http://en.wikipedia.org/wiki/Harvest_Moon_%28video_game%29) for the
|
|
|
|
Super Nintendo and [When They Cry](http://en.wikipedia.org/wiki/Higurashi_When_They_Cry) by [07th
|
2015-01-22 08:26:53 +00:00
|
|
|
Expansion](http://en.wikipedia.org/wiki/07th_Expansion). The protagonist is a city dweller, who upon inheriting a small
|
2016-07-10 06:11:26 +00:00
|
|
|
farm from a distant relative, decides to try his hand in agriculture. He finds the residents of the nearby small town a
|
2015-01-22 08:26:53 +00:00
|
|
|
friendly bunch, but something about them does not seem right. Everyone is appears to be hiding something from the
|
|
|
|
player, who must uncover the truth to survive. In short, this is (as I have described it to my friends), "Harvest Moon
|
2016-07-07 05:39:01 +00:00
|
|
|
with Murder."
|
2015-01-22 08:26:53 +00:00
|
|
|
|
2015-11-17 05:36:39 +00:00
|
|
|
## Technology ##
|
|
|
|
|
2015-01-22 08:26:53 +00:00
|
|
|
From a technical point of view, the game engine was an exercise in creating a completely data driven game. In
|
|
|
|
retrospect, it was probably over-engineered, but in general it was flexible and I liked what I could do with it. At the
|
|
|
|
core of the engine was the `Actor` class, the functionality of which could be expanded through add-on properties. The
|
|
|
|
property definitions were specified in XML; for example, below is the definition for the playable character:
|
|
|
|
|
|
|
|
|
2017-09-30 00:04:03 +00:00
|
|
|
```xml
|
2015-01-22 08:26:53 +00:00
|
|
|
<Actor alias = "Player.01" dynamic = "1" layer = "4" thumbnail = "Player.01.Idle.S.01">
|
|
|
|
<Properties>
|
|
|
|
<Animation />
|
|
|
|
<Script resource = "Player.01.Default" />
|
|
|
|
<Physics />
|
|
|
|
</Properties>
|
|
|
|
</Actor>
|
|
|
|
```
|
|
|
|
|
|
|
|
In addition to the self-explainable `Animation` and `Physics` properties, you can see a `Script` node which associates a
|
|
|
|
Lua script with the actor. Scripts would get notifications about events such as `OnActorUpdate`, during which custom
|
|
|
|
processing could take place:
|
|
|
|
|
|
|
|
|
2017-09-30 00:04:03 +00:00
|
|
|
```lua
|
2015-01-22 08:26:53 +00:00
|
|
|
function OnActorUpdate(elapsed)
|
|
|
|
if InputIsKeyTriggered(META_KEY_USE) then
|
|
|
|
DoActorUse()
|
|
|
|
return
|
|
|
|
elseif InputIsKeyPressed(META_KEY_UP) then
|
|
|
|
DoActorWalk(DIRECTION_NORTH)
|
|
|
|
return
|
|
|
|
elseif InputIsKeyPressed(META_KEY_DOWN) then
|
|
|
|
DoActorWalk(DIRECTION_SOUTH)
|
|
|
|
return
|
|
|
|
elseif InputIsKeyPressed(META_KEY_LEFT) then
|
|
|
|
DoActorWalk(DIRECTION_WEST)
|
|
|
|
return
|
|
|
|
elseif InputIsKeyPressed(META_KEY_RIGHT) then
|
|
|
|
DoActorWalk(DIRECTION_EAST)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
DoActorIdle(playerDirection)
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
Scripts can directly interact with properties on the parent `Actor` and can communicate with surrounding world via a
|
|
|
|
messaging system. This made it possible to build any game object imaginable by editing a couple of XML files and some
|
|
|
|
simple scripting.
|
|
|
|
|
|
|
|
|
2017-09-30 00:04:03 +00:00
|
|
|
```lua
|
2015-01-22 08:26:53 +00:00
|
|
|
function DoActorWalk(direction)
|
|
|
|
if playerAction == ACTION_WALK and playerDirection == direction then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
ActorPhysicsSetVelocity(playerId, playerWalkVelocities[direction])
|
|
|
|
ActorAnimationSet(playerId, playerWalkAnimations[direction])
|
|
|
|
ActorAnimationPlay(playerId, true)
|
|
|
|
|
|
|
|
playerDirection = direction
|
|
|
|
playerAction = ACTION_WALK
|
|
|
|
end
|
|
|
|
|
|
|
|
function DoActorUse()
|
|
|
|
actorsIds = ActorPhysicsQueryShapeCollisions(
|
|
|
|
playerId,
|
|
|
|
ACTOR_SHAPE_TYPE_COLLISION_INTERACT
|
|
|
|
)
|
|
|
|
|
|
|
|
for i, v in ipairs(actorsIds) do
|
|
|
|
ActorScriptSendMessage(v, "interact", { user = playerId })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
I eventually stopped work on Moonfall due to a lack of time, combined with the fact that I am not an artist and could
|
2016-07-03 04:31:06 +00:00
|
|
|
not author the assets required to develop this into a complete game.
|
2015-01-22 08:26:53 +00:00
|
|
|
|
|
|
|
## Screenshots ##
|
|
|
|
|
2016-07-03 04:31:06 +00:00
|
|
|
[![Gameplay window](https://foosoft.net/projects/moonfall/img/gameplay-thumb.png)](https://foosoft.net/projects/moonfall/img/gameplay.png)
|
|
|
|
[![Sprite editor](https://foosoft.net/projects/moonfall/img/sprite-editor-thumb.png)](https://foosoft.net/projects/moonfall/img/sprite-editor.png)
|
|
|
|
[![Console window](https://foosoft.net/projects/moonfall/img/console-thumb.png)](https://foosoft.net/projects/moonfall/img/console.png)
|
|
|
|
[![Asset editor](https://foosoft.net/projects/moonfall/img/asset-editor-thumb.png)](https://foosoft.net/projects/moonfall/img/asset-editor.png)
|
|
|
|
[![Map editor](https://foosoft.net/projects/moonfall/img/map-editor-thumb.png)](https://foosoft.net/projects/moonfall/img/map-editor.png)
|
2015-11-17 05:36:39 +00:00
|
|
|
|
|
|
|
## License ##
|
|
|
|
|
2017-07-31 00:37:40 +00:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|