Archive for the ‘Programming’ Category

Game Programming Basics: Creating a FPS counter

Click here to read Game Programming Basics: Creating a FPS counter

Sometimes, while creating a game, a programmer realizes that he/she needs to make sure if some part of the code is running fast enough, before adding more things that could cause the game to slowdown. To properly measure a game’s performance, there is the need to program a FPS (frames per second) counter. As the name suggests, it will count the number of frames that where rendered at the period of one second.

This is an essential information when creating games, as it will serve as a strong indicator to measure the performance impact of a recently added element to the game.

Continue reading: “Game Programming Basics: Creating a FPS counter”

Android: Loading and playing videos from different sources

Click here to read Android: Loading and playing videos from different sources

This is the 41st post on the website! It explains how to load images from a variety of locations, such as the ‘Resources’ folder, the SD card and from a remote server. As usual, the source code is available for download at the end of the post.

Let’s start with the basics: video formats. At the time this is being written, Android supports .3gp and .mp4 video files encoded as H.263,H.264 and MPEG-4 SP file formats. For an updated list, visit this link.

Continue reading: “Android: Loading and playing videos from different sources”

Unity3D: Programming a machine gun – Part 2

Click here to read Unity3D: Programming a machine gun – Part 2

This is the second and last post of this series that explains how to code a machine gun in Unity3D. The first post explained how to make the automatic firing mechanism, and this one will focus on how to set-up the machine gun, the bullet and explain the code that makes it all work. Also, a Unity3D project with all the source code discussed on the series is available for download at the end of the post.

So, let’s start by setting the machine gun. The 3D model of the gun can be any one, you don’t even have to create a 3D model at all, it is possible to use Unity3D’s cubes and other primitives. The only thing that one must know is that the muzzle of the gun must be a completely separate element. This is crucial when making the gun at an external 3D modeling application such as 3D Studio Max, Blender or XSI. Continue reading: “Unity3D: Programming a machine gun – Part 2”

Unity3D: Programming a machine gun – Part 1

Click here to read Unity3D: Programming a machine gun – Part 1

This is the first of two posts that will explain how to program a machine gun at the Unity3D game engine. This post will focus on coding the element that defines a weapon of this type: continuous automatic firing. It will show two different ways to achieve this behavior: one based on the Invoke() method call, and the other based on Unity3D’s coroutines. As any other post series in this website, a Unity3D project with all the source code will be available at the last post of the series.

All code in this post will be in C#, but for those who don’t use it, a JavaScript version of the code will be available for download at the end of the post.

Continue reading: “Unity3D: Programming a machine gun – Part 1”

Android: Creating a button to load images from a remote server

Click here to read Android: Creating a button to load images from a remote server

This is a follow up to the post published two days ago that explained how to load images into a View’s Canvas from different sources. Differently from the last post, I will explain how to load images from a remote server after the View has been loaded and rendered on the screen. Also, this post features how to download an image after pressing a button.

So, let’s get to it. The first thing the reader might be thinking is that we just need to create a button and place the code that downloads the image inside it. It’s not as simple as that, due to these problems: Continue reading: “Android: Creating a button to load images from a remote server”