Archive for the ‘Programming’ Category
Unity3D: JavaScript vs. C# – Part 1
Posted by Dimitri | Filed under Featured, Programming
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
Posted by Dimitri | Filed under Programming
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
Posted by Dimitri | Filed under Programming
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
Posted by Dimitri | Filed under Featured, Programming
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”
Installing APK Files on Android Emulator
Posted by Dimitri | Filed under Programming
Not exactly code, but it’s programming related. Chances are, you already found a bunch of pages describing the process of installing a APK file on Android Emulator using the command line. Surely, it is the safest and most recommend method, but why go through all the trouble if you want to run the application just once or twice? If you are a Eclipse user, there is a easier way, that will be explained here.
First, choose a device you wish to start emulation from the AVD Manger.
Continue reading: “Installing APK Files on Android Emulator”