Category Archives: Projects

Unity Sparks system

Everyone knows I love particles. And if you don’t then there’s something new to learn about someone every day.

But seeing as I like particles so much, I decided to try and see if I can get some nice realistic spark effects in Unity and succeeded after a couple of hours.

20131013213349

And because I’m nice, I’ll let you have the package:

DOWNLOAD THE UNITY PACKAGE FOR FREE BECAUSE I LOVE YOU

The way this was done was mostly trial and error and tweaking values in the particle system.

The way I did it was first create 2 GameObjects, 1 for the spark effect in the middle, and the other for the flying sparks.

Next, I added the particle emitter to the main spark one and stuck an additive particle material on it. I then set the particle emit rate to 60, the life time to something really low (the values are all in the unity package anyway) and a random rotation. Also to make it look better I added a size over lifetime so they sort of get bigger over 2 frames.

The second part was a cone shape emitter with a large emit rate, a bounce setting and the render type set to “Stretched billboard” so they all face the direction they go.

That’s the basics of it, but there’s a lot more to it like getting the gravity just right and the lifetime just right. These are all in the package but they will depend on your scene in the end so they will still need to be tweaked.

If you like, you could add smoke particles to a 3rd emitter to give it more of a burning effect. I actually recommend this, but smoke is another tutorial that I’m sure you can find somewhere else.

Anyway, I hope this helps someone out.

PS: you could use a “one shot” for both emitters and use it as bullets hitting a wall šŸ˜€

Amazing.

Improving usability

In the last few days I’ve decided to do a little bit of extra work on our first year project :”Filtrate”. This was due to me wanting to show something off at Open Day.

For this who don’t know, this is FIltrate:

2013-08-22 10_12_46

Rather, that is a screenshot from the current version.

Main game

Some of the things I updated on it were as follows:

  • Adjusted player movement. This was because the player jerked to left or right when pressing the arrow key. In theory, this was a good move to begin with because it meant the player moves in that direction instantly, but as we added better physics to the game it started to not work well. The reason for this is that when you hit an arrow key, it set the player speed in that direction instead of increasing the speed. This meant that you couldn’t do precision landings and also it caused the player to move unnatural when he moves in one direction and then changes direction.
  • Added a circle around the player that reveals what’s behind the player in other dimensions. This was extremely difficult and the end result was really good.The first attempt, I tried to use a white oval behind the player that was used as alpha on the background. This didn’t work mainly because I couldn’t figure out how to set up the blending very well and I moved onto another method.The second method I used was a single large image that was completely white but had hole in the center. This was then placed over the player and the blending functions were applied for the filters using this rather than a white square which is what it was before. This worked well and is how it’s used now. I then made the square change size randomly to make it seem like it was flickering, creating the effect that it’s stuff from another dimension.
  • Added a smokey effect in the dimension circle around player. This also turned out really good. The way I did it was also extremely hard. I’ve explained it all below.
  • Added more levels. This was a result of improving the level editor and just making levels as I tested it. Some weren’t saved, which is sad. But there are some easier levels at the start that introduces the player to the basics slower.

Smokey dimension effect

This is the effect in the game that allows you to see smokey effects on objects in other dimensions directly behind the player.

First, I calculate the red, green and blue filter colours. THese are eased based on what filter has been selected with a formula Ā cĀ += (0 – c) / delay for colours not selected, andĀ c += (255 – c) / delay for the current filter colour. This wasy the colours that are off blend down to 0 over time and the colour that’s active will blend up rto 255 over time. These are not actually applied to the filter, yet but are needed in the next step.

I then negate these colour values as the blending needs the opposite colour to “show” the actual filtered objects behind it (so to see red the blend needs to be 0, 255, 255, which is all colours BUT red).

I then set up the first spritebatch (XNA for the win) which uses an additive blend state. This is used to render the “Below” level (Everything that is filtered, eg. Not the player and start/end doors or HUD etc.) This draws in 2 modes: 1 draws ONLY the FILTERED dimensions that are NOT active. So if I have red filter activated, this will draw only the green and blue dimensions, but not the white dimension. The reason for this is explained later.

2013-08-22 10_59_20

The next step is to draw the smoke. The smoke effect is a tiled square of smoke (actually an inverted black and white water texture)
SwirlThis is applied using a “multiply” effect (darker areas are drawn more, lighter areas are more transparent). This causes the effect of dark smokey patches over the top of the underlying dimensions. I then made the UVs rotate upwards and positioned it relative to the camera.

2013-08-22 11_01_16The NEXT step was to render the rest of the level. The easiest part is to draw the neutral dimension. The other dimension (the blue one in this case) needs to be drawn at a percentage of how far along the transition is. Otherwise if we draw the dimensions “if others are off” they will switch instantly and we lose the fade effect on elements on the previous dimension.

2013-08-22 11_02_15As you can see from the screenshot, it is starting to make sense why I’ve done it this way. The neutral dimension doesn’t need to be drawn to have clouds applied because it’s ALWAYS on. Even though technically it’s still counted as being in that all coloured dimensions.

Next, we apply the “filter”, the main aspect of the game. This originally was a stretched plain white 255,255,255 texture, but as mentioned above, it’s been changed to a white square with a tiny hole in the center that reveals our other dimensions with smoke on them (and as you can see, the neutral dimension shines through).

2013-08-22 11_03_07Notice the green orb is smokey because it’s not part of the blue dimension but the player is standing over it.

Then, I apply a dark border just to add a gloomy atmosphere.
2013-08-22 11_04_39Then we draw the white objects (this has since been changed so it’s drawn under the gloomy border):

2013-08-22 11_05_49And finally the static effects, and the HUD:

2013-08-22 11_07_03Notice that the noise adds a negative effect to the level, which is nice.

Level editor

  • Added dynamic title bar – This is so you can see what level you have open, (or Untitled of none) and a * if you have unsaved changes,
  • Made save feature on close – Added an inturrupt on any close events that causes a “Save changes?” dialogue box to appear.
  • Multiple select items with shift – This was very difficult as object with change properties would change every object’s properties to the last selected item, so I had to add a check on every variable if it’s the same as it was and if not, it edits JUST that property. Worked well in the end.
  • Can create platforms dragging up and left now – previously, platforms could only be created by dragging from a point down and right. To fix this I did a check for if the final mouse positon’s x or y was lower than the starting mouse pointer’s x or y and if so, reversed the formula.
  • X Y Width Height in properties now NumericUpDown – Before this was a textbox which not only needed converting, but had to be edited to see changes. Now you can just click up or down on the arrowds on eahc box.
  • Made texture in properties a dropdown with default “” – I plan on implementing this properly for the sake of variation in levels. Levels will have customisable textures for help signs etc.
  • Removed corkscrew button /Ā removed goose button – These weren’t implemented
  • Added zoom function – Can zoom in and out by multiples of 8
  • Added shortcuts for menu items Ztrl+O opens etc.
  • Got Exit to work /Ā Got New to work – they obviously didn’t work. Exit also promps for save.
  • Added caution box for unsaved data – as mentioned above this was implemented by the close inturrupt. This was done with a simple variable that was set to ‘true” when something was deleted or added to the scene. And set to false when the level is actually saved. This state is used to add the * in the title bar.
  • Added check for locked files – If the level editor tries to save a file that is locked, it would crash. To stop this I added a function that used try / catch on the file stream.
  • Clicking nothing de-selects everything – I kept doing this to de-select items so I just implemented it by making use of the function “DeselectEverything” that had already been implemented.
  • Made 2 levels of grid lines – most of the levels I had made used 2 by 2 sections are they just looked nicer. I added a darker grid line for every second one to help with this sort of level style.
  • Made dimension and effect button selections more obvious – Before it was hard to see in the properties panel which button was pressed as they had little background or shading. Now they use bright colours.

2013-08-22 11_41_45

Game Jamming

This weekend we will be embarking on a journey into the jam… of games.

Stuart, Alex and I on a team against other teams of fellow AIE members at the AIE floor. The theme was announced at 7pm which ended up being…

Deception

20130527010626

(I know, that’s from “Inception” but screw you).

After much discussion and broken bones (I wasn’t there for that part)… we decided on a game idea. The idea is basically checkers but with ninjas. There will be 2 players, each with a single ninja. The ninja can move to any square in a 3×3 area around it, but the catch is that when the player does this he can choose to create a ghost ninja that the other player cannot detect (they just see a normal ninja).

We thought hard about how we would do this without networking and thought that the best thing to do would be to have the player choose between 4 different coloured ninjas and they select one by dragging it down onto the board in the position they want the ninja to move to. But I hear you say “But the other player will see this won’t they huh? huh?” Yeahsss… But to do this they can either left click or right click and then drag the ninja onto the board. depending on which of these you do, the ninja is either clones or moved. The reason we have colours is mainly so someone can actually remember which of THEIR ninja is the real one. (I know I’d forget).

We don’t have a name yet, but in the code we called it “Shadow Clone”.

So that’s the planning stage. Look around for more posts to continue the plot of the ninja.

Game Jam progress

Friday and Saturday Morning.

Which seemed like the same day, we had Alex pump out some pretty sweet looking grass, rocks and bamboo for the level textures. Then after a few hours we had a state machine going. The state machine was my handy work and I managed to get it to run everything from the game playing state, and calling the ChangeState function on the same state again reset the game. In the meantime, Stuart was working on the getting the player to move around and we were both deciding on some key concepts like how Z ordering would work.

Not really much to show at this stage of the jam; just core mechanics needed to build up from.

Day 2.

We have not had very much sleep. I got about 5 hours (accidentally. I was only going to have 3, but I felt awesome after it…) and when I got back to the room we were in, Stuart had pumped out the code to get the players moving in the squares which was wicked.

From there, Alex had done a nice looking Ninja. We were planning on animating the ninjas but only towards to end of the jam if we had time. Alex had also re-made the graphics to a new style and made a start on the HUD graphics.

I implemented a camera controller with smooth movements which looked really good. This was done by a Camera class with a normal position and a target position. The camera would ease into the X and Y of the target, getting slower the closer it got. This is my favourite formula in programming ever. We also got the graphics in and had the ninjas moving around which looked nice.

sdf

(This is still the old graphics)

At this point, the ninjas simply teleport to their position without any way of knowing what’s happening. So we planned on adding in an explosion which I made a start on in Flash. It turned out really well in the end after a few attempts. I tried to make the smoke pull inwards towards the centre of the cloud as it moved upwards. After that I added a purple tint to it so it looked like a ninja puff of smoke. I then exported it into a PNG sequence for importing into XNA.

Untitled-2

At this point, Stuart had left for a concert so I began implementing more smooth ninja movements and getting the camera to position its self on the players properly.

More updates to come!

Gameboys are awesome

So I’ll start my blog thing by talking about Gameboys.

I was playing Kirby’s Dreamland 2 on Gameboy and decided that the game is amazing and almost like a perfect game. Great tileset, story, sounds, music and really nice world. Because the main characters and art style were created in Kirby’s Dreamland (the first one) the art style suits the gameboy really well compared to other games like Donkey Kong which used bad looking 3D models converted into sprites. Kirby is basically just a circle with eyes and round legs: easy to draw.

So, I looked at the graphics and tried to figure out how the tile-set worked and what they probably did to draw everything. I then recorded the sound directly from the emulator and ha da look at it in Sound Forge. The sound and music is really interesting. The sounds in the gameboy seem to have the volume of the waveforms locked on to about 7 levels and whne there’s no volume at all, the soundwave is right at the bottom of the negative part of the waveform. So I assume this is because they preogrammed the waveforms so they would have an offset of -7 db or something and then from that, use a single 3 bit number to push the wave higher. This also means the DC offset is wrong and when the sound starts and ends, because the wave is pushed down to the negative when there’s 0 volume, there is that pop noise. I assume this is what caused the tiny pop sound when you turned a gameboy on when having headphones plugged in.

With the graphics, I magined that most of the tiles were flipped and rotated with algorithms. This would save memory and it got me excited because I do enjoy compression and low-level programming with pixels. It’s just so simple compared to these day’s graphics.

Then it got me thinking, would it be as hard to make a Gameboy game as it was to make a Sega Megadrive game? Could I make it work on an emulator or even a real Gameboy?

Apparently not hard.

I looked up a bunch of sites, most of which were made around the year 2000, so a lot of the links didn’t work.. but I managed to download a C compiler for the Gameboy that outputs a .gb file that you could put in an emulator and run! Awesome!

So I played around with this, trying to get Notepad++ to compile it and managed to do this with a .bat file that ran the compiler and some variables that get get parsed into it. I assigned a button in Notepad++ that would compile the code with the compiler and run the game in anĀ emulator.

This was awesome, but how do I do this in Vidsual Studio 2010?

No idea.

I managed to learn from teachers that I could set up Visual Studio to use Makefile settings and do it that way. Challenge accepted.