Moai – Part 2

So, after my last post on Moai, I’ve continued to play with the framework (and with Lua). Its all leading me towards a second game.

I’m still hard at work on PPRPG, its not vapourware, I promise. :) This Moai project won’t impact the development or timeline for PPRPG and It’s actually having a positive effect (acting as a creative diversion to prevent burnout).

The two games are being developed in two very different ways. With PPRPG I have a clear vision of the final game and how it will feel. Development is pretty much planned out and, whilst I still have lots of game design problems to overcome, it’s pretty much a case of ploughing through the work.

This second game is much more organic. Its doesn’t have an aim. In fact the mining mechanic is something I just started to program, I didn’t really choose it. I’m just kind of throwing ideas at it and seeing what sticks. I’m programming in a very immediate fashion and refactoring code (frequently) as needed.

I won’t make you read all of the text below if you don’t want to. Here’s an updated video demoing my progress.

Since my last prototype video I’ve introduced a few new concepts. The first was the concept of streaming chunks of dirt. The way I’m doing this is to generate 1/2 screen of dirt as the player reaches the previous chunks edge – this is generated on the fly and stored in a very simple data table. As the earth is mined and block added, the data table is updated. Moving out of a chunk into a new chunk removes the old props (Moai’s terminology for a placeable instance – a bit like a CCSprite in cocos I think) from the screen. When you move back into a chunk, the engine reads from the data table and regenerates the props.

Obviously the final game will generate and stream content 3×3 to ensure that you don’t see the objects streaming in. I just found it was helpful to limit it to 1×1 whilst debugging.

Outside of that, I’ve added a few other features…

You can currently only dig left, right, and down. Ladders allow you to traverse previously explored places. They are automatically placed when you press “up” and have empty space above you.

“Gravity” has been added to the main player controlled “character”. There are no physics involved. It just detects empty space below and moves you down 1 layer/row.

On the tools front, I’ve found that the best combination is Sublime Text 2, Command Prompt, and the built in Windows Process Monitor (to show memory consumption and CPU load). Originally I had been using Sublime’s built in build command to run the game but switched back to command line because Sublime suppresses the output (which means you can’t print debug info on the fly).

I still have a lot to learn about both Moai and Lua. I’m currently rocking a single Lua file which represents the whole game (not sure if this is correct). I still need to look into spritesheets and animation.

I’m thinking about tweaking my chunk generation a bit more (utilising threading if I can). I’d generate chunks ahead of time and stream row-by-row rather than chunk by chunk.

Anyway, this game is about fun development so next up its a single ore type and bombs! (Not for a few weeks though since I have a bit of an PPRPG Sprint to get into :).

5 Comments

  1. Gord says:

    Moai looks really cool. Been trying to pick a language for 2d graphical game dev free of platform dependence. I leaned in VB so Moai seems a little intimidating. Like, how to do an input box (enter your name) or save a game. Being lua scripts, I’m not sure how you’d package a game so people couldn’t easily steal all your stuff.

  2. Chris says:

    @Gord

    I’d encourage you to give Moai a try. There are sample projects demonstrating GUI elements such as text input.

    I found Lua surprisingly easy to pick up so don’t be put off by that. I’m by no means an expert but I’m learning.

    I haven’t packaged a final game yet but I know that there are tools out there for encrypting your Lua scripts. I’ll try to write a blog post about packaging games as I get closer to an Alpha.

    Anyway, its early days for me but so far I’d say its worth a shot. Good Luck :)

  3. Gord says:

    Hope you put up some more posts! Tutorial and such things seem very lacking for building anything other than level and hi score based action things. Trying to find things like inventory, drag and drop, text input, etc. :)

  4. tolvak says:

    I found a way to get the Sublime Text 2 build system to automatically run a new window for cmd, so you get real time results for debugging while being able to use the ctrl+b shortcut, use this (runs the command start via the windows shell, which creates a new cmd window):

    {
    “cmd”: [“start ${project_path:${folder}}/run.bat”],
    “shell”: true
    }

  5. Chris says:

    @tolvak

    That’s a great tip. It should make my workflow much simpler.

    Thanks :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.