Posts Tagged ‘Programming’
Programming related posts.
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: (more…)
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.
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: (more…)
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.

Select a Android Virtual Device to start the emulator.
WordPress: get posts within the loop
Posted by Dimitri | Filed under Programming
This post will explain how to get posts at the WordPress loop, so you can place code (probably advertisement code) after a specific post (first, second, third) or at intervals (e.g.: every 3 posts).
Before starting, it is a good idea to create a backup copy of your theme’s index.php file, just in case anything goes wrong.
This is a five page post, so here is the page index:
- Get the first post
- Get the 2nd, 3rd or any other post
- Get odd/even posts
- Get post intervals
- Final considerations
Let’s begin by finding where to place the code. That’s why we need to find the WordPress Loop in the index.php file.