Archive for the ‘Tile Engine’ Tag

I may just be getting used to this whole OpenGL thing…

I have been playing around with OpenGL ES 1.x for the iPhone, and really having a tough time with it considering I’m used to other ways of getting images to the screen. I started doing some research, and a whole lot of reading, and I think I might have come up with something!

Yep, you’ve guessed it… the basic framework of a tile engine is up and running! Oh sure things are a little different from my XNA tile engine, and I’ll even go as far as saying I’m a little uncomfortable with a few of the things that OpenGL does… but I’m learning. 

One of the major things I’m uneasy about is the world coordinate system used in OpenGL. I am not sure if I’m doing things correctly, but I’ve been used to the (0,0) point to be in the upper left corner of the screen, as you move down your Y value increases… and as you move to the right, the X value increases. OpenGL uses a different quadrant in the coordinate system, where (0,0) is now located in the bottom left corner of the screen, and up increases Y, right increases X. 

No worries though.. the VERY basic framework of my RPG engine has been ported over to ObjC and the iPhone. Step 2 is to expand on that basic framework and get a few key systems up and running (IE: the Tile Engine and other systems)

XNA RPG Editor: Soon to be Open Sourced

As stated in a previous post, our goals for this project were simple yet ambitious at the same time. We wanted to create a system that could be useable for not only our immediate needs and the RPGs we wish to create, but also any future needs and the games we have yet to think about, and taking it a step further we wanted this project to be usable for any game creator wishing to create levels for THEIR RPGs. 

Step one for my portion of the project is complete. I’ve been working on the XML Exporter class and the front end to that exporter. The goal for me was to get the XML to export all of the needed information in as customizable fassion as posible.. but at the end of the day when you hit “Export to XML,” you can take that file and plug it into your projects content pipeline and expect it to work. You won’t need to mess around with formatting, adding the asset type, change your TileMap class around because of the XML document… it will truly be a document suited for your needs.

We are really only on step one, building the basic framework and systems for the editor. Hell, the editor itself is nothing more than a blank windows form at this point hah. I have started working on the front end of the Exporter system over the next few days and hope to have something to show off then.

Keep in mind, this project is in its first stages, and has some pretty ambitious goals. Our overall goal for this though, is to ensure that people who use our editor will be able to plug the XML into their project and just “have it work” :) Also when the editor gets into a more complete state, we will open up the repository so everyone can take what they like and add it to their own projects or continue to enhance ours for their own use.

Content Creation

With the Dream Build Play project “Complete,” I’ve turned my attention to a few items that will aid in the creation of not only Meir, but any future RPG I write. Content creation is a tricky subject, as the goal is to create something flexable enough to re-use in any RPG project, but dynamic enough and easy enough to use so if I had a few people working on any given project, they would know what to do.

Well me and a buddy from the shacknews chatty decided that he didn’t want to use TileStudio anymore, but wanted something more suited for his game.. so we started colaborating on an editor that would be built specifically for XNA games, but flexable enough to use in any project. Obviously this editor will have to support several major features of basic RPGs, but how in depth are we going to really go with this thing?

Create and edit tile maps? Basic feature, has to be included.
Exporting XML in the same style of the XNA Content Pipeline? Basic feature, has to be included.

but what about features like adding a “tile” to the texture, and having the map build the texture and exporting that to a PNG file? What about creating a system that can export to multi dimensional or single dimensional arrays based on the project needs? How about a dynamic XML system that lets the user edit how their XML should look, then hitting “Export XML” and having their XML formatted correctly? There are many many more ambitious goals we wish to include, and we’re thinking a bit larger scale then just these… but its pretty interesting to see what we could come up with. As always, I’ll keep everyone up to date on whats actually going on. 

So if you had to pick and choose a few “Must Have” features of a game editor, what would you want included?

Meir is an official Dream Build Play project

When I started this project, I couldn’t tell you the difference between a float, int, or double. I didn’t know how to program, and had no clue where to even begin on a project as complex as this… but here I am.

Typical combat screen in Meir

Typical combat screen in Meir

Obviously its not a complete game, nor is it as polished as it could be.. but its good enough to prove a point to myself. Good enough for me to say “I set a goal for myself and reached my deadline with a specific quality in mind, and I hit it.” Next step for me is going to be putting together a story, finishing everything I couldn’t get done for the demo, and working towards the Community Games. Until then, enjoy the promotional video we had to put together for the Dream Build Play competition.

For some reason, the video is currently not showing. Direct link is: http://www.youtube.com/watch?v=g8n0fBt2t_8

I would like to give a few thanks.. because there were some people along the way that really pushed my goals forward. Most notably from the shack news community (http://www.shacknews.com/) People such as MitchWalker, RomSteady, and Mittense, DHAvatar, and everyone else on that crazy site.

I would also like to point out that the music for the demo was crafted by Delaric, and it is fine music indeed. Several people have contacted me wishing to help on a possible final version of the game and if you’re interested, all you have to do is shoot me an email. I would like to point out, however, that the final version of the game is a LONG… LONG way off. This i would consider, a very basic demo.. and the final version will be a full fledged RPG. You do the math :) But for now.. one milestone is down.. and thank you EVERYONE who helped along the way.

ShackRPG: Engine Progress

These last few weeks, I’ve taken the opportunity to re-write my RPG Engine, and base it closer to the RPG Template engine released by Microsoft for the XNA platform. I did this for a few reasons, one of the primary reasons being I have not seen any RPGs to come out of that RPG Starter kit hosted on the XNA space. With a basic demo, and a little creativity, I wanted to show people what can be done with the tools given by Microsoft.

Current Map, Developed by EvilNando’s editor; http://xnafantasy.wordpress.com/

Fast forward a few weeks and I’ve pretty much got the tile engine done, and put together a few quick maps with a great map editor made by my buddy, and fellow XNA RPG Creator, EvilNando (Website located at http://xnafantasy.wordpress.com/ ) Changes to the Microsoft engine are plenty, but some of the notable ones include:

Modified content importers – I have not used the Microsoft importers, choosing to instead use just .xml files. Because of this, all methods of importing content from the content pipeline have been done using the System.XML namespace

Audio Engine – I really liked what Microsoft did with their audio engine, so I just tweaked it to include a “Playlist” system. Basically this is just a stack, and new music can be pushed onto or popped off of the stack at any given time. If there is no music in the stack (playlist) the general background music will play.

Collision System – I really, REALLY didn’t like the way Microsoft handled collision detection with tiles, mostly because it wasn’t compatible with my system at all ;) So instead I stripped out what they wrote, and modified my old version to handle collision in the new tile engine.

Screen Management – I used a modified version of my old screen management, and discarded Microsofts completly. It works for what I want it to do, and I made it a little more modified to handle Update Blocking and Draw Blocking on gamescreens. For example, You’ll notice in the video, the “Gameplay Screen” is the last one on the stack, but the first screen is the “Main Menu.” Obviously you wouldn’t want the Main Menu screen updating or drawing if it is being covered. Because of this, the main game screen blocks updates and draw calls to all lower screens.

Animation – Since my old animation method worked quite well, I just modified that to work with the new system. Nothing really new.

Video of the new engine in action:

There will be more updates soon, especially when I finish the next few stages of the engine (which includes NPCs, Quests, and Combat, which I will be taking an entirely new direction.. you’ll love it)

Questions, Comments, Opinions, feel free to drop me an email at CraigGiles9@yahoo.com.

ShackRPG: Updated Tile Engine Part 2

With the Map class complete, we can no start working extra things into our Tile Engine to display each map to screen. In its current state, the tile engine is incomplete for a few reasons including collision detection between characters and drawing order of all layers. However, i do have enough to get the basics of the engine up and running and continue to work on the rest of the systems of the game. So, on that note, lets begin!

I have 6 seperate regions to help organize the tile engine;
TileEngine Data – Houses all data associated with the engine. 3 data fields and properties; a true / false statement on if we’re loading a new map into memory, a Map file, and the mouse location for the editor.

Constructor(s) – initializes the tile engine on startup

private void Initialize()
{
map = new Map();
map.Load(“Map001″);
}

Update / Draw – … can you guess?
Update right now does nothing, but will call the “CheckCollisions();” method.
Draw just calls “map.Draw()” … so thats very easy.

Clamp Camera – Aah this is a fun one. I’ll post the code and see if you can make heads or tails of it.

public void ClampCameraToBoundries(Vector2 position)
{
//clamps the camera to the players position
Globals.Camera.Position.X = position.X – (Globals.Graphics.GraphicsDevice.Viewport.Width / 2);
Globals.Camera.Position.Y = position.Y – (Globals.Graphics.GraphicsDevice.Viewport.Height / 2);

//Clamps the camera within the game screen
Globals.Camera.Position.X = MathHelper.Clamp(Globals.Camera.Position.X, 0, (map.Width * map.TileWidth) – Globals.Graphics.GraphicsDevice.Viewport.Width);
Globals.Camera.Position.Y = MathHelper.Clamp(Globals.Camera.Position.Y, 0, (map.Height * map.TileHeight) – Globals.Graphics.GraphicsDevice.Viewport.Height);
}

Make sense? Basically you give the method the players current positional vector and it keeps the player within the center of the screen. If the player moves right, the camera moves right. If the player moves left, the camera left. However, after that it keeps the camera on top of the game world so if the player moves left to the edge of the map, the camera will stop when it reaches the imaginary edge.

Player Movement – This region does 4 things and is quite long compared to the camera clamping method. It will take the keyboard data collected by the games Update() method to determine if the player should be moving, and which direction. It then takes the positional vector of the player, and the speed modifier of the player, and calculates what the new position will be. Finally, it will take that new position, check to see if the player is on a tile it can walk on, and if so passes the new position to the game for update. If the player is on a tile they shouldn’t be on, it passes the old position, in essence, the player has not moved. Confusing huh? It can be.

Save / Load / Create New Map – map editor functions, and these are quite long and deal with loading and saving from an XML file from within the content pipeline. I do not write my own content importers or processors, so I’ve been using the System.XML namespace. If you want to know how its done, inquire within!

I tend to organize my programs by clumping things together. I know some people do “Data fields” “properties” “Constructor(s)” “Public Methods” “Private methods” but in bigger programs I’ve gotten into the habit of clumping everything together that goes with eachother. Might be a bad habit but to each his own. I’ve spent a few days on other systems for the Tile Engine and I’ve updated the code at the projects site. Next update I’ve had a request to post about my particle effects system, so I’ll get that in order and have it out here in a few days. I also will go into my in-game map editor.

As always, if you’re interested in checking out the full source code (newly updated), just head on over to code.google.com;

ShackRPG: Updated Tile Engine Part 1

Over the past few days, I’ve been re-working my Tile Engine and Map Editor, and before I post on it I would like to say that it has been quite a bit bigger than I had anticipated. For that reason, this post will be broken up into several posts to show the basic features of the various components of the Tile Engine / Map Editor, but without having one big 30 page post on the whole sha-bang.

So on that note, we’ll start with the Map.cs file. This file will hold all of the map information, which is actually quite a bit of data. Some of the data fields include:

string Name – Map Name
int Height – Map Height
int Width – Map Width
int TileHeight – Height of each tile on map
int TileWidth – Width of each tile on map
string Tileset – Tileset used to draw the map

Point PlayerRespawnTile – Players respawn Location

List Tiles – List of textures used for map tiles
List NPCs – List of all NPCs on the current map
List Items – List of all world-items on current map (IE: Treasures)
List Portals – List of all portals leading to OTHER maps

string MusicCue – Music data to be used on map

int[,] BaseLayer – Base Layer Layout (Things you walk on top of, grass etc)
int[,] FringeLayer – Foreground Layers layout (Things you can walk behind)
int[,] ObjectLayer – Object Layers Layout (pots, barrels, plants, etc)
int[,] CollisionLayer – Collision Layer (Tiles you can not walk on)

This is most of the information needed to make a map work with this tile engine. The next step in getting the Map.cs file in order, was a way to Save, Load, and Initialize a map. Obviously for a complex role playing game, you’ll want to have several maps. Maybe a few towns, dungeons, an overworld map, city at sea, a sky level… The choices are limitless, but for every region you have in your game, you’ll have a map to hold the information. All of these maps will hold the same structure which makes it easy for the game to load and display

I really did not want to write my own content importer / content reader in the XNA engine, so I’ve stuck with the System.XML namespace. Because of this, each map will be stored in its own XML file and fed through the XNA content pipeline, but with the map.xml property set to “Do Not Compile.”

Below is a screenshot of a test map I did while testing the map engine showing off some of the map editor.


Red P = Player Respawn
Blue P = Portal to a different map
I = Item
M = NPC / Monster

The map name is called “Map001″ and you can see the XML file HERE

Not too many problems came up while working with the Map.cs file, more-so when trying to get the editor up and running.. but I’ll save that writeup for another time. Could this map file be smaller? Probably. As it stands now, it is just under 1300 lines of code. There are also several other systems needed to display the map to screen, but for anyone interested in writing their own map engine in XNA, I figured the best place to start was the map itself.

Full project source code can be found HERE
Project homepage can be found HERE

Next time I’ll go more in depth on the Tile Engine, and some of the Map Editor.

Follow

Get every new post delivered to your Inbox.