Retro Review: Death Rally

Click here to read Retro Review: Death Rally

Death Rally is one of those games that appears to be simple, until you realize you have played it for hours. It is a racing game with a top down view and cars equipped with weapons used to destroy other racers. The player earns money for each completed race, and the more difficult the race is, more money the player gets. This way, an easy race pays a lot less than a hard race, although is difficult to survive til the end of a hard race with the first available cars. The game has also a global difficulty setting, if you feel it is too easy or too difficult. Money earned from the races can be used to fix your vehicle or upgrade it with engines, tires and better armor, or even buy a new car.

Continue reading: “Retro Review: Death Rally”

Unity3D: JavaScript vs. C# – Part 1

Click here to read Unity3D: JavaScript vs. C# – Part 1

This is the first post of a series that will discuss some differences between JavaScript and C# when programming for Unity3D game engine. A project with all the scripts used in these posts will be available for download in the last post of the series. So let’s start from the start and see some of the main differences between the two languages.

The first and most easily distinguishable is the notation used to declare variables and methods. When programming in JavaScript, it isn’t necessary to declare the variable or method type whether in C#, it’s a must. That is because JavaScript is a weakly typed language, meaning that the interpreter chooses the best type to use at compilation-time. C# is a totally different because it is strongly typed, so, the type has to be declared before a variable or method. Let’s see some examples to better grasp this concept. The following script is a JavaScript example: Continue reading: “Unity3D: JavaScript vs. C# – Part 1”

Android OpenGL: Texture from Canvas

Click here to read Android OpenGL: Texture from Canvas

Another post about Android programming, although this time, it’s going to incorporate some OpenGL techniques. The code below shows how to draw a Canvas into a Bitmap, and then, load it as a OpenGL texture object. This means that it is possible to use all Canvas methods to draw into a texture, like drawCircle(), drawPoints() or drawText(). This is useful to render text to a texture and to dynamically generate textures.

So here’s the code: Continue reading: “Android OpenGL: Texture from Canvas”

How to get Android local files URI

Click here to read How to get Android local files URI

When programming applications for Android that requires the playback of audio or video files, sometimes, there’s the need to obtain the URI of those media files instead of using a String for the absolute path. But what is a URI? A URI (Uniform Resource Identifier) is an address to an local or internet resource. It’s more like a standardized path syntax that allows pointing to a specific resource that’s available over the internet, however we are going to use it to point it to a local resource.

A URI is specially useful, when using the VideoView class to load a video located on the res folder or in the SD card. Passing the video file to the VideoView as a String won’t even work on an emulated Android device. This way, we need to get the URI of the file.

Continue reading: “How to get Android local files URI”

Extra life after a certain amount of points

Click here to read Extra life after a certain amount of points

Finally, a post directly related to game programming! I will explain how to write a piece of code responsible for giving an extra life to the player’s character after a certain amount of points. TheĀ  following code was written in Java, because it’s it would be shorter and easier to explain. Since this a generic algorithm, let’s assume that the game logic runs inside a method called Update() that is a member of the GameLogic class, responsible for our hypothetical game logic. Additionally, we need to have in mind that this method is being constantly called inside the game loop.

So here’s the code: Continue reading: “Extra life after a certain amount of points”