Posts Tagged ‘Algorithm’

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.

(more…)

Game Programming Basics: Moving an element

Click here to read Game Programming Basics: Moving an element

This post explains some of the most basic game programming techniques: how to move elements on the screen. If you already know this, please skip it, or add something to this post in the comments. Since these lines of codes are trivial to game programming, it may be one of the reasons why it is so hard to find a post or a website explaining them. The code presented on this post isn’t the only way to move objects in a game and certainly there is a lot more information out there. The intention of this post is to serve as a starting point.

(more…)

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: (more…)