Tag Archives: gaming

Basic client/server communication in C++ using the RakNet networking engine

Quote: RakNet is a cross-platform C++ and C# game networking engine. It is designed to be a high performance, easy to integrate, and complete solution for games and other applications. The snippets below demonstrate basic client/server communication using the RakNet library.

Posted in C++ | Also tagged , , , , , , , , , , | Leave a comment

Minimax algorithm with alpha-beta pruning in C#

Minimax is an algorithm where two players (min and max) play against each other for minimizing loss and maximizing gain. The following picture illustrates minimax with a game of tic-tac-toe. The algorithm uses a tree for the moves and scores of each player. In some cases, it is unnecessary for the algorithm to check certain subtrees. [...]

Posted in C# | Also tagged , , , , , , , , , , , , , , , , | 1 Comment

Matrix multiplication in C++

Matrices can be used to perform transformations. For example, in 2D and 3D space. Transformations include, but are not limited to, rotating, scaling and translating. Transformations can be combined by multiplying the matrices with each other. For example, you might want to: scale an object with a factor of 2 rotate it 45 degrees around the [...]

Posted in C++ | Also tagged , , , , , , , , , , , , , | 2 Comments

Detecting keyboard input in XNA

Keyboard input is essential in most games. The user might use it for moving a character, mario style enemy killing and many other things. XNA supports so called keyboard states to detect keyboard input.

Posted in C# | Also tagged , , , , , , , , , | Leave a comment

Double buffering with a back buffer in VC++

A common problem when drawing with GDI in VC++ is that the screen might flicker when you’re doing a lot of drawing. This problem can be overcome by drawing on a so called back buffer. The back buffer is then drawn at once. I’ve created a Win32 project in VC++ to demonstrate this. The first [...]

Posted in C++ | Also tagged , , , , , , , , , , , | Leave a comment

Distance between 2D and 3D vectors in C++

This example extends the Vector2 and Vector3 classes from the 2D and 3D vector normalization and angle calculation in C++ example. The formulas for distance calculation in 2D and 3D are listed below.

Posted in C++ | Also tagged , , , , , , , | Leave a comment

2D and 3D vector normalization and angle calculation in C++

Normalizing a vector can derive the direction of the vector in 2D or 3D space. A normalized vector is also known as a unit vector. We’re going to normalize and calculate the angles of a 2D vector at position (5,5) and a 3D vector at position (5,5,5). This can come in very handy when, for [...]

Posted in C++ | Also tagged , , , , , , , , , , , , , , , , , , , , , , , | 2 Comments

Creating a robot in Java with Robocode

Robocode is a programming game where you get to build a robot to battle with other robots. It supports the Java programming language and the .NET framework. We will use the Java programming language in this example.

Posted in Java | Also tagged , , , , | Leave a comment