info

Crate Crash 2 & The Future of Crate Crash

0

Posted by Thomas | Posted in Flash | Posted on March 30, 2013

Hi Everyone!

Finally, after 3 long years, Crate Crash 2 has been released! After (literally) years of on and off work, and starting, and restarting the project, the game has finally made it to the internet! The Crate Crash series is my sweet sweet “Flash baby”. As you can see, even after years of fluctuating development, I have released it.

A little bit about the game

Crate Crash 2 has the simple goal of: Get all the crates off the screen! The environment is physics controlled, and features quite a few obstacles to keep you busy. I’ve been working on the Crate Crash series since high school, and it’s been my favorite flash game to develop so far. The concept is simple, and fun and can prove to be quite difficult to beat the levels. I wanted to make Crate Crash because of that reason. I also knew that people would like it. Crate Crash 1 has been played over 3 Million Times!! If that doesn’t scream success, then I don’t know what will, maybe 1 Billion Plays? :)

Lessons Learned From Crate Crash 1

The thing about Crate Crash 1, was that it was too hard! I never spent enough time polishing it, and reworking the physics of the levels into something that was more enjoyable and playable for people who haven’t been testing the game for months straight. The difficulty curve of the game was way too steep. Many of the websites that I posted the game to left the game with around a 3/5 Rating simply because of the difficulty. Maybe around half of the comments were focussed on how difficult the game was, rather than what they liked, or thought was interesting about the game.

With Crate Crash 2, I spent significantly more time adjusting all the physics in the game to create a more manageable, and fun experience. I didn’t want to aggravate players, and I certainly did not want to lose any players half way through the game because of an unbalanced level progression.

This leads me to the next problem of Crate Crash, I didn’t balance the level progression. I had metrics in the game that showed where people gave up in the game, and how well they did on certain levels, and more. For Crate Crash, it appeared that everybody was stopping at level 13. After not playing my own game for months, I could understand why it was so difficult. Because of this mishap, I had my friends and family testing the game, helping me decide what levels were easiest, moving up in difficulty.

Mistakes in Crate Crash 2

So far, with over 150,000 plays of Crate Crash 2, from the comments on the game, I think my biggest mistake was not including a click limit in the levels. The levels of Crate Crash 2 revolve around the fact that it’s almost a sandbox environment. Because I didn’t limit the clicks, it immediately took the challenge away, and turned the game into a leisure activity rather than a challenge. I left the click limit out of the game because I thought it would keep people from disliking the game, but I think the fact that I left it out was the reason that people didn’t like it as much. If I had spent the extra week testing the game and recording click amounts on the levels it could have been a much better game.

The Future of Crate Crash

In the next iteration of Crate Crash, I want to:

  • Have different play modes –> Casual (No limits), and Normal (Limited clicks)
  • Bring back the bonus levels
  • Create a more intuitive level editor
  • More obstacles and shapes!

I would also LOVE to get the game on a mobile platform! I’ve been thinking of porting it to android and iOS. If I were to do that, I will definitely include the above changes.

I am also planning on releasing a Crate Crash 2 Players Pack that includes all the custom levels that everyone has made for the game, but that might be far away. I haven’t received nearly enough levels to make a players pack, but soon, I hope ;)

 

Tom

Easy C# Custom XML Serialization

0

Posted by Thomas | Posted in Tutorials | Posted on March 22, 2013

Hi everyone,

In the past, I spent time working with XML serialization for Grey: The Lost Technology, and I ended up writing a blog post about my findings and experience with “compressing” data to create smaller xml files, which is seen here: Grey Dev Diary: Problems of Storing Maps.

Now I want to show you a specific method that I use when writing a custom serializer for an object that needs special processing during (de)serialization. First, you would implement the ISerializable interface, and you would need to implement the following functions:

public System.Xml.Schema.XmlSchema GetSchema()
{
    return null;
}

public void ReadXml(XmlReader reader)
{
}

public void WriteXml(XmlWriter writer)
{
}

For me, reading the XML had always been the hardest part, until I came up with this:

public void ReadXml(XmlReader reader)
{
    while (reader.Read())
    {
        if (reader.IsStartElement())
        {
            switch (reader.Name)
            {
                case "Name":
                    Name = reader.ReadElementContentAsString();
                    break;
                case "ValueA" :
                    ValueA = reader.ReadElementContentAsInt();
                    break;
                case "ValueB" :
                    ValueB = reader.ReadElementContentAsInt();
                    break;
                case "DeeperObject":
                    //If object has more information and is its own class, deserialize that one.
                    reader.ReadStartElement();
                    DeepObjectInstance = (ObjectTypeClass)new XmlSerializer(typeof(ObjectTypeClass)).Deserialize(reader);
                    reader.ReadEndElement();
                    break;
                default:
                    //Do something if no case for the start element
                    break;
            }
        }
    }

    //Any sort of post processing
}

The main idea is that you loop through the start element of each entry, and then if you have a case for it, read the values. It’s super simple, and if you need to scale the object you’ve been serializing you won’t break anything.

Writing the XML is just as simple, but you don’t need to loop through anything to do it.

public void WriteXml(XmlWriter writer)
{
    writer.WriteElementString("Name", Name);
    writer.WriteElementString("ValueA", ValueA.ToString());
    writer.WriteElementString("ValueB", ValueB.ToString());

    //Don't forget you can call the WriteXML of another object and serialize it in the
    //same file as the one you're already writing to. It just means more processing later.
    //OtherObject.WriteXml(ref writer);

    writer.WriteStartElement("DeepObject");
    new XmlSerializer(DeeperObjectInstance.GetType()).Serialize(writer, DeeperObjectInstance);
    writer.WriteEndElement();
}

That’s all I have for you! If you have any questions, don’t hesitate to comment!

Dynamic 2D Navigation Mesh Generation using Medial Axis and Voronoi Regions

0

Posted by Thomas | Posted in Experiments | Posted on December 11, 2012

Hi all,

2D navigation mesh generation is something that I’ve been playing with for some time now. To be completely honest, I don’t even know if there are nice, affordable options that you can get online. I know that they exist in 3d, but, through my minimal searching I haven’t found one for 2D games. First and foremost, what is a Navigation Mesh? A navigation mesh is usually a 3D mesh object that defines traversable space in a game. This is where the problem occurs for us in 2D. 3D objects don’t exist in 2 dimensions. So, to combat this issue, the game designer can generate a map of connected waypoints, thus creating a navigation graph. Where the real trick is, is creating a “navigation mesh” for dynamic 2D environments. In my youth I was fascinated by the AI in Lionhead’s Black and White.

Lionhead's Black and White 2

In Black and White you play as a “god”, and you are overseeing a world below you, answering prayers, and helping townsfolk. I would watch the people in these little towns walk around and go where their AI tells them to. What I found was most interesting was when I were to drop rocks, or build a house in front of them, they would know exactly how to get around it and continue with their daily lives. With this, I set off trying to create my own implementation of it.

Read the rest of this entry »

C++ Library Wrapping Weather.gov REST API

0

Posted by Thomas | Posted in Tutorials | Posted on December 10, 2012

I’ve began creating a library that wraps the REST API offered by weather.gov. It’s not much right now, you can only input a latitude and longitude to get the highs and lows for the next 7 days, but it’s pretty neat nonetheless, and I had a pretty good time trying to get everything to work the way that I wanted it to.

Information

Why create a library for this? TO LEARN! I wanted to learn how to make a library in C++, and learn how to use the CURL library in C++, and then take these libraries and use them in a project. I don’t have a real project to use them in for now, but eventually I will use it, and add more to it.

Pro-Tips for C++ Libraries

In Visual Studio, you’ll see that there is a template for creating a Class Library in C++. This is for creating a library that uses managed code that is compiled with CLR (Common Language Runtime). This is not what you want. It’s a pain to get this set up if you plan on solely using C++ for your library. The best way to do it is to create an empty project then go from there.

Quick Tutorial:

First, create a new Empty Project, call it TestApp. Now, in the same solution, create a new project, and make it an Empty Project, this will be our library. You can call it TestDLL. The next thing we are going to do is create some classes to use in our library. Add in a header file called TestAPI.h. We will not be adding in any C++ Source Files (.cpp) because it creates issues in the namespacing. We are going to start it off really simple:

#pragma once //sorry, windows only. Too lazy to make ifndef

namespace TestAPI
{
	class Mathematics
	{
	public:

		Mathematics() {}

		int Multiply( int num1, int num2 )
		{
			return num1 * num2;
		}

	};
}

That’s all you need as far as code for the library. Now we are going to configure our TestApp project to use our library:

 

Resolve some dependencies

Add a reference to the TestDLL Library

Now, after that, you should be able to just reference your Mathematics class really easily. Now lets create the main function for our TestApp project that’s going to use our library. Go ahead and create a C++ Source File called main.cpp, and add the following code:

#include <iostream>
#include "TestAPI.h"

using namespace std;

int main()
{
	TestAPI::Mathematics math;
	int result = math.Multiply(3, 5);

	cout << "Results: " << result << endl;
	// Results: 15

	return 0;
}

That’s it!

Problems

In my implementation of the Weather REST API, I found that when I tried to use libcurl in my project, I had to include it in both my TestApp and my TestDLL. Other than that, everything went smoothly.

 

Download: C++ Weather REST API Wrapper

C++ Event System using Delegates

0

Posted by Thomas | Posted in News, Snippets, Tutorials | Posted on April 21, 2012

Recently I’ve been working on an Event System in C++. You might be reading that right now and wonder why that small sentence makes it sound like a true endeavor. Well, it was. As many of you may know I’m a student at Champlain College, and in one of my classes, each of the students are tasked to use an event system or a messaging system in their game. The teacher provided us with one, and it’s really great and all, but I couldn’t help but feeling restricted, especially after having used C# for so long where the code is so forgiving, and easy.

I did some research and it turns out that a lot of event systems in C++ are organized in such a way that when you want to do events you must:

  • Create an EventManager class (nothing wrong with this)
  • Create an EventListener class (for setting up events)
  • Create and Event base class
  • Be restricted to use only one function to handle your events
  • Create a huge enum holding a key for each of your events (Can hash it for speed)

I saw those and my heart dropped. I immediately thought that is way to restrictive, there must be an easier way to get events to work. And so the researching began.

Read the rest of this entry »

Understanding C# 2D XNA HLSL – Part 2

0

Posted by Thomas | Posted in Tutorials, XNA | Posted on February 22, 2012

Read the first part here

I know a lot of you loved the first part of this breakdown, and now I’m back to continue the explaining!

Breakdown of Effect Parameter

Continuing from the end of the first part: What the effect parameter does here is that it takes our effect and then applies it to all of the textures that you draw then on. This is effective for coloration effects such as black and white, or inverting colors, but if you have an effect that works based on certain coordinates or is constricted similarly, then you need to beĀ  very careful! To avoid issues like that, there is a rather simple solution when you want to apply an aforementioned size/position constricted effect to the screen.

Further Implementation

Adjusting the Effect parameter of the SpriteBatch.Begin() function is not the only way to use HLSL effects in your projects. Another method that you can do is draw all of your textures to one RenderTarget2D (Think of this as an empty texture, or a blank canvas). After you’ve drawn all your textures to that, it’s really easy to apply your effect to “the screen”.

RenderTarget2D MainTexture;

//In the Initialize function set up the rendertarget:
PresentationParameters pp = GraphicsDevice.PresentationParameters;
MainTexture = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight);

        //Then create a function to draw your game textures to, and draw it all up       

        private void DrawGame(GameTime gameTime)
        {
            GraphicsDevice.SetRenderTarget(MainTexture);
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            spriteBatch.Draw(bg, GraphicsDevice.Viewport.Bounds, Color.White);
            spriteBatch.Draw(player, new Vector2(200, 300), new Rectangle(0, 0, 128, 128), Color.White);

            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            DrawGame(gameTime);

            GraphicsDevice.Clear(Color.Black);

            // Use Immediate mode and our effect to draw the scene again, using our pixel shader.
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            mainEffect.CurrentTechnique.Passes[0].Apply(); // for every pass that you have you can apply
                                                           // all them to the texture if you want.
            spriteBatch.Draw(MainTexture, Vector2.Zero, Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }

Alternatively, you can use the effect parameter in the spriteBatch.Begin() function when drawing MainTexture, because remember: The effect is applied to the texture in every Draw() function call. If you only have to draw one texture and want all the passes applied when drawn, then you can use the Effect parameter.

Why do this?

In a project I was working on I really wanted to have an INFINITE amount of 2D lights in my game, and after countless attempts at getting a high number lights (higher than 5) from all HLSL effects, I found that by drawing a my lights to a texture, and then my game to another, I could then use an HLSL effect to blend my lights together.

 

I hope this helped.

-Tom

Using Git with a Subversion Repository

0

Posted by Thomas | Posted in Tutorials | Posted on January 30, 2012

Using git bash with a subversion repository is very easy when you know how to use it!

First, you’ll want to head over to the Git Website and get the latest release of the git application (we’ll be using git bash)

NOTE: when you install, consider checking “Git Bash Here” as a context menu option:

After it’s installed, go ahead and open git bash and cd to a directory where you want to download the repo to, or if you chose to install that context menu option, navigate to your folder in explorer (or finder) and right click on it then “Git Bash here”.

After that go ahead and run the “git svn clone” command on your repo, example:

git svn clone https://svn.webhost.com/svn/sp12egp31001

Alternatively, you can clone a subdirectory of the svn repository by simply writing the directory name at the end of the repo address. This is particularly useful when you’re working on a large project and don’t want to download all the files on the server.

git svn clone https://svn.webhost.com/svn/sp12egp31001/subdirectory

After you run the command you’ll be prompted for authentication, go ahead and fill that out and your repository will be downloaded onto your machine.

From there you’ll be able to modify the code, or whatever it is as you would regularly, then when you are ready to push changes back to the server, all you have to do is add these changes, and get them ready for commiting.

To start, go ahead and run this command:

git status

That should list out all the files you’ve modified, added, or deleted.

To track these changes run the add command:

git add .

The “.” at the signifies that you would like to track all the changes that were made. Another thing to note is that if you deleted a lot of files you would want to run the add command with another optional parameter:

git add -u .

This should track all the changes made, regardless of deleted, added, or changed.

Once you are satisfied you will need to make a commit to your local git repository by running the git command:

git commit -m "Your message goes here!"

Something to note about the commit command: You don’t have to use the -m parameter, it’s just that it’s much easier to do this, rather than being taken to a command line text editor to write a message.

Once you’ve commited your changes to your local git repository, you’re ready to push them to online subversion repository!

When pushing your git changes back to the online repository, you’ll want to run the subversion rebase command. What this command does is download all the changed files from the repository. You won’t be able to add your changes to the online repository if you don’t do this:

git svn rebase

After you’ve run that command, the only thing left is to commit those changes to your online svn repository:

git svn dcommit

And, that’s it! You’ve successfully learned to use the git bash with a subversion repository!

One more thing to note if you work on multiple machines. If you’ve cloned your repository on multiple machines you’ll need to run the rebase command:

git svn rebase

to download any changes from the server that you’ve commited from your other machine BEFORE you start working on your code on your current machine.

 

Now you’re ready to get working with git on your subversion repositories!

Minecraft-Style Engine in XNA 4.0

0

Posted by Thomas | Posted in XNA | Posted on January 15, 2012

Hey gang,

So lately I’ve been messing around with creating a minecraft-styled engine in XNA 4.0. Currently I think it’s going really well. Check it out and let me know what you think:

One of the most important things about this project for me is optimization. What’s great about minecraft is that there are so many things on the screen and there is virtually no lag at all. This isn’t just about me making a minecraft clone, I really want to become better at working in large environments, and allowing them to run as fast as they can!

Understanding C# 2D XNA HLSL

3

Posted by Thomas | Posted in XNA | Posted on November 26, 2011

Introduction

Firstly, what is HLSL? What can we use it for? HLSL is an acronym for High-Level Shader Language, and because it is a shader language, it runs on the GPU of the computer. With HLSL you can perform many post-processing effects, such as: blur, point lights, black and white, bloom, and pretty much any filter you can think of that can be done in Adobe Photoshop.

When working with HLSL on the Xbox 360, you are limited to using Pixel Shader 2.0 (This way you can support all Xbox’s) rather than 3.0, which isn’t terribly bad, but it could be so much better. You can do a lot with pixel shader 2.0 with up to 64 mathematical operations per-pixel. Because it is a pixel shader, the code that you write will be executed on every single pixel that is on the texture you’re working with. If your game resolution is 720×360, totalling to 259200 pixels, and if you have 3 mathematical operations per pixel (for example you are using sin, cos, and +), totalling to 777600 mathematical operations done for every time this shader code is ran (typically the total amount of times you draw the effect to the screen).

 

Examples

Nearly any filter that can be done in photoshop can be done with a shader. So, check out an example (more to come):

Radial Blur Example

fig. 1.0: Radial Blur

Read the rest of this entry »

Crate Crash 2 and More

0

Posted by Thomas | Posted in Flash | Posted on May 26, 2011

Hey,

It’s been a pretty long time since I last updated. I’ve been up to a few things lately. One of the biggest things I want to address is the development of Crate Crash 2. A few of you know of the first Crate Crash game, but for those of you who don’t, you can play it here: Crate Crash at TopPhysicsGames.com. The first Crate Crash game is all about clicking the game screen to apply impulses or little explosions that launch the crates. The goal of the game was to get the crates off of the screen, and this goal is still pertinent in the second game, BUT there are more crazy levels, obstacles, and challenges to get through.

The biggest issue that I noticed that people were having was that the game was way too damn hard. Now that I go back and play it again, I think it’s too hard. What I’m going to do with CC2 is create different difficulties. By default users will be playing on casual mode which will allow you to just play the game with no limits of restrictions (that means no medals on the levels, and no click limit). I’ve found having a sandbox-type mode allows the user to have a more enjoyable experience, I know that for a fact because sometimes in developing the game I get distracted just messing with the physics.

Another change from the original is that there will be less levels. It isn’t completely final how many levels there will be, but right now I have a 45 level cap. It could increase, but I don’t think it will.

The biggest feature of Crate Crash 2 will be the level editor. Users these days like to create their own content, and with the level editor that I’ve made, creating your own content should be VERY easy. I’ve had a few ideas of how I wanted to share these levels and I have few ideas going on in my head.

In other news, I am developing my own arcade script, Custom Arcade Script (Pretty cool name, right?). After being in the arcade scene for nearly 2 years now, and having mild success, and looking at how the arcade business is being handled, I’m not 100% satisfied with the way that arcade scripts work today. I’ve tried a few arcade scripts, and none of them are particularly great. They all their ups and downs, but none of them are a one-stop solution. Custom Arcade Script looks to provide just that. CAS will encompass some of the newest and most reliable arcade-related code available. With its streamlined interface, and easy to use admin panel, I have no doubt that Custom Arcade Script will be a huge contender in the arcade script market when it’s released!

-Tom