Sorry for the extensive break I've had from Crevis. I've several things in the past month and a half, most of which are fairly boring.
I first continued where I left off and implemented the day/night system into the game. It looks great, but I plan to add shaders to the sun to give it an edge of realism.
I spent the rest of the time trying to resolve a particularly annoying lag spike, and I've been pressed with a particularly hard decision. A major lag spike happens when entering a new chunk and lasts for about a fourth of a second. It may not seem very long but it can be very annoying when exploring new terrain. Unfortunately, I wasn't able to find a way to remove the lag. One way of reducing the overall lag is to rewrite the inventory system, as its pretty inefficient.
My personal knowledge of memory management and arrays have grown greatly over the past year, and the inventory system that I created last March is not as efficient as it can be. I plan to rewrite the inventory system shortly, which should bump the game's frames up by at least fifty.
Now, onto the meat of the post - using color to store multiple values.
The GameMaker coding language doesn't have very many datatypes. For example, a vector3 would have easily allowed us to put three values into a grid cell. Unfortunately we don't have that data type. This presented me with a problem. I needed at least one metadata slot, so I created a separate grid to hold metadata. As time went on the need for metadata kept coming up - durability, random block sprites, enchantments, and so on. These are values that cannot be held by a single slot.
I had to find a way to put multiple values into one grid cell. At first I used ds_lists but they ate up way too much memory. I made a post on the forum and someone mentioned make_color_rgb.
This function allows you to create your own colors by inserting a value for red, green, and blue. The value it produces is a 24 bit number that stores the three values, perfect for what I need. Today and tomorrow I will be re-organizing item property lists and will be implementing a system that can incorporate the function into the game.
Until next time!
Hello everyone! I have completed the day/night system in a test room! It now must be put into the game, but that's as easy as dropping the object in the game room. It needs a bit of tweaking and I'm going to replace the sun and moon with proper sprites eventually. Here's what it looks like.
So, how does it work? There are a ton of different elements in within the day/night system that you probably would not have thought of.
The day/night system correlates with the time. Time is a value between 0-1440. There's one minute to an hour, making each day 24 hours. 1440 is the amount of seconds in a day. I will be referring to the numeric value of time (0-1440) as "raw time."
A proportion calculates the angle of the sun based on the raw time. The sun is then drawn on the ellipse at that angle.
In this example, the proportion calculates that the sun should be at 90 degrees on the ellipse at 12:59 PM (780 raw time). It gets the position of the sun from a series of scripts.
The fading backgrounds was done very simply with a phase system. Phases are certain spans of time with specific backgrounds. There is a phase for every fading animation as well as static backgrounds. To get the fading effect, two images are stacked: the image to fade from and the image to fade to. The image to fade to starts with zero opacity and then increases to maximum opacity as time goes on. This system uses NO alarms and is very dynamic.
Until next time!
I'm not really sure what happened last month, but I didn't post anything. Oops! In the beginning of the month I was quite busy with school activities, but I started to pick up development towards the end of the month, forgetting about the blog... sorry about that guys! So... here's everything I've been working on/am still working on!
I was experiencing severe lag spikes when going from chunk to chunk. I did a bit of debugging and found that the source of the lag was saving the chunks. To optimize it, I made sure that the chunk had been modified for it to save to assure I'm not just saving the same exact thing.
After receiving help on the GMC, it was deduced that the GameMaker function ds_grid_write was slowing the game down immensely, so I tried using buffers (a faster way of saving/loading in short). It worked perfectly except for the fact that I was getting some weird bugs with it so I switched back. I will probably try to get this working again in the future.
Saving objects within chunks
I have also been working on being able to save objects within chunks. These objects are created when the chunks are initially loaded and then deleted when the chunk is unloaded. I am having trouble deleting them when the chunk is unloading, but I think I can get this working by tomorrow or the next day.
As you know, severe lag spikes happen when crossing into other chunks. I optimized it a tad by making it so that chunks had to be different than what's already saved for them to be saved again. By preloading all of the chunks, it eliminates pretty much all the lag, which is awesome.
Cellular automata caves
Today, I completed underground cave generation using cellular automata (4-5 rule)! It needs tweaking, but it's a great start. I'm excited to start adding vines, stalactites and stalagmites, and pockets of ore.
I also did some minor things:
Sorry for the lack of posts recently - I've been busy with schoolwork (yes, it's that time already). Today I perfected background blocks and made it so that separate chunks are generated for the biome, creating interesting background terrain. Check it out!
I also created lightmaps - essentially, they're grids that store light data (chunk cells that can either be 0 or 1, depending on whether there's a block there). This allowed me to incorporate background blocks with lighting and it also allowed me to create light blocks - more on this tomorrow. However, with all the new additions, I've noticed a surprising drop in framerate. I plan to fill next month with optimizations (or the remainder of this month).
In the screenshots you can also see that the player rig is in complete disarray... still working on it. After I sort the rig out I'll focus on incorporating light blocks & optimizing the game. I'm also going to be implementing water in the near future.
Until next time!
I have spent the last four days organizing data structures a lot of the messy code in the game, making it easier to create new content. I also made an adjustment to chunk saving to allow for more data to be saved - chunks are now saved within ini files. This allows me to save other things like metadata and multiple chunk layers within the same file. Metadata is also something I have really wanted to incorporate with the chunk system, because there are still objects that cannot be saved as tiles - chests, crafting tables, etc.
I made a separate ds_grid for background blocks and also am going to make a separate grid for metadata - not sure if this is the most efficient way of doing this, but I'll try. Here's a screenshot of the background blocks -
Not the best showcase, but I wanted to have some kind of screenshot for you guys... haven't posted anything interesting for a while.
Until next time!
February's task is to improve the combat system and create a system for enemies and their AI.
The author of the blog is Alec. He posts weekly, usually on the weekends on Saturday.