About this blog
Exploring of a world of code, coding a world of exploration...
Entries in this blog
Implemented hammer rotation, background, and the unfinished basics of a entity system.
My game name: "MC Hammer Toss"
You play as a hammer, and you move it around to get it through a moving jumble of objects trying to protect a crystal or something that you are trying to break. The crystal moves around, with its guards moving with it.
I intend to have multiple enemy types: Most defensively protecting the crystal that you "can't touch", but also one or two offensive ones trying to kill you. Also, possibly level terrain.
First up: Drawing a good hammer.
Just finished drawing the hammer, which you can see here:
Searched Google Images until I found one I liked, then drew over it and remade it.
The contest started. The theme is "[color=#1C2837][size=2]MC Hammer, "U Can't Touch This[/color]"".
My first task is (obviously) to design what the game will be. I will prioritize by coming up with three features or ideas that I will build the game around, and work hard on implementing those three things first. If the gameplay isn't fun, no matter how much I polish it, it wont still wont be fun.
My first spot of time is only 2 hours long, then I have to run off to a prior engagement for ~3 hours, but I'll have plenty of time after I get back. I'll post my design choice as soon as I come up with it (hopefully within the first hour)
I'll be taking a minor break this weekend to participate in the GameDev.net Community Challenge.
I'll be writing updates on my progress (when time allows) as the challenge is underway, and you can see all related posts by viewing my Journal category labeled "Community Challenge". I also have an album where screenshots of my entry shall go. (Currently empty, since the challenge hasn't started yet).
For my project, I'll be using C++ with SFML as the 2D graphics API, using the QtCreator IDE, and compiling with the MinGW port of GCC as my compiler. Depending on what I decide to make once the theme is announced, I may also use Lua in my project.
I've been working hard to get more work done on AdventureFar, but still not much visible progress. My hard work hasn't converted well to legitimate progress over the past 4 or 5 weeks. I decided to change the map format I was using, to reduce the amount of costly parsing the game needed to do when loading map chunks, because I still haven't quite achieved 100% seamless transitions. It's getting closer and closer, but not quite there yet.
Previously, I was doing alot of text parsing, with almost everything stored in text for convenience, but now I'm pre-parsing alot of it and storing it in binary to just read it into different parts of the struct directly. I'll find out how much time this saves me in a few days, once I track down a few nasty bugs that popped up.
I'm not dead - I just haven't haven't posted for 2 weeks.
I've made alot of progress, but alas! I have no pretty pictures to show you. Instead, I'll talk some about what I've implemented, and how I hope it'll help my game be successful.
First and forth most, my game world is divided into 'areas', and an area is broken up into chunks that are 20 by 20 tiles. An area can have as many chunks as it likes. The player is always at the center of a 3 by 3 grid of chunks - the 9 chunks that are currently loaded. I've been working to optimize the loading of chunks; when the player crosses a chunk boundry, there used to be a very big pause as it loaded the new chunks (part of the pause was me forgetting I was running debug mode ).
I've cut down that pause a great deal (some silly mistakes that were wasting speed, but also some clever optimizations), and it's now only 0.05 seconds on average, though it's still noticeable, and some chunks are taking up to 0.15 seconds. I want to get it down to 0.01 on average, if I can. My game needs to support older computers if I hope to make a profit, and some of my areas will be much higher detailed than my current test area (though I don't anticipate much of an problem for higher detailed chunks).
There are still a few more optimizations I want to implement before I consider some of the more drastic and dramatic optimizations like multi-threading the loading or loading more chunks that the basic nine while the player is walking around.
I can now walk across a (nearly!) seamlessly scrolling area. The only 'transitions' in my game will be (due to design choices, not engine limitations) transitioning from places like towns to the outside, or from plains to forests, or from the outside of towns to the inside of buildings. I personally feel these type of 'area' transitions are important to giving the player a sense of indentifying areas.
I could very easily make my entire game take place on a single giant seamlessly scrolling area, at no extra performance costs and no extra work coding or mapping the area - but I actually *like* the feeling you get when crossing over in a 'new' area while playing a game. I also like the feeling you get when 'exitting' an area you were training in, giving you a sense of 'relief' from the dangers of that area. I greatly enjoy knowing that I 'made it through' a dangerous area that I was travelling through - it's a feeling of victory and relief. That solid boundry line between areas is important.
Game flags system
Another thing I've been working on is a single system that gives scripts a great deal of access to valuable information.
It's basically just a tree of key-value pairs that I'm going to use for storing quest information, player stat and equipment information, and all sorts of data.
It looks like this:
The game flags don't dictate that you store the information in any sequence like 'Game.World.Nation.Area', that's just something I'll make myself and any other script writers adhere to for organization. Scripts can read and write to any flag, unless the flag or one of it's ancestors is read-only or blocks creating children.
The ones that are read-only are (some of) the ones that the engine creates itself. I use underscores to visually distinct built-in flags.
An example would be:
All the player's stats and skills will be built-in also.
[color="#006400"]Game.Player.Stats._strength[/color] (for example)
Hopefully this will give the scripters a lot of flexibility while still maintaining readability of the scripts in the future.
Game packs system
I've also set up a system for managing (user-made)mods and (official)expansions to my game. The game looks inside two folders (named 'Mods' and 'Expansions') for game packs. It then builds a list of them, and establishes a generic 'order of importance' for them.
The (as yet unmade) menu for the game packs will look something like this:
(The game itself will not be able to be disabled)
This allows players to manually fix incompatibilities between multiple mods (if they, say, use similarly name filed or make areas with the same name) by choosing which ones get priority. This also allows mods to mod other mods, or 'graphic pack' mods to be applied even to other mods' areas. Further, this allows players to disable/enable mods at their leisure, even disabling expansions (or just one of the expansions) to play the purely original game if they want to.
When loading a file, it runs through the game packs that are currently enabled, and checks if the file exists in each of their directories, and goes with the file that is in the directory of the game pack with the highest priority.
For example, if I wanted the game to load file "Data/Tiles/Plants/LargeTree.png", it will look in these places, and will return the first one it finds, in order of priority first:
I can manually specify to look only at the directory of a single mod, expansion, or the game itself if I want, by specifying something like this:
This makes the addition of expansions very easy to release. I don't really expect a lot of mods (or any) to be made, but implementing the features might encourage a small mod community to build around my game, which might help with sales. Since I get these modding features for free, while implementing the expansion system, I might as well add it and hope someone makes use of it.
The real benefit, however, is that I hope it'll speed up the process of releasing expansions. I intend to release two expansions to the game after the initial game is released: Two expansions expanding the world, and one free expansion expanding the game's content (adding new features and abilities). The free expansion will be given to you once you purchase the first two expansions.
So yes, progress is being made. I'm working to complete my first major milestone (out of five), and I'm watching bemused as my 'todo' list to meet that milestone both shrinks and grows at the same time (thankfully, it's shrinking faster than it's growing. ).
While working on this milestone, I've implemented alot of things that'll help contribute toward the other milestones. I need to get this milestone knocked out soon, because until I do, not a single map can be made for my game - this milestone is holding me back from completing the editor.
Music is being composed by the composers, and my older brother is working on concept art for the main character. Someone is working on the plot of the game too, but we'll see how much of it I'll actually use. I'm not worried about it being high quality, but I am worried about it not being... 'my cup of tea', as the British say. (or as the Americans pretend that the British say, anyway )
Once I finish this milestone and get the editor updated (current guestimation: Maybe a month), then I think I'll forgo working on the game's interface as previously planned, and instead work on the combat system first.
Here's a picture of my game's main directory. I'm very happy with this project, much cleaner and better organized (both the files and the code) than my previous one.
Hopefully I'll have real screenshots in a few weeks.
Here are some pictures of furniture I've made. Some of it was for a previous game I was working on with some online friends, some I more recently made for AdventureFar (this is why some furniture is two tiles high, and some is three tiles high).
I'm just going to picture spam you here, so don't mind me.
I didn't feel like chipping away at my todo list last time I coded, so I decided instead to implement some new graphical features to AdventureFar's tile engine.Specifically, I wanted to add shadows for any map makers to place on a map. Iended up doing a bit more than that, and added five different ways of blending stuff together, using the same blend modes PaintShopPro or PhotoShop uses.
Previously I had tiles and masks, and I could only apply that mask in one way. Now I can choose how I want the mask to be applied to the tile. I can apply the mask as illumination or as shadow, or I can continue to use it as exclusion to make the tile partially or fully invisible.
Here are pictures of the new blends I added (all images taken from within AdventureFar), as well as the algorithms to implement them. I intend to add additional ones later, just to give map makers more tools to use creatively. Now that I have them in, if I know the proper algorithm it only takes about 5 minutes to add a new blend mode to the game.
In my game, all of this is done only once when the map is loaded, and the blended tile is then cached. There is no run-time cost for these blends except the initial increased load times. If the same mask is blended in the same way to the same tile, then that final image is shared and it doesn't take any more memory than previously.
I also added the ability to (inside the engine) run the same blend multiple times in a row, as seen here where I am using Multiply blend for five loops:
Overlay blend was the hardest to do, because all the articles I read online, including PaintShopPro's and Gimp's stated algorithms, weren't producing the correct result for me. It turns out you have to apply it per color channel, not per color. The big thing with Overlay is that it darkens and brightens the image, depending on the mask. It's a mix of both Screen blendand Multiply blend.
Here's an example: [size="1"](images stolen from [size="1"]elsewhere on the internet[size="1"] and then implemented in my game)
If the pixel is less than 128, you use something similar to Multiply blend. If it's greater or equal to 128, you use something similar to Screen blend. However, you do it per color channel of the pixel, not per the average of the pixel, like I was doing (which was an obvious mistake on my part). So on a single pixel you might Multiply the red channel but Screen the green channel, or whatever. This is the proper way to do Overlay blend.
Another part of the confusion is all the articles I read online just say, "if less than 128 use Multiply, otherwise use Screen blend". This isn't entirely true - the multiply used in Overlay Blend is different than the regular Multiply blend. They multiply it by 2 afterward, to make it not contrast with the Screen blend as jarringly. They do the same thing with Screen as well. Observe:
If you compare Overlay blend with Multiply or Screen in your image editor of choice(or in the table above), you'll notice that the Multiply will be almost twice as dark as the dark parts of Overlay, and Screen will also be somewhat brighter in the same spots than Overlay. All the articles I read failed to mention that... =)
The proper Overlay blend mode algorithm like in Photoshop, PaintShopPro, or Gimp, is as follows:
[color="red"][size="2"](Warning: Gimp mixes up the name of their 'Overlay' blend. Their 'Overlay' is misnamed 'Hardlight', and their 'Hardlight' is misnamed 'Overlay'. This is their mistake, not Photoshop's or PaintShopPro's, as you can easily deduce when reading Gimp's documentation. The 'Overlay' I show above is called 'Hardlight' in Gimp)[/color]
While doing all this, I also realized I was doing alpha transparency wrong when applying masks to tiles.
Here's what I used to do:
int alpha = maskColor.GetAverageValue();
Here's what I'm now doing:
int alpha = (tileColor.GetAlpha()* maskColor.GetAverageValue()) / 255;
What was wrong with the previous one? It overwrites the tile's transparency with the average of the mask. If the tile already has transparency, its transparency is ignored! The new code takes into account the transparency of both the mask and the tile. Observe:
With the bad result, it ignores the tile's original transparency. If the tile doesn't have transparency, then the new chunk of code produces the exact same result as the old code.
As an added bonus, mask blending is now stackable just like the other blends. I can run the same mask-blend several times to make the tile increasingly more transparent. (This is actually what led me to discover this mistake in the first place - realizing that consecutive mask blends wouldn't stack properly,and then further realizing that they wouldn't even stack on the tile's original alpha channel).
Resources that helped me:
I made a good amount of refactoring progress on AdventureFar the past few weeks, but mostly it's non-visible.
I got collision in and just about finalized the world format. My tiles now carry extra information in a very extensible way, so a tile can be a type "Wall" or type "ScriptTrigger" or type "Teleporter" or all three at once, and each type can also carry type information to further customize that tile.
I've also made the move to Boost, and while doing so, converted all my raw new and delete calls to smart pointers (a shockingly easy transition). This is a first for me. I'm also using exceptions now, which is also a first. These two additions has helped clean my code up a good deal, alongside the other refactoring I've been doing.
I just downloaded a program called SourceMonitor, since QtCreator doesn't provide source code metrics by default.
It's really cool. Here's AdventureFar's stats:
% Branches: 12.6
% Comments: 15.6
Class Defs: 38
Avg Statements/Method: 5.2
Max Complexity: 24
Max Depth: 6
Avg Depth: 1.08
Avg Complexity: 2.21
On one hand, I feel slightly disappointed at the project size - I thought it was way more lines and classes then that. Certainly feels like it.
On the other hand, I've been trying my best to write clean and compact code, so I guess I've been (mostly) successful, especially when it comes to keeping classes as small as possible and making sure functions only do one thing. I've been inspired by the simplicity of APIs like SFML, where the source code is very minimalistic and clean.
Looking at the stats above, I'm especially please with the average depth of a function only being 1.08, and the average number of statements per function being 5.2. Pretty good! I just need to refactor the 4 or 5 extreme cases like the 'Max depth = 6' and 'Max complexity = 24' functions.
I made some progress the last two weeks, but not as much as desired. I don't know how [s]VertexNormal[/s] JTippets possibly cranks out the amount of work he does. I guess it comes with experience.
I got a character walking around, but I'm using placeholder art for the avatar at the moment. I also put in support for animated character walking (it still needs some higher level code though) as well as animated tiles such as water.
(The window thing at the bottom is going to eventually be for a dev console. It's not the actual game's GUI)
Since most of my progress isn't visible screenshot-wise, and since very little progress got done anyway, I'll just post some of the new furniture art I made this past week.
I'm running a bit behind schedule, according to my progress guide, but that was to be expected - I have only previously completed one game of any real scope. I'm currently about 15 days behind, and will probably drag on to about a month behind schedule before my first major milestone is completed. I need to put a good week or two into the plot to iron it out, before submitting it for peer-review. This is important before starting creation of the world itself. I also need to update the editor once I hit the first milestone - the first milestone being the finalization of the map format, and the ability to explore the world (script triggers, collision, area transition, etc...).
On an unrelated note, I finally got around to installing Boost. I look forward to playing around with it, and seeing where I can save myself time by implementing it into my game framework.
My world is displaying again, after a week of refactoring some of the code. Now more of the editor's features are working in the actual game, as you can see in the screenshots below.
As I think I've mentioned previously, I can procedurally apply color to tiles in the editor; this color now displays fine in the game (Tile rotations and tile masking are also working again). My editor is now out of date, compared to the game itself - I'll have to update it when I get a chance.
[size="1"](Note: this is coloration, not lighting. I don't intend to add light in this game)
Coloring tiles are very useful, as it expands the possibility of the map designers. Which is mostly me, but a few others have offered their help as well. Here's an example of its use to the mappers:
[size="1"](Ignore that one marble tile that stands out too much. I'll adjust it later)
Now watch: By tweaking the coloring of the walls, I get a whole different mood to the area. Warmer colors, warmer feeling. Less dungeon-y and more like some rich guy's house.
(I a[size="1"]lso changed the baseboard in the next shot (the little trimwork where the floor meets the wall))
Add in some redwood floors...
...and now all I need is some furniture in there, and I'd be happy to move in.
[font="Verdana"][size="2"]Here are the first screenshots of AdventureFar. I just got the world displaying yesterday night.[/font]
[font="Verdana"][size="2"]Keep in mind that some of the art in the village is placeholder (noticably the non-tiling grass), and some of the art is from previous projects. The art will improve dramatically once I can focus on world development instead of programming.[/font]
[font="Verdana"][size="2"]I would've loved to toss in some trees and plants or other objects to make the scenes more interesting, but tiles with transparency recently stopped working in the editor, and I haven't yet gotten around to fixing it.[/font]
[font="Verdana"][size="2"]The way my engine works, is that the world is broken up into Areas. Each Areas can contain an infinite number (until you hit limits of memory or whatever) of seamlessly scrolling AreaChunks that are loaded/offloaded as needed. These AreaChunks are 20 by 20 tiles and contains an infinite number of Floors that entities and objects can be on. One floor can be above another floor, and the player can move up or down floors. This is useful for example, if a player needs to walk under a bridge, and then turn around and walk across the bridge he just walked under.[/font]
[font="Verdana"][size="2"]My engine also supports transparent tiles with varying degrees of transparency, and also the ability to alter the transparency of a tile as a whole, right in the editor. You can also rotate the tiles, mirror and flip them, and even adjust the coloration. It also supports tile masking, which is a feature I've always wanted to play with.[/font]
[font="Verdana"][size="2"]Pardon for the rushed journal entry - I decided I need to replay The Lost City of Malathedra, and thus just reinstalled it.[/font]
Hello again. There's something about talking about your project publicly that motivates you to work harder on it, isn't there?
Well, I'm back, and with more details about my hopefully-oneday-commercial 2D RPG, "AdventureFar". Ready? Go.
AdventureFar development schedule:
As I promised earlier, here's my desired schedule for AdventureFar's development:
I don't know whether I'll be able to meet the milestones or not, but at least I have goals to work toward now.
The first 8 days of this month was spent chasing down a weird issue with ATI's Catalyst drivers which were keeping my program from launching (Wasn't my fault - their most recent drivers were faulty, it had nothing to do with my code). I also spent 3 days focusing on how I want to approach the 2011 in my life, so I didn't actually get coding until about the 14th.
However, my Map Editor and my game itself share a good chunk of code in common, particularly when it comes to displaying maps, and my first milestone so happens to be, "Get maps displaying" - What a coincidence! So even though I lost half the month, I don't expect to be any more than 5 to 10 days late on that milestone.
Ofcourse, the late time accumulates from milestone to milestone, and not everything that needs to be done is listed on that chart - only the major things. Those small tidbits add up and take time as well, and unexpected/overlooked things I need to do might pop up from time to time.
Since I'm doing pretty much everything on the project on my own (only delegating to those who offered their help things I'm confident they can do), I'm already wondering how I'm going to code the game, make the artwork, write the plot, script the quests and NPC conversations, and ensure the world gets created properly, all at the same time.
But I have no managers or publishers enforcing a hard release date, so if I must go longer to make a well polished game, then longer I shall go. I'll just have to re-adjust the schedule every few months to accommodate incorrect estimations of time costs, but hey, that's to be expected. That's also one of the benefits of a schedule, I can see I'm actually making progress, and I can see how much needs to be done, so I know that I am in fact getting closer to the goal. Even if the goal keeps moving back each time I re-estimate my schedule, I know that I'll always have moved two steps forward for every one step the goal gets moved back.
It's more of a progress guide - a document set to guide and measure my progress - rather than a development schedule. A schedule is something you must keep, or you 'failed' and have to re-schedule. A progress guide is something that guides you to make progress, and as long as you are making progress, you didn't fail, even if you miss the milestones (that's the definition I just made up, anyway).
So, uh, this schedule is not final, and no release date is set in stone.
My progress guide is more than just the desired timeline; it also contains a breakdown of different steps in the different parts of development (Code, plot, content creation, etc...). Currently it's only 5 pages long, but two pages don't really belong there, and should be in their own document - detailed questions I'm asking myself to help me flesh out some of the main characters (I'll post that some other time, perhaps, but it doesn't really belong in this journal entry).
Here are two other relevant parts to my game's development:
[font=arial, verdana, tahoma, sans-serif][size=2][font=Arial]Good evening, GameDevers; this is my new development journal (I refuse to call it a blog) which GameDev has graciously given me (a mistake they will surely pay for).
I'll be using this journal to document the progress of my 2D RPG which I have been working on for the past 6 months - all of that time was spent on the Map Editor, and I only started on the game itself about 20 days ago. However, a good chunk of code is shared between the map editor and the game itself, despite using two separate APIs, so I already am off to a good start.
The game is a fantasy turn-based-combat RPG (swords and magic) but I'm doing my best to be original. No elves, dwarves or races identical to elves or dwarves but with slightly different names. Also, I'm doing my best to be original in my combat system and world exploration, and gameplay in general. Not innovating for innovation's sake, but taking what I like from games I like, and adding my own ideas into the mix - hopefully it'll be combustible when the time comes.[/font]
[font=Arial]I'll be sure to go into detail about my ideas for the game in the coming weeks - I have alot of ideas I'm eager to put in the game, that I feel mesh together well. The plot also will be submitted on here (and the forums) for peer review, but currently it is very much WIP. I hope to complete the plot and lock it in stone by mid February.[/font]
[font=Arial]A plan for success, even if you fall short of meeting it's milestones, still takes you closer to your goal than no plan at all would've taken you. With this in mind, a week ago I wrote up my timeline for completion of the game. My goal is currently to complete it by September, with a two month beta test right before than. By reading this you are contractually obliged to test my game come July and August.
Right now it is going under the code name "AdventureFar", because I haven't come up with a good name for it. I definitely will not keep 'AdventureFar' as the permanent name. I just had to choose some name, because having an actual name to the game builds my own confidence in the project and motivates me to press onward. I intend to sell this game commercially when finished, and port it to Mac OSX and also that penguin OS.
I don't have any pictures of cure kittens for you, but here's something not even remotely cute:
I'll post my timeline and more details of the game in the near future. I will make an attempt at updating this journal (not blog) once a week.
~ Servant of the Lord, logging off ~[/font][/font]