Posts tagged Tiled

Excuses, Excuses

0

Where to begin?

According to WordPress, 323 days ago I posted a development video of what I was calling Ne+. That whole idea/game perished shortly after. There were many reasons why I never saw it through to completion, but at the end of the day I gave up and it was my fault.

One of the reasons was that I started working for Intel. Even now I can’t say what it is I’ve actually been doing professionally for the last year, except to say it’s certainly the best work I’ve ever produced and it’s been a very exciting and interesting ride for me. Hopefully I’ll be able to link to some images and videos soon.

A few weeks ago I was looking over the code I had written for my senior project. There was a lot of good stuff in there, although a lot of it needed to be cleaned up. Getting lighting, shaders, 3D audio, a tile engine, and other components all working was no small task. And a lot of it can be used to a greater purpose, I hope. So with that in mind, I’ve started working on a new project. Mistake number one is that it’s already far more ambitious than my first project, and we know what happened to that one. I won’t claim it’s going to be great, I won’t even give it a name, but I am going to keep putting time into it here and there.

The first big thing that I did was implement a different tile engine, so that now the senior project code I wrote is being used to create an old-school top-down tile movement system. You can draw boundary tiles in Tiled and be able to run into them with your character, and just yesterday evening I created an NPC class that you can also run into, although the way I implemented the collision checking for those was a little hackish. Movement speed is isolated in a configuration file as it should be. I also have a space skybox with a nice 3D camera to play with, currently used as the background of my main menu. I think I should be able to get a lot of mileage out of it for many different pieces of the game.

So, I really won’t say too much more now, as I just want to have something to show at this point. But there are still things in the works, and right now I am more productive than I’ve ever been.

 

Two platforms, a blue light, and a red box float against a black background.

Anti-Gravity Light Created

0

Working with Tiled has been a real joy so far. My latest feat has been integrating TiledLib with the physics in my game, so that when I open up a map file I read in the artwork, collision (both with tiles and with Tiled “objects,” which I’ll go into in more detail in a bit, player spawn points, and light objects. What I’m striving for is having as much level data and configuration in Tiled maps as possible, given that the Tiled maps are XML (although they can be many different formats). In fact, I might switch to CSV, because that might represent maps more visually in text before they are loaded, which might be nice to keep in source control to watch their developments.

A grid interface with two rectangles and some configuration information.

Here's another Tiled example, but here I'm actually defining a spawn point, a light, information about the light, and two different collision techniques - a tile overlay, and a Tiled object overlay. The tiled objects are just rectangles that you can attach data to, and I can create simpler collision geometry if I avoid creating it by tile.

The above image shows me designing a testbed for the anti-gravity light. The goal of this experiment was to create a light that enables the player to move between two platforms. When under the light, the player floats upwards. This is what it looks like loaded in-game, with the appropriate additions to the engine to take care of most of this automatically…

Two platforms, a blue light, and a red box float against a black background.

The red box is starting to float after taking a dangerous leap off the starting platform. Click the image for a video.

The test went really well, but I’m most excited about the fact that it’s so easy to define all of this stuff in my map files and have the engine take care of all the loading. As you can see in the image above, Farseer’s debug view is showing that the left platform is composed of many small squares, whereas the right platform is just one big rectangle. Obviously the one is more efficient that the many, but I am just going to keep the code around for both because it might be neat to utilize different techniques depending on the situation.

For my next trick, I’m planning on creating more light components, but after I refactor the code a bit, because I still have a bit left in my Game1 class that shouldn’t be there as a hack to get this example going. I would like to create the light that nulls other lights so that I’ve always got that in my arsenal. I also would like to have my dynamic lighting back, but I am waiting on Krypton XNA for the 4.0 update so that I can hopefully utilize that project to speed up development. However, I am still confident that if that never happens I’ll be able to do something from scratch without too much trouble. I am going to keep a collection of lights in my level class, so that they’re all easily and logically accessible. I need to figure out what the best way is to affect objects that are being touched by light with the appropriate effects, which as of now is a bit hacked together.

A grid-based application with a map drawn with tiles in its editor.

Drowning in Tiles

0

I have been spending the last week (on and off, as I had to make a drive over to Corvallis for the MECOP Fall Event), trying to integrate Tiled and TiledLib with my project. I learned a lot about the fantastic functionality of Tiled and how to actually go about using the program, which of course is going to become one of my main development environments when I need to start creating content for Ne+ (and really, I’d want to use Tiled for any 2D game moving forward), but I got hung up pretty badly once I started trying to load a map with XNA’s Content Pipeline and the TiledLib extension. I was getting an error about indexing past the end of an array in TiledLib’s map loading functions, so immediately I wondered what the deal was as I had tried out the demo and it worked perfectly.

A grid-based application with a map drawn with tiles in its editor.

This is what Tiled looks like.

So, I started taking a closer look at the demo – I was truly doing the absolute bare minimum in my project – declaring a map variable and then attempting to load the map file that I added to the content project, fully aware that the file was referencing a tile PNG with my one tile in it, but TiledLib was supposed to handle loading that for me. Eventually I just replaced the demo’s map with mine and saw my map load no problem in that project, but not in my own.

I debugged for a while, and saw that indeed, my project was not loading the PNG referenced in the map correctly. I pulled out garbage values where it was supposed to read the filename. Then I thought that maybe the file was getting processed incorrectly in my project, and then I remembered that there are settings for the importer and processor for every content item in your content project.

Sure enough, the importer and processor were blank. I set them to the TMX (map file extension) importer and processor, and bam, immediately the map appeared in the scene I’ve been testing. I still need to make my engine load up physics for the maps I load, and I think that with Tiled’s awesome ability to attach “properties” to tiles I’ll be able to decide whether or not the tiles are just for show, or should be “Collideable,” or anything else I can think of. I can also use Tiled to define player spawn points that don’t actually display on the screen, and other areas of interest. It’s a really cool program that provides nothing more than exactly what I’d want from it, and I can’t wait to start utilizing it more heavily.

Making a Player Class

0

One of the things I really wanted to accomplish this week was creating a player class to take over my bouncing box, as the code was pretty much my engine, which is a bunch of global things organized in a way that makes sense to me, and my XNA Game1 class, which housed the code for pretty much everything else – initialization, drawing, the debug view drawing, camera setup, etc… so it was a mess, a slightly organized one as I kept all the different parts separated by whitespace, but a mess nonetheless. So I set out to pull out the bouncing box – leave the platform where it is in the Game1 class, but everything involving my dynamic Farseer Fixture needed to move.

I first created an InputComponent, and wanted this component to handle player input that affects the box, which in my small project is jumping, or floating. I set out to do this, and had some code that checks if the jumping keys or buttons in the Configuration class are being pressed. I built the project for Windows just fine, but then realized that I was only compiling the Key code in the Input reader if we were on a Windows platform, but doing the check both ways. So I ripped out that stuff so that I just return false if I’m checking the keyboard on an Xbox.

Then, I somehow managed to forget about my actual InputComponent and moved on to the PhysicsComponent, which basically is used to create a polygon, throw it into the Farseer simulation, and then update the game world position on every update for my player. That worked perfectly, although the drawing order of the code screwed up my debug view and I ripped that out into the Physics part of the engine and made that a drawable component as well, which draws the debug view last. So my player class instantiates an input component and a physics component, and then uses just the physics component (for now) to update its position. It also loads its texture and draws it, which is pretty standard XNA stuff.

The next thing I have to do is make it actually use its InputComponent, and then I will move onto using Tiled and TiledLib to draw the placeholder platform like it’s loading a whole map, and then I can decide how I want the flow of the game to be using all of my new classes instead of hard-coded stuff in the main class. I also need to create a particle effect component so that I can easily attach particle effects to objects, which will instantly make things a lot cooler, although I still need to learn how to create my own effects with the Mercury editor.

Go to Top