Friday, 8 March 2013

Raspberry Pi and OpenGL

So it has been two weeks since my last blogpost, so much for keeping weekly updates. Couple of reasons why I have not kept up: First, I was working on my graduation which picked up some more steam. Previously I had been running experiments which gave me some off-time to work on other project. Secondly, I have been having some doubts about the project as to what I want to do with it. This keeps happening often with me; once the fun stuff is done I seem to lack motivation and most of all, purpose. I think I need to have better goals and a better time window/planning. Finally, not all time is wasted. I recently got my hands on a Raspberry Pi and was messing about with OpenGL ES on the PI. The OpenGL work that I have been doing is very interesting and is closely related to game development.

For those who do not know what a Raspberry Pi is, it's a small credit-card sized board that has a little ARM processer and a GPU which is powerful enough to render 1080p video. It has a HDMI out and all the basic inputs you need like USB and Ethernet. Since it hook up to a TV and can stream video it makes it ideal for configuring it as a media center. There is a XBMC distribution for the Pi, but to be honest I have tried XBMC and didn't quite like it so much. It has too many features (not really a problem, but this makes it more complex than needed), doesn't look all that good and has a counter-intuitive user interface. I simply want a wrapper around my file system so I can select what I want to watch. I already gave this a go before with PyGame and made a design for it, but this seemed to give poor performance because it didn't use the GPU. While fun at the time, it got shoved in the freezer because it was not usable.


Media center design
So, I have spend the last couple of week working on getting OpenGL working on the Pi and trying to see if I can get something presentable. This little project started when I came across a forum topic about OpenGL and the Pi. Somebody there made a github project which contained some of the work he had been doing with OpenGL ES. When messing around for a bit I noticed the code wasn't really all that readable and covered more than what I wanted to do with it. So I extracted what I needed and made it a bit more manageable for me. The result is a small 2D framework for rendering sprites; it can also do clipping masks and animation. I also made a texture loader which can run in the background for better performance. There are still some quirks where the texture data seems to be missing (render white), which is most likely due to a garbage collector or something which still needs to be looked into. Far from done, but overall I think I already have something workable.

video

At the moment of writing I can get around 40-60 FPS with quite a bit of background work (crawling file system and async texture loading). I think this isn't too bad, seeing I am using Python as a wrapper around the native code from the .so (lunix version of a dll) file. I have included a small video which shows the actual think I have now. Possibly I can extend this to run on the desktop and it might even use it to create games with it. If you are interested, send me a message (either on reddit, facebook or twitter)

Next week I hope to come up with a better plan on what I will be doing with the AGame. I have some ideas, but I need to work them out further, so until then.

Thursday, 21 February 2013

Lighting and teleports

Hey Internet, so here is my second update after a week worth of progress. I've done a couple of things. First of all I wanted to make some sort of lighting so you can see if you are in the shadows or not. I thought it would be really neat to do this with shaders and set out do so. So what I made was a shader that calculates the distance to each light source and takes the minimum. The effect was ok, but diamond shaped rather than square like the grid. You can see the effect in the Figure below.



Lighting with shaders
So I wasn't really pleased, since the performance seemed to be quite bad, however that it something attribute to my sloppy code. I have had no experience with shaders and while slow and not what I wanted, I did learn quite a bit. So next up I tried another solution: an overlay. This was quite a bit faster and a lot easier to make. I simply take the bounding box of a map and draw tiles with an alpha value based on the minimum distance to a light source. The result of this can be seen in the figure below.

Lighting with an overlay
Hmm, we now have it aligned with the grid of the tiles but the effect is not as pronounced as before. This was because with the shader we can acutely make things brighter than they are. Now we can only make them darker. However, too dark and you cannot see the player, so it's a bit more difficult to really get those layers. But this is good enough for now.

As you might have noticed, I'm on a map which is on the inside of a building. And you are correct. I made the option to load a new map when you hit a certain spot. That way you can move in and out of buildings and so forth. I call it a teleport, which is sort of a remnant of how it was called in RPGMaker and how I still think about it, and most of all, it describes what it does, right? So if you move to the door on the bottom (where the light is coming from) you 'teleport' outside to the original map.

Outside of the room, with global lighting
As you can see, it is light outside so we don't need to shadow layer. I can just set the maximum about of shadow per map in the editor (I added a slider). Speaking of the editor, in order to place lights and teleports, I extended the editor to support this too. You can now drag a square with the light tool to create light areas. Another is the teleport tool which, when used, lets you select a map file and position from it with a special pop-up window.

Lights tool
Teleport tool
So far my progress this week. Furthermore, I decided to make this a one-month project where I get as much stuff done in about a month. I think I sort of rushed into this idea without too much thought (as usual) and seeing things blow up a bit before I actually have a finished game. Nonetheless, I plan to make it at least playable. So what I will be adding is at least some gunplay where you can shoot some of the lights and maybe some NPCs. I was also thinking of implementing path finding using the A* algorithm for some basic NPC movement since this is something I will need at some point and it's a good learning point. But that is something for future blogposts. See you then, internet.

Wednesday, 13 February 2013

The beginning, the game (Part 2)

If you haven’t read the first part, I recommend doing so. It contains some background information about me. Or if you are just curious about what I’m making; Read on!

What I’m planning on making is a stealth game where being detected is usually punished. So the main features will be hiding in shadows and finding alternative routes to a target. To goal is infiltrate some area, assassinate a target and make a clean escape. You might picked up on it, but the main inspiration comes from Assassins Creed, but with more planning and less attack power. I really enjoyed to bits of gameplay where I carefully planned my attack by seeing patterns in guard behaviours and the schedule of my target. This is what I want to recreate on a much smaller scale. I want to give the player the ability to blend in with crowds to get a bit closer to the target and navigate terrain by sneaking around, either via air ducts, sewers, secrete passages or simply the roof. Furthermore, I was planning on different ways to eliminate targets. Simply close range with a dart or with poison. Maybe explosions under a room or sniping from a vista. In all cases, different tactics apply but one feature is present in all, stealth. In order to get close you need to either get rid of guards or not rouse any suspicion as to your motivations. When sniping, you need to scout for vantage points and see when to where to place and ideal shot. So with all this, I distilled a list of features that I think would realize this gameplay:
  • Stealth movement, so visibility with respect to how far away you are from a light source.
  • Stealth takedowns, so you can get rid of guards or your target.
  • Move bodies, so other guards don’t notice somebody is missing
  • Escalating AI, so when you mess up the AI will react more aggressive or stressed out
  • Shooting lights, remove a light source like in splinter cell
  • Simple shooting, very limited. Maybe pick-a-target-and-shoot simple. This also goes for snipers
  • Open terrain, so you pick how you get there. There should be multiple ways into a building. (Front door, roof, basement, air ducts)
You might think this is starting to become quite a big project, something I want to avoid. And I agree that this is becoming ambitious, I don’t want to make a simple platformer or puzzle game. As I said, I want to make something I like to play, which happens to be involve adventure and actions. However, I have a plan to make it a bit more manageable.

I am planning on making this in a 2D retro game like Chrono Trigger, Final Fantasy 6 or even the Pokemon games. This severely cuts back to work in assets and animation as well as how much work goes into actually moving about and such. Using a tile based environments will reduce complexity even further. ‘Lighting’ can be done by simply overlaying an alpha texture and ‘real’ light sources will be very few, which makes it easier to compute your visibility. So while it might not be the next Assassins Creed visally, I think this is just enough to get the gameplay across and still be fun to play.

So at the moment of writing I’m nearly 5 days in this project and already have some noteworthy progress. First, I decided upon using libGDX as a graphical framework to use, mainly because it also provides a nice 2D scene model which should eliminate some of the OpenGL headache when dealing with 2D graphics. libGDX also is a JAVA framework, which is what I have most experience with, which I can actually make a game with.

Secondly, I’ve started working on basic movement, collisions and sprite animation, which will be the basis upon I will make this game.

Thirdly, I’ve made some assets which, to me at least, look good enough to give a reflection of the mood of the game. I like to keep it dark tones at night, which will be my first prototype. Maybe I’ll add other stuff later on, but for now I will stick with this. Maybe when I progressed further I will redo these or even get somebody to do it. But that is something for later.

And finally, I have made a tile editor to create some maps. I know what you are thinking, “What about Tiled?”. I am aware that this is neat little map editor, but I have little experience with it and I want to make sure that the map editor can produce the data I need. One of the things I need is a collision map which also includes some notion of high, since I want to include basic jumping and climbing. While it might be possible with either special layers or plugins, I decided it was not worth the time to dive into this and was better spend making my own. On top of that, I had previous experience with making applications and even map editors (yay for failed projects). So after 2 days I had a decent map editor which suits my needs, including a low overhead map format for storing data.

So all in all, good bit of progress which I hope to keep up until the end of the week. Afterwards, it is back to work on my graduation and no longer have a vacation. Well that is it for me, I will have news soon and will keep you posted!

My self made tiles

The current editor, the green is the collision map

And the game using the map made in the editor

The beginning, the developer (Part 1)


Ehm, hey there. Welcome to my little game development blog. Here I will be documenting the development of a game I’m making and will hope to give some insight into the things that go into making this game.

So first, before I’ll explain what game I’m making, some information about me. I’m Yannick, age 24 and a student at the university of Eindhoven in the Netherlands. I’m currently in the process of wrapping up my graduation and will (hopefully) have my Master of Computer Science and Engineering degree by the end of March this year. I started making games in my early teens with a wonderful tool called RPGMaker 2000 and later with its successor RPGMaker 2003. This was my first experience with making games and it was my first encounter with game creating and especially scripting, which got rather good at to a point where I was replacing some of the build in systems with my own custom ones. But as knowledge grows, you seem to hit the limits of this tool. This became even more apparent when I started studying for my bachelors I acquired real programming skills and started to fiddle around with languages like Java, Action Script 3 (Flash/Flex) and Python. I would make small prototypes which were horribly slow and clunky, but these helped me progress. In the years I was messing around, I was usually starting projects and putting them away again, but I was learning some important things. First, make something you actually want to play; Breakout clones are not fun to make after a first time. And secondly, don’t make huge games (obvious right?). Too many projects (even with a team) failed because the intended end product was just to large of a scale. When the sparkle of a new project wears off, you still need to conquer this massive amount features and then the motivation begins to decline and eventually drops to zero. Which at that point the project is put on “hold” as most say, most of the time never picked up again.

However, when a project fails at least I learned something and each time I started I knew more than the last time and actually got further each time. So here I am again, stronger and better prepared than every other time and willing to see it through the end. So here is the plan, a small game with not to complicated art and a small set of features. I don’t want to spend too much time on the basis, I just want to make something playable.

Hmm, this is getting longer than expected. I’ll make two posts, so this can be archived better. Which means: The beginning, the game (Part 2).