Hello everyone, just wanted to write a quick post to let you all know that I'm still working hard on Prospectus and I haven't given up on it yet. I've been having a bit of trouble finishing the port of the current version of the game over to Java, so I decided to set it aside for a few days and focus on something else that will keep me encouraged about Prospectus.
With this in mind, I've quickly put together a very simple main menu system which makes excellent use of the Slick2D java library. It is so well put together that I was able to get a basic menu system up and running in a matter of 5 minutes!
The general idea is that your game extends a class called StateBasedGame, thus allowing you to be able to make use of different states easily and effectively. Once you have created this basic game structure, the idea is that you create different classes that extend BasicGameState to represent your different states (MainMenu, Gameplay, PauseScreen, etc.).
The awesome thing about extending BasicGameState is that you are forced to implement three abstract methods. These methods are very similar to methods found in almost every XNA game created today (init, render, update). This allows us access to a familiar game loop that we, as XNA programmers, are comfortable with. This also allows us to use a global input manager that is maintained by our generic gameContainer (created by the StateBasedGame class). From here we can display our menu image, and check for user input, telling us either to enter the game, exit the game, or do whatever we tell it to do.
This is just a quick and easy example of how Slick2D is helping us develop and grow Prospectus into a great game. Here is a short video of the menu test in action.
Thanks for reading and check back for more updates!
Showing posts with label terrain. Show all posts
Showing posts with label terrain. Show all posts
Wednesday, August 10, 2011
Basic Menu System Using Slick2D
Labels:
demo,
game development,
Java,
Prospectus,
terrain,
youtube
Thursday, July 28, 2011
Extreme Makeover: Prospectus Edition
Hey guys I am very excited to bring you more news about Prospectus. I'm sorry it's been so long since my last post, but I have been busy making some changes that I hope will benefit more people down the road. Over the past few weeks I have been struggling with developing Prospectus only for .Net capable machines. I feel like I would be able to reach more people with Prospectus if I was not tied down to .Net machines. I have therefore decided to migrate the existing version of Prospectus (as well as continue on from here) to the Java language using Netbeans and the Slick2D Library.
It is my intention that more people will be able to play this game because I'm making it more platform-independent than before. I hope this does not upset too many people who were using this as an Xna-specific learning tool. I will do my best to make any code-related posts as generic as possible in order to continue to be useful and informative for the Xna community.
As always I want to thank everyone who reads this blog as it is a huge motivational tool for me to keep working on Prospectus. I will be bringing you new posts as soon as I finish porting the existing version of the game to Java, but in the meantime I hope you take the time to try out Prospectus for yourself and don't lose faith in me...I'm going to keep building this game into something great.
Until next time!
It is my intention that more people will be able to play this game because I'm making it more platform-independent than before. I hope this does not upset too many people who were using this as an Xna-specific learning tool. I will do my best to make any code-related posts as generic as possible in order to continue to be useful and informative for the Xna community.
As always I want to thank everyone who reads this blog as it is a huge motivational tool for me to keep working on Prospectus. I will be bringing you new posts as soon as I finish porting the existing version of the game to Java, but in the meantime I hope you take the time to try out Prospectus for yourself and don't lose faith in me...I'm going to keep building this game into something great.
Until next time!
Labels:
cave generation,
code,
game development,
Java,
platform,
Prospectus,
terrain
Tuesday, July 5, 2011
Alpha 1.0 Preview
Hey guys I'm just giving you a quick update about the latest addition to the game...updated, custom sprites for the player! I am very excited about this latest addition, mostly because I am not really an artist, just ask my wife :)
I'm getting even more excited about launch day, which I am glad to announce will be this next Friday, July 15. I will be uploading the first build of the game, mostly bug-free probably after I get back from the midnight showing of Harry Potter.
I will leave you now with a preview of my player:
And don't forget to vote for what the name of the game should be.
I'm getting even more excited about launch day, which I am glad to announce will be this next Friday, July 15. I will be uploading the first build of the game, mostly bug-free probably after I get back from the midnight showing of Harry Potter.
I will leave you now with a preview of my player:
And don't forget to vote for what the name of the game should be.
Labels:
animation,
C#,
code,
demo,
game development,
generation,
player,
sprite,
terrain,
XNA Game Studio
Friday, July 1, 2011
Revamping the Terrain and Caves
Hey guys I've been busy reworking the terrain and cave generation code to give smoother and less rigid results. I've also cleaned up the HUD to show less things and not clutter up the screen as much. Enjoy!
Labels:
C#,
cave generation,
Cellular Automata,
code,
demo,
generation,
inventory,
Perlin Noise,
terrain,
video,
XNA Game Studio,
youtube
Monday, June 27, 2011
Game Demos on YouTube
Hey guys I figured it was about time I upgraded my presentation quality with this game and starting recording some actual "gameplay" for you to see. So without further ado, here is the first in-game video for my Adventure Resource game:
I apologize for the low framerate, I'm still getting use to this new video capture program. I assure you the game runs plenty fast.
I apologize for the low framerate, I'm still getting use to this new video capture program. I assure you the game runs plenty fast.
Labels:
C#,
cave generation,
code,
crafting,
demo,
game development,
gathering,
generation,
inventory,
Perlin Noise,
platform,
platformer,
player,
resources,
terrain,
video,
XNA Game Studio,
youtube
Wednesday, June 15, 2011
Terrain Generation Explained
Hey guys I have been putting off writing this kind of a post for awhile (mostly because I didn't feel that my code was 'good enough' to show off), but I've had a request and so I will try and explain my method for terrain generation using a mixture of different techniques.
Let me start by saying that my way is definitely not the only way, or even the best way to create terrain; it just happens to work for me (for now). At first, what I tried to use was the Midpoint Displacement Algorithm for creating a rough sketch of ground-level blocks. This method was ok for the time, but I needed something else that gave me a more 'natural' look. This led me to the Perlin Noise algorithm, which turned out to be fairly easy for me to understand from reading a few good explanations of it. Before I put the code into my game, I also looked at techniques for cave generation, which was even easier for me to understand than the Perlin Noise.
For this reason, I decided to integrate the cave generation first as it was the easier of the two. My method for cave generation involves the classic 4-5 rule which states that a block is a wall if the 3x3 region centered on it contains at least 5 walls. Repeating this process n times gives decent looking caves in the map. The entire process is modified slightly in the last two iterations to further refine the shape of the caves and make them appear more 'natural'. Here is some code for example:
The main difference between my code and the algorithm in the link I provided is that instead of filling in an empty map, I'm poking holes in a completely filled in map. This in my opinion gives different and better results for me.
After I added the cave generation to the game, I felt confident enough to tackle the Perlin Noise algorithm. Using the method provided in the link I gave above, I produced this code to create my surface terrain:
A high-level explanation of what happens in a Perlin Noise algorithm (as I understand it) is that the final product is an array of y values (for height) that is the size of all the x values in the map. To get these values, we basically generate random numbers for every x value in the array and linearly interpolate between them to 'smooth out' the shape of the terrain. The link I provided above was, for me, the best explanation I could find about how to make a Perlin Noise algorithm.
I am by no means the expert on Perlin Noise but if you have any questions please feel free to leave a comment below. This is a very basic overview of my technique for creating terrain and it is by no means the only way or the best way. Also, I intend to modify this technique before my game is complete, so feel free to use my code in your own projects, although it may not work with your specific game.
As always, thanks for reading and I will give a game update as soon as I have one.
Let me start by saying that my way is definitely not the only way, or even the best way to create terrain; it just happens to work for me (for now). At first, what I tried to use was the Midpoint Displacement Algorithm for creating a rough sketch of ground-level blocks. This method was ok for the time, but I needed something else that gave me a more 'natural' look. This led me to the Perlin Noise algorithm, which turned out to be fairly easy for me to understand from reading a few good explanations of it. Before I put the code into my game, I also looked at techniques for cave generation, which was even easier for me to understand than the Perlin Noise.
For this reason, I decided to integrate the cave generation first as it was the easier of the two. My method for cave generation involves the classic 4-5 rule which states that a block is a wall if the 3x3 region centered on it contains at least 5 walls. Repeating this process n times gives decent looking caves in the map. The entire process is modified slightly in the last two iterations to further refine the shape of the caves and make them appear more 'natural'. Here is some code for example:
private void CreateCaves(int i) { // i == Number of iterations
if (i == 1) {
for (int y = Height / 10; y < Height; y++) {
for (int x = 0; x < Width; x++) {
// Percentage needs to be 60% to make 40% filled
// NOTES 06/10: Perlin Noise method functional and not bad,
// "Poking holes" cave creation method pretty good.
// NOTES 06/14: Making the percentage 55% / 45% is pretty good
// with the addition of possibly skipping over the block if the
// depth is too little
if (rand.Next(100) <= 55) {
// PUTTING HOLES IN COMPLETELY FILLED MAP
// AS OPPOSED TO PUTTING BLOCKS IN EMPTY MAP
blocks[x, y] = LoadBlock('.', x, y);
}
else if (y < Height / 7)
continue;
}
}
}
else {
int neighboringWalls = 0;
string blockName = "";
for (int y = Height / 10; y < Height - 1; y++) {
for (int x = 1; x < Width - 1; x++) {
if (blocks[x - 1, y - 1].Texture != null) {
blockName = blocks[x - 1, y - 1].Name;
neighboringWalls++;
}
/////// Some block tests removed to shorten code \\\\\\\\\
if (blocks[x - 1, y].Texture != null) {
blockName = blocks[x - 1, y].Name;
neighboringWalls++;
}
if (i >= 4) {
if (neighboringWalls >= 6)
blocks[x, y] = blocksDictionary[blockName + "SingleTop"];
}
else {
if (neighboringWalls >= 5)
blocks[x, y] = blocksDictionary[blockName + "SingleTop"];
else if (neighboringWalls <= 2)
blocks[x, y] = LoadBlock('.', x, y);
}
neighboringWalls = 0;
}
}
}
}
The main difference between my code and the algorithm in the link I provided is that instead of filling in an empty map, I'm poking holes in a completely filled in map. This in my opinion gives different and better results for me.
After I added the cave generation to the game, I felt confident enough to tackle the Perlin Noise algorithm. Using the method provided in the link I gave above, I produced this code to create my surface terrain:
private int[] CreatePerlinNoise() {
float[] values = new float[Width];
int[] realValues = new int[Width];
for (int i = 0; i < values.Length; i++) {
values[i] = PerlinNoise(i);
values[i] *= 10;
realValues[i] = (int)Math.Ceiling(values[i]);
}
return realValues;
}
private float Noise(int i, int x) {
if (i == 0) {
x = (x << 13) ^ x;
return (float)(1.0 - ((x * (x * x * 557 + 1049) + 2411) & 0x7fffffff) / 1073741824.0);
}
else if (i == 1) {
x = (x << 13) ^ x;
return (float)(1.0 - ((x * (x * x * 1303 + 2473) + 3229) & 0x7fffffff) / 1073741824.0);
}
else if (i == 2) {
x = (x << 13) ^ x;
return (float)(1.0 - ((x * (x * x * 4441 + 6277) + 7549) & 0x7fffffff) / 1073741824.0);
}
else {
x = (x << 13) ^ x;
return (float)(1.0 - ((x * (x * x * 4663 + 6007) + 6961) & 0x7fffffff) / 1073741824.0);
}
}
private float SmoothedNoise(int i, float x) {
return Noise(i, (int)x) / 2 + Noise(i, (int)x - 1) / 4 + Noise(i, (int)x + 1) / 4;
}
private float InterpolatedNoise(int i, float x) {
int y = (int)x;
float fractionalX = x - y;
float v1 = SmoothedNoise(i, y);
float v2 = SmoothedNoise(i, y + 1);
return MathHelper.Lerp(v1, v2, fractionalX);
}
private float PerlinNoise(float x) {
float total = 0;
float p = 0.5f; // persistance
int n = 4; // four octaves
for (int i = 0; i <= n; i++) {
float frequency = 2 ^ i;
float amplitude = (float)Math.Pow(p, i);
total += InterpolatedNoise(i, x * frequency) * amplitude;
}
return total;
}
A high-level explanation of what happens in a Perlin Noise algorithm (as I understand it) is that the final product is an array of y values (for height) that is the size of all the x values in the map. To get these values, we basically generate random numbers for every x value in the array and linearly interpolate between them to 'smooth out' the shape of the terrain. The link I provided above was, for me, the best explanation I could find about how to make a Perlin Noise algorithm.
I am by no means the expert on Perlin Noise but if you have any questions please feel free to leave a comment below. This is a very basic overview of my technique for creating terrain and it is by no means the only way or the best way. Also, I intend to modify this technique before my game is complete, so feel free to use my code in your own projects, although it may not work with your specific game.
As always, thanks for reading and I will give a game update as soon as I have one.
Labels:
C#,
cave generation,
Cellular Automata,
generation,
Midpoint Displacement,
Perlin Noise,
terrain
Sunday, June 12, 2011
New Block Type
Hello everyone, I have a game update to share with you. As of tonight, I have a rudimentary way of random inserting a new block type into the game world. Right now, I'm only using dirt and coal (new) blocks. I'm pretty excited about this newest addition to the game, as it will allow me to begin work on other things such as the player's inventory.
My method for putting coal blocks in the game is pretty simple at this point. First, I loop through all the blocks in the map, looking for the first non-null blocks (meaning that this block is theoretically the ground level for this particular column). I then loop through the current column and have a set of 'if-then-else' conditions that check if the column block in question is at a certain depth. Based on the depth there is a chance that the block will be a coal type, otherwise it is a dirt type.
I'm sure there are many other more sophisticated ways to randomly put different block types into the map, but for now this method will do just fine for me. I appreciate everyone who is following this game's progress and I will continue to provide updates as I make changes and improvements to the game.
My method for putting coal blocks in the game is pretty simple at this point. First, I loop through all the blocks in the map, looking for the first non-null blocks (meaning that this block is theoretically the ground level for this particular column). I then loop through the current column and have a set of 'if-then-else' conditions that check if the column block in question is at a certain depth. Based on the depth there is a chance that the block will be a coal type, otherwise it is a dirt type.
I'm sure there are many other more sophisticated ways to randomly put different block types into the map, but for now this method will do just fine for me. I appreciate everyone who is following this game's progress and I will continue to provide updates as I make changes and improvements to the game.
Labels:
C#,
cave generation,
Cellular Automata,
crafting,
game development,
gathering,
generation,
platform,
platformer,
resources,
terrain
Saturday, June 11, 2011
Caves caves caves!
Hello everyone I am very tired but I thought I should write an update of my game. I have been working feverishly on cave generation using a form of Cellular Automata and so far I have had decent results. I am still tweaking the algorithm to give more natural "cave-like" structures that connect to each other better, but for now I am pleased with my cave making skills.
I am also still working on using Perlin Noise to generate the shape of the terrain at the surface level, though this cave generation turned out to be easier (which is why I worked on it first). I am really excited with how this game is coming together and I believe a name needs to be created for this game (hopefully name chosen soon!).
I really appreciate everyone who reads this development blog and I try to provide updates as frequently as I can. Thanks for reading and check back soon for more news!
I am also still working on using Perlin Noise to generate the shape of the terrain at the surface level, though this cave generation turned out to be easier (which is why I worked on it first). I am really excited with how this game is coming together and I believe a name needs to be created for this game (hopefully name chosen soon!).
I really appreciate everyone who reads this development blog and I try to provide updates as frequently as I can. Thanks for reading and check back soon for more news!
Labels:
C#,
cave generation,
Cellular Automata,
game development,
gathering,
generation,
journal,
platform,
platformer,
resources,
terrain
Thursday, June 9, 2011
Dynamic Block Texturing Is Up
Great success! After too many days of struggling with the code to get the blocks updating their textures based on what blocks are neighboring around them, I finally have a working build that looks really good. The main trouble I was originally having was that I was trying to test for too many cases, which overcomplicated the entire thing.
What I first tried to do was test a block's eight neighbors to determine which texture should be used for that block. This was over-complicating the process; not only did I have to have the six textures for the simple left, right, top, bottom scenarios, but I also had to have textures for all of the possible corner cases. This left me very frustrated and in need of something else to do.
The solution to my problem was very easy in fact. What I did was shrink the block size from 32 x 32 to 16 x 16 and dropped the corner cases / corner textures. Please note that when I say corner textures I'm referring to a piece that has a corner cutout of it. I also created new textures for the blocks with edges that seemingly run together. This makes the cases in which there is an L-shape still look good in the corner spot because the top and right textures almost run together.
Other things that I did include changing the resolution to classic 800 x 600, changing the player sprite from a square to a thinner, taller rectangle (to more closely resemble the final sprite's size), and am running an UpdateBlock() method every time the player removes and adds a block (which updates the surrounding blocks' textures based on which action the player made).
The game is coming along nicely in my opinion. Next things on the list include better terrain generation, more types of blocks, player inventory, and many more things that I don't want to list for fear of getting overwhelmed by it all.
For now, please enjoy a screenshot of my small (but big to me) victory.
What I first tried to do was test a block's eight neighbors to determine which texture should be used for that block. This was over-complicating the process; not only did I have to have the six textures for the simple left, right, top, bottom scenarios, but I also had to have textures for all of the possible corner cases. This left me very frustrated and in need of something else to do.
The solution to my problem was very easy in fact. What I did was shrink the block size from 32 x 32 to 16 x 16 and dropped the corner cases / corner textures. Please note that when I say corner textures I'm referring to a piece that has a corner cutout of it. I also created new textures for the blocks with edges that seemingly run together. This makes the cases in which there is an L-shape still look good in the corner spot because the top and right textures almost run together.
Other things that I did include changing the resolution to classic 800 x 600, changing the player sprite from a square to a thinner, taller rectangle (to more closely resemble the final sprite's size), and am running an UpdateBlock() method every time the player removes and adds a block (which updates the surrounding blocks' textures based on which action the player made).
The game is coming along nicely in my opinion. Next things on the list include better terrain generation, more types of blocks, player inventory, and many more things that I don't want to list for fear of getting overwhelmed by it all.
For now, please enjoy a screenshot of my small (but big to me) victory.
Monday, June 6, 2011
Update on Terrain Generation
Hey guys, it's been a busy last few days. This weekend was fairly productive and even a little frustrating at times. However, after much digging on the internet and reading up on terrain generation techniques, I have decided (at least for now) to use a modified version of the Midpoint Displacement algorithm for my terrain generation.
So far, this seems to be working moderately well. The overall shape of the terrain (top layer, of course) is fairly randomized but not too chaotic. The issue I have yet to work out is my technique for putting the correct block (i.e. with the correct texture) with the correct sides, cutouts, corners, etc.
I have spent a fair amount of time tweaking my brute force if then else statements to handle the different cases, but am having difficulty when I get more than just a few cases to try. Anyway, here is a screen shot of my latest build in all it's glory.
Though I am having trouble at the moment, I am enlisting the help of the wonderful people on the Xna forums so I should except to have a better strategy for my blocks in the near future.
In the meantime, I will be working on either the player's inventory (which at this point would only include blocks he has 'mined') or fixing the map saving/loading which has no doubt suffered because of my new terrain generation procedures.
Check back often for updates!
So far, this seems to be working moderately well. The overall shape of the terrain (top layer, of course) is fairly randomized but not too chaotic. The issue I have yet to work out is my technique for putting the correct block (i.e. with the correct texture) with the correct sides, cutouts, corners, etc.
I have spent a fair amount of time tweaking my brute force if then else statements to handle the different cases, but am having difficulty when I get more than just a few cases to try. Anyway, here is a screen shot of my latest build in all it's glory.
Though I am having trouble at the moment, I am enlisting the help of the wonderful people on the Xna forums so I should except to have a better strategy for my blocks in the near future.
In the meantime, I will be working on either the player's inventory (which at this point would only include blocks he has 'mined') or fixing the map saving/loading which has no doubt suffered because of my new terrain generation procedures.
Check back often for updates!
Labels:
C#,
cave generation,
Cellular Automata,
game development,
generation,
Midpoint Displacement,
Perlin Noise,
terrain
Sunday, June 5, 2011
Terrain Generation using Midpoint Displacement
Well it's been a productive couple of days since my last post. I've been busy working on implementing a better random terrain generator for my game using some tiles that I made myself using Paint.net. I must say that I have never been a strong algorithmic programmer, but I have been reading up on the subject and from what I have found, an easier way to implement random terrain is to use the Midpoint Displacement Algorithm.
This algorithm repeatedly uses two points in space and places a midpoint between them. Then, one point on either side of the midpoint is created at a random height (or displacement) from the midpoint. This algorithm recursively calls itself and continues to create a rough terrain shape. The more times this is done, the smoother the effect.
I'm definitely not the expert on this subject, so if you would like to read more about it check out this post. In the meantime, here is a sample the results of my terrain generation code. Note that there is still much work to be done to clean it up and improve it. This is definitely the first time I've done this.
This algorithm repeatedly uses two points in space and places a midpoint between them. Then, one point on either side of the midpoint is created at a random height (or displacement) from the midpoint. This algorithm recursively calls itself and continues to create a rough terrain shape. The more times this is done, the smoother the effect.
I'm definitely not the expert on this subject, so if you would like to read more about it check out this post. In the meantime, here is a sample the results of my terrain generation code. Note that there is still much work to be done to clean it up and improve it. This is definitely the first time I've done this.
That's all for now...
Labels:
C#,
game development,
generation,
Midpoint Displacement,
platform,
platformer,
terrain,
XNA Game Studio
Subscribe to:
Posts (Atom)





