More Editor – An Icy Night In Snowman’s Land

Last  time I talked about the level editor. Today I’m going to talk a bit more about the editor, because I’ve spent a lot of time lately working on it and I need to write down some of this for my own benefit.

The game will be released on Android and HTML5. I’ve been developing on Linux, and I’ve been testing builds for all three targets. Now, the level editor has been “done” for awhile, at least for Android and desktop. Editing, testing in the editor, saving, loading, and everything else was implemented. However, the HTML5 build had an additional challenge.

On the other platforms, saving and loading levels require accessing the local storage of the device and allowing the player to choose a level to load or a location in which to save the level. However, the HTML5 version of the game isn’t running on the player’s device at all. It’s hosted on a webserver that the player will connect to through their web browser, and so it doesn’t make sense (and indeed would be a major security issue) to give players access to files and directories stored on the webserver. To allow the player to save and load levels, it was necessary to transmit data between the webserver and their local machine.

Eventually, I bit the bullet and got down to implementing saving ad loading in the HTML5 editor. I didn’t need anything fancy; from the player’s perspective all I needed was to display a dialog letting the player choose a file to upload and a dialog to save the level file. I thought “That’s easy! Obviously I can’t do anything filesystem-related, but since I’m using (HaxePunk on top of) OpenFL and Lime, and lime.ui.FileDialog exists, this should be pretty straightforward!”

Unfortunately, lime.ui.FileDialog currently doesn’t support loading of files on HTML5. That’s pretty unfortunate, as that’s half of what the level editor needs to do with files. I was at a loss for awhile, until I found these examples of creating a file dialog and invoking it through javascript. Now, I tried these examples in jsfiddle to confirm that they worked, and so I implemented the examples in the game and it worked in all browsers I tested… except Firefox.

Now, Firefox has valid reasons to limit what can happen programmatically. I wasn’t surprised that I ran into a limitation for security reasons; I was surprised that the code only failed to work correctly on one browser (and a non-Microsoft browser at that). In the end, I did manage to get saving and loading on HTML5 working, after being pointed toward open.net.FileReference. If you got here from a search engine and want to know how to make this work, here is the solution that worked for me:

I created an instance of openfl.net.FileReference (called fr in this case), then I added the following code (only compiling it for the HTML5 build):

 
 
  1. private function stageClicked(e:Event)
  2. {
  3. if(isMouseOver(myUIButton))
  4. {
  5. fr.browse();
  6. }
  7. }
  8. private function startLoad(e:Event)
  9. {
  10. fr.load();
  11. }

The  important thing to note is that fr.browse() is being called in response to a stage click event. This is necessary for the file browser to work; without being called in direct response to user input, it may be blocked for security reasons.

Once the file the user selected has been loaded, you can access the data like so:

 
 
  1. private function loadComplete(e:Event)
  2. {
  3. var data = fr.data.toString();
  4. if(!Levels.isLevelValid(data))
  5. {
  6. //not a valid level
  7. return;
  8. }
  9. //parse the level file
  10. }

The result? Working saving and loading of levels on HTML5!

An Icy Night In Snowman’s Land

I should blog about the development of this game. I’ve been meaning to add to my blog for so long anyway.

Huh, I got so wrapped up in developing the game that I forgot all about my plans to detail the development on my blog. Oh well, I’ll start tomorrow.

Hmm, wasn’t I planning to blog about this game last month? I guess I should start tomorrow.

Well, I meant to begin this a lot sooner. Like, months ago. Still, better late than never, right?

I’m making a new game. Well, not a new game. It’s a revamped and expanded version of an old game. That I made several years ago. That I meant to update much, much sooner than this.

The basic premise is this: A snowman is stuck on a frozen lake. The goal is to guide the snowman to the carrot on each level. There’s a twist of course: when the snowman moves in a direction, it won’t stop until it bumps into something. That’s ice physics at work. Adding additional complexity are holes in the ice that the snowman can fall into, snowballs that can be pushed around, and gusts of wind that will change the direction of anything that moves into them.The original game, made for Ludum Dare, had 10 or so levels. That’s a meager amount of content, so one of the items on my todo list was adding more levels. As of writing, there are 50 puzzles in the game. I didn’t want to stop there, however.

The project has gone through a bit of feature creep. I didn’t originally intend to have a level editor, but the simple editor I threw together was so useful for building the game that I decided to polish it up and make it available to players. That’s where a lot of time and effort went. It turns out there’s a big difference between “this editor works for me while I’m building content for the game” and “this editor is intuitive and user-friendly enough to be used by someone who didn’t build it and also it gives helpful feedback and doesn’t look awful.”

Adding to the difficulty was the fact that this game isn’t just going to be released on devices with a keyboard and mouse; I’m also targeting mobile devices (just Android for now). This means the level editor needs to be usable on a mobile device with a touchscreen. The non-mobile editor looks like this:It’s a pretty straightforward editor. Click on the icons to the right to select an object. Click on the tiles in the level to place the object. It’s mouse-driven, which means for the most part it translates well to a touchscreen, with one notable exception: right-clicking. The non-mobile version uses both the left and right mouse buttons to place and delete objects, respectively, but touchscreens don’t have a way to differentiate between “left and right tapping.” As a result, the mobile version of the editor looks like this:The keyboard  shortcuts are replaced with on-screen buttons, and instead of right-clicking to remove objects, there’s another button to toggle between placing and erasing. It works pretty well. I’m happy to say that the editor is entirely functional on mobile devices (again, I’m just targeting Android for now). Placing, erasing, saving, loading, and everything else works. I’m not aware of another smartphone game that includes a level editor or something similar, so I wasn’t sure what kind of issue I’d run into. Apart from having to keep in mind that the OS will limit storage access to a particular location set aside for the app, as well as the differences in input methods, it was a rather straightforward task.

There’s one last part of the editor I’d like to talk about. You may have noticed a button in those screenshots labeled “Test.” I took some inspiration for the editor from the editor in Mario Maker (and Mario Maker 2, but I began building the editor before it was announced), and I especially liked the ability to quickly and easily test levels in that game. My level editor’s test feature works rather similarly: once the snowman and goal are placed, clicking the test button removes the level editor interface and lets the user immediately begin controlling the snowman to test the level. Moving between the editor and testing the level is quick and seamless. I’m not going to lie; getting that working felt great.

So that’s the level editor. There’s a lot more of the game I want to talk about, so I’ll keep making blog posts at least through release (this counts as marketing, right?). I’ve always enjoyed reading about how games are made, so if you have a similar itch, I hope these posts manage to scratch it.

Team S.T.E.A.L.T.H. – Postmortem

My entry to Ludum Dare 33 is Team S.T.E.A.L.T.H. Prior to the jam, I had been playing a lot of the Metal Gear series, and that made me want to create a stealth game. My original idea was very complex, and was essentially “Metal Gear (2), but turn-based”. I had plans for so many weapons, tools, obstacles, and enemies. I had a save format and level format designed. I had the HUD drawn. I had an idea with a huge scope. I have no idea what I was thinking.

The Original Idea

As I mentioned, my entry was heavily inspired by the Metal Gear series, though my original idea was even more heavily inspired by the series. Since I started thinking about my plans before Ludum Dare started, by the time half an hour had passed, I had a strong, fleshed-out idea.

The game would be turn-based, and involve collecting a certain amount of intel on each level. The player would have a certain number of move points, which would dictate how far they can move each turn. They would be able to plan things out and perform actions like shooting or equipping items on their turn, after which the enemies would move. There would be plenty of guards to avoid, as well as things like cameras and infra-red lasers. Items such as empty magazines could distract guards, and thermal goggles would reveal mines and laser beams. The levels would mostly be large, ecouraging use of the radar to see enemy and intel positions.

My original idea also included stat tracking. Enemies killed, enemies dispatched non-lethally, turns taken, and a lot more would all be recorded and have a small effect on the story.

Here’s the first and second versions of the hud, created one right after the other.

uiv1uiv2

Here’s part of my early design document listing what I had planned.

Weapons:
-Taser
-Tranquilizer Pistol
-Pistol
-SMG
-Empty Magazine
-Grenade
-Smoke Grenade
-Mine
-Sleeping Gas Mine
-Sleep Syringe
-Key Cards (Removed after each level)

Equipment:
-Cardboard Box
-Mine Disarm Tool
-ThermalGlasses (make infrared beams visible and display heat sources)
-Medicine (heals player)
-Chocolate (Allows more movement)

Enemies/Obstacles:
-Guard (can have pistol, smg, or shotgun, always has knife)
-Armored Guard (can have shotgun or assault rifle, always has knife)
-Grenadier Guard (armored, can have rpg or grenade launcher, always has grenades)
-Camera
-Gun Camera
-Flying Mobile Drone
-Flying Mobile Gun Drone
-Infrared Lasers

That’s quite a lot of content and quite a large scope.  So what actually made it into the game?

screen2Not much.

The Game

There were two major moments when I knew I needed to make major changes to my original idea. The first came early on Saturday (about 18 hours into the competition). I looked at my list of items and weapons and knew I couldn’t add all or even most of them. By this point, I had already decided to stick with the two enemies I had created, a guard and a drone.

I figured that since one was an organic threat and the other was a machine threat, I could simplify combat into two attacks. One type of bullet would deal with the guard, and the other would deal with the drone. Using the wrong type of bullet would simply alert the enemy and they would chase and attack the player.

early4

It wasn’t until a few hours later that I began to implement the combat. At this point, I still had much to do, including music/sfx, adding more levels, adding the story, making the title screen, and a lot of other small things. Also, I would not be able to work on the game at all on Sunday until the afternoon, which would leave me with 8 hours until the competition ended.

I had the assets for bullets and buttons created. With only a few hours left in the day, I knew that if implementing combat didn’t go very well, I would likely have to cut it entirely. It didn’t go very well.

I cut combat entirely, which was the second major change I made. This also meant that the only possible fail state I could have given the current state of the game was to make getting spotted mean instant failure.

As I finished up the game and added more levels, I realized that these last two changes were actually beneficial to the game as a whole. There was no way I was going to execute my original idea, and having basic but superfluous combat would likely detract from the game entirely. And so, the game turned into much more of a puzzle game than I originally thought.

I finished the title screen and story, and added more levels on Sunday.  To keep things simple, levels would all be the size of the game screen, and no larger. I polished up a few things and submitted with 30 minutes left (not counting the dedicated submission hour). In the end, the final product was approximately 99% different that what I planned going into the weekend.

screen1

What Went Right

  • I had a clear idea of what I wanted to do.
  • I planned how I would use each of the themes in the final round.
  • I knew my tools.
  • I got something playable quickly.
  • Some of the changes I made massively benefited the game.
  • I finished a game.
  • I had fun. :)

What Went Wrong

  • I massively, massively overscoped my original idea.
  • Because of this, I had to make several changes throughout the weekend.
  • Because of this, I ended up undoing or not using some of my work, which wasted time.
  • I had trouble getting pathfinding working correctly at first, which lead to delays in progress.
  • There are a few minor bugs left in the game.

In The End

I’m very happy with my game. The gameplay is simple yet fun. Most people seem to like puzzle games. The game still has the spirit of what I intended. The radar works and looks cool, so I’m extremely proud of that. The “ending” is sort-of outside the game, and is somewhat open to interpretation by the player.

If you haven’t played it, you can find the game here on the Ludum Dare website. If you made a game for LD33, be sure to vote and tell me what you think!

Jetpack Jacob progress – conveyors

There has been almost no work on the level editor since the last update. I’ve been busy adding objects to the game and making them work properly.

“Mechanical Mansion” is part of the game’s title, so there should probably be some mechanical objects, right?

conveyor1Conveyors will move objects that rest on them to the left or right. They move quickly, which means that they can be used to prevent progress in a certain direction.

conveyor2Multiple conveyors can quickly accelerate an object to its maximum horizontal speed!

That’s all I’m going to include in this progress report. The next instalment should be even more interesting. You could even say that it will be a ‘blast’! ;)

Jetpack Jacob progress – finishing the level editor

leveleditor5Work continues on Jetpack Jacob. I’ve been fixing bugs and making the level editor more user-friendly, as shown in the screenshot above. More dialogs have been added to help users use the editor. Something entirely new is a message in the lower left corner of the screen to help users understand what is happening when they select or change an object, or load or save a level.

The new Jetpack Jacob game has many new objects that weren’t in the original game, and I’ve been slowly adding them all to the game itself (not just the level editor). Switches and colored keys and switchable blocks an colored switchable blocks all function perfectly.

early1That’s all the visible changes since the last update post. Most of the changes have been bug fixes and other non-visible improvements. Next I’ll be added the rest of the new objects to the game, and making level progression work.

Jetpack Jacob progress – level editor

Long ago, for Ludum Dare #27, I made a game called Jetpack Jacob in The Quest for Time. I was happy with that game, but knew that it could be much better. I’ve been working on a sequel: Jetpack Jacob in Mechanical Mansion.

The work has been slow but steady. To make the levels for the Ludum Dare game, I used OGMO Editor, and manually edited the output to make parsing easier. For the sequel, I am building a level editor into the actual game. That’s right, all players will get access to the same level editor I am using to make the levels for the game!

leveleditorThe editor is coming along nicely. (All art/fonts/etc in these screenshots are not final) There are user-friendly dialogs and error popups to make things easy for players.

leveleditor2The editor itself supports infinite undo/redo. Certain object (such as the player) can only be placed once. Objects that can be placed an unlimited number of times can be “painted” onto the level without the use needing to click in each tile to place an object.

leveleditor3The editor keeps track of what has been added and what needs to be added, and displays the status at the bottom of the screen. If the player or exit are not part of a level, it cannot be saved. If a key is added, but not the blocks it unlocks (or vice versa), the level is considered incomplete and cannot be saved. In these situations, an error message is also displayed when attempting to save.

The next things to add to the editor are objects for the enemies in the game, and loading of previously saved levels.