Archive

Posts Tagged ‘Engine’

Platformer Engine: Inside + Mini Update

September 19, 2009 2 comments

Been sometimes since I last wrote here. Been kinda busy, especially with my new computer, which needs a lot of love to be properly used ^^

Well, what about my Platformer Engine? Like I said, I’m kinda busy, so there isn’t much of an update to be put here. But it is wrong to say that I haven’t done anything, since actually, a lot has been changed inside the engine. You see, since I was focusing on the actor, my code has been focused on Class Actor as well, making it more “Procedural” and less “Object Oriented”. So I decided I need to restructure it before I add more feature, and here we are.  Anyway, I’ve been showing some screenshots of the engine before, so this time, some diagram describing what restructure I have made should suffice.

Classes in Platformer Engine

Classes in Platformer Engine

First off, classes. This hierarchy here exploits the inheritance feature C++ give, so we can separate the much more generic code, like position and velocity to the parent class (Entity here in my engine)  and the specific code like Artificial Intelligence and Input Processing to the child class. This would helps us in focusing a specific task to a specific class, so we don’t need to worry about changing other part of the engine and ruining everything. At first this might sound tedious, but as the program grows, it will help a lot in reducing the complexity of your codes. And besides, it looks cool ^^

Anyway, other than this classes, there are also other classes, one example is Sprite class, which is a member of Class Entity (which makes it also a member of all Entity child classes) that handles image and animation. Another one is World class, a class that handles interaction between objects of different classes (say, like handling how a bullet damage an enemy) and Map class, a class made for handling map and tiles.

Seems pretty neat, huh? But all convenience comes with a price. Even though separating codes into classes helps us in solving problem, another problem rises. It is how to process interactions between those different classes, especially when they are blind to each other. It is much like building a computer, even though we have several awesome component, without any way to make them work together, they are useless. So, if a computer uses a motherboard to connect different components, I use World Class to handle classes interaction.

This diagram shows the engine main process, and how it is separated to different classes.

A detailed Input > Process > Output diagram

A detailed Input > Process > Output diagram

As you can see, there are 2 main parts here, the Game Engine, and the World Class. This is how I apply the Input > Process > Output formula to the engine, where Game Engine handles the input and output part, while World Class handle the processing part. So, basically, Game Engine is the outer layer where the human player interacts with game, while World Class is the game world, where everything in-game happens and processed.

Let’s take a closer look at World Class, code-wise, we can see that it is divided into two, the member part, and the procedure part. Objects (like enemies, actor, pickups) are members of the world class, so the part that process the members are referred as the member part, while the procedure part refer to the procedures used to handle interaction between the members. You can see that there’s a lot of transitioning between classes, from Objects Class to World Class, etc. Many of these transition used pointer, like collision checking used pointer to access an entity rectangle, but some also used public access procedure, like projectile class used a specific read-only procedure to access character’s private data.

Now, an example of how all this process worked. First of all, we’re checking for player input, say, the player gives a “go to the right” command to the game character. This input is then transferred to the Actor Class, which must process and validate the input given. If the input is valid, it is then translated into a State (I’ll describe this “State” thing some other time, since it is useful for a lot of things, so I might expand it). Then the World Class take over, it will start processing each object, like Actor object, Enemy objects (processing it’s AI),  projectile objects, etc. These processes actually take place internally within each class, because it only needs to handle itself. Then, after each object has been processed, World Class will proceed with handling interactions between objects, like projectile hitting an enemy, the actor picks up a power up, and also collision checking. After all the processes are done, each object updates their sprite class to match their actual data.  And then, the Game Engine takes over again, taking the updated sprite data and displaying it to the screen.

Whew, that was some long description. No wonders, I spent like, 3-4 days to restructure the program, encountering some difficulties in translating from procedural paradigm to object-oriented. So, it is best if you plan ahead and implement classes and the like as early as possible, because restructuring a program after it has grown complex is much more difficult.

For the closing, how about a teaser screenshot:

The X Buster (Not charge-able though)

The X Buster (Not charge-able though)

Yeah, I’ve been working on the shooting system. As of now, I have the basic done, but I need to expand it for other stances, like shooting during jumping, etc. And I also need an enemy class to test the damaging system @.@

So, my to-do list would be:

  • Multiple shooting stance (climbing, jumping. etc)
  • Optimizing tile collision system (kinda buggy now)
  • Adding enemies
  • Adding projectile damaging system
  • Adding scrolling system to the map editor

There’s only a week of holiday left, how far I can go I wonder…

Platformer Engine update and Map Editor v0.5

September 8, 2009 Leave a comment

Hi guys!

Been some times since I last wrote anything about my platformer engine project. So here I’m going to update you all about what has happened with it, since a lot of thing has changed since it’s last update. So, here’s a screenshot:

X: "Yay, now I can jump in a real map!"

X: "Yay, now I can jump in a real map!"

Yeah, if you compare it to our last screenshot here, you can see there’s a lot of difference now, some major changes I’ve made:

  • Added a jumping system
  • Added tile-based collision
  • Changed how character state works
  • Added map reading system
  • Added gravity

Some of them are still buggy, like the jumping system animation is not fully done, buggy control on jumping, etc. Yeah, most bug is mainly on the jumping system, since I need some reference before I can perfect it, and since I don’t have my megaman games right now, I need to wait a bit before I can go back to work on it. Oh, and another feature is…

Climbing still needs a proper sprite

Climbing still needs a proper sprite

…climbing! Yeah, don’t worry, it’s a not a bug that made the character looks like that, I’m just too lazy to sprite myself a climbing sprite, so I just flip the walking animation. Yeah, this is a feature that I find interesting to have, I mean, with the addition of climbing, we can get a brand new level design that exploit this ability. As of now, the character is only able to climb vertical wall, but I was planning to make him able to climb horizontal wall as well, making him able to hang from the ceiling (I wonder if I should add some kind of stamina for climbing, what do you think?)

So after 2  weeks of no updates, it’s just this? Heck, no! The next screenshot will answer it:

Creating map with Map Editor 0.5

Creating map with Map Editor 0.5

Yep, you guessed it, a map editor! If you’re one of those keen observers, you would have noticed that we’ve got an entirely different map than the one showed in the previous screenshot, it is the product of this very editor. This one is build using C++ and windows API entirely from scratch, I was thinking of making this one in visual basic, but I figured that this would be a good chance to learn window programming with C++, so here it is, I spent like, a week for this thing.

Anyway, current version is still 0.5, so there are still a lot of improvement to add, but this one here is already powerful enough to create a decent map easily. It can, unlike most small, free map editor out there, select more than one tiles and put them on the map! Though, the most urgent feature I’d like to see real soon is the ability to create a bigger map, since I still hasn’t implemented any kind of scrolling system on this. Some other features that I’d add are tool buttons and map layer.

Anyway, Platformer Engine is progressing fine, with all the framework it now have, adding a feature is a breeze. Though, I’m in the middle of restructuring the whole program now, since this thing has grown beyond my expectation, so I need to implement a new architecture on this thing. And with the next feature I’m going to add is the ability to shoot, I really need to have a solid structure so I can make classes interact easily with each other, which is the main goal of the restructuring.

Programming Addicted?

August 23, 2009 Leave a comment

Sigh, and I still haven’t got around to writing the about page…

Anyway, I can’t believe I spend my whole saturday programming my Platformer Engine. Yeah, with 2 of my roommates went out of town, another was being busy with his own agenda, and my girlfriend went out of town as well, I didn’t really have anything to do, so I just stayed in my room, sat in front of my laptop, and started coding it, oh, and not to mention that I was fasting too, so I didn’t really need to go out to find some foods. And what’s worse is, I didn’t regret doing it. I mean, with all the games sitting in my laptop (and hard disk), I still chose programming over them, and I feel happy about it. Sigh, and my Fallout 3 is still far from finished. I’m just afraid I’ve become addicted to programming, much like a person gets addicted to gaming, but this one’s with programming instead. And that’s just when I think I have handled my addiction to gaming…

Anyway, speaking about programming, I’ve finally finished the 2D section of Beginning Game Programming Second Edition. There’re still around 4 chapters dealing with 3D, but I’ll leave it for later, since as of now, I want to fully master 2D first. So, my next move is to create an engine for platformer games (you know, Megaman, Mario, etc), and it comes along just fine, there’s a bit of trouble when implementing class, but it’s been solved now. I already have some kind of game in mind, though I would save it for later, since I still need to draw all the sprites @.@

Platformer engine screenshot

X and his tilesets on Platformer Engine

Oh well, let me give you a little progress report (and a screenshot) of my Platformer Engine for this week. Well, I haven’t modified DirectX Framework much so far:

  • Added a tile mapping system.
  • Added a map scrolling system.
  • Started implementing classes.
  • Optimized some image reading functions.
  • Added some controls for the character.

The basic engine is really almost done, I just need to add more advanced features like jumping, reading an outside source file, etc. I also need to make myselp a map editor, so I could create a better looking map with the tileset I got.

And yeah, I finally found some Megaman X tilesets! Those are pretty rare actually and would help a lot in imagining and designing the collision detection system. I also got a complete Megaman sprite, which would really help in making the animation system for everything the engine will be capable of, like jumping, climbing wall, air-dashing, etc.

If there’s anyone interested, here’s a link to Sprites INC, where I get the megaman sprite, and VGMaps, where I get the tilesets (it’s actually comes from map images, so you still need to tile and set them properly).

Follow

Get every new post delivered to your Inbox.

Join 111 other followers