• ### Remove ads and support GameDev.net for only $3. Learn more: The New GDNet+: No Ads! • # Learning How to write a 2D UFO game using the Orx Portable Game Engine - Part 1 General and Gameplay Programming # Overview Welcome to the 2D UFO game guide using the Orx Portable Game Engine. My aim for this tutorial is to take you through all the steps to build a UFO game from scratch. The aim of our game is to allow the player to control a UFO by applying physical forces to move it around. The player must collect pickups to increase their score to win. I should openly acknowledge that this series is cheekily inspired by the 2D UFO tutorial written for Unity. It makes an excellent comparison of the approaches between Orx and Unity. It is also a perfect way to highlight one of the major parts that makes Orx unique among other game engines, its Data Driven Configuration System. You'll get very familiar with this system very soon. It's at the very heart of just about every game written using Orx. If you are very new to game development, don't worry. We'll take it nice and slow and try to explain everything in very simple terms. The only knowledge you will need is some simple C++. I'd like say a huge thank you to FullyBugged for providing the graphics for this series of articles. # What are we making? Visit the video below to see the look and gameplay of the final game: # Getting Orx The latest up to date version of Orx can be cloned from github and set up with: git clone https://github.com/orx/orx.git  Once cloning has completed, the setup script in the root of the files will start automatically for you. This script creates an$ORX environment variable for your system. The variable will point to the code subfolder where you cloned Orx.

Why? I'll get to the in a moment, but it'll make your life easier.

The setup script also creates several projects for various IDEs and operating system: Visual Studio, Codelite, Code::Blocks, and gmake. You can pick one of these projects to build the Orx library.

# Building the Orx Library

While the Orx headers are provided, you need to compile the Orx library so that your own games can link to it. Because the setup script has already created a suitable a project for you (using premake), you can simply open one for your chosen OS/IDE and compile the Orx library yourself.

There are three configurations to compile: Debug, Profile and Release. You will need to compile all three.

For more details on compiling the Orx lbrary at: http://orx-project.org/wiki/en/tutorials/cloning_orx_from_github at the Orx learning wiki.

# The $ORX Environment Variable I promised I would explain what this is for. Once you have compiled all three orx library files, you will find them in the code/lib/dynamic folder: • orx.dll • orxd.dll • orxp.dll Also, link libraries will be available in the same folder: • orx.lib • orxd.lib • orxp.lib When it comes time to create our own game project, we would normally be forced to copy these library files and includes into every project. A better way is to have our projects point to the libraries and includes located at the folder that the$ORX environment variable points to (for example: C:\Dev\orx\code).

This means that your projects will always know where to find the Orx library. And should you ever clone and re-compile a new version of Orx, your game projects can make immediate use of the newer version.

# Setting up a 2D UFO Project

Now the you have the Orx libraries cloned and compiled, you will need a blank project for your game. Supported options are: Visual Studio, CodeLite, Code::Blocks, XCode or gmake, depending on your operating system.

Once you have a game project, you can use it to work through the steps in this tutorial.

Orx provides a very nice system for auto creating game projects for you. In the root of the Orx repo, you will find either the init.bat (for Windows) or init.sh (Mac/Linux) command.

Create a project for our 2D game from the command line in the Orx folder and running:

init c:\temp\ufo

or

init.sh ~/ufo

##### Share on other sites
8 hours ago, trsh said:

..\..\..\lib;$(ORX)\lib\dynamic; doesn't exsist. Some some steps setting up new project are missing. Hi Trsh, thanks for reporting. Under "Getting Orx" there is a part that mentions that git close auto-setup creates a project so that Orx can be used in your own projects. On reflection it's not 100% clear that you need to compile the projects. But I did include the link on compiling which takes you to the Orx wiki. Let me know if that doesn't solve the issue. However, once the orx libraries (debug, profile and release) are all compiled, the "dynamic" folder should then exist. Also check that after git clone step (the post setup step) managed to create an$ORX variable in your environment variables.

##### Share on other sites
On 3/15/2018 at 11:45 PM, trsh said:

..\..\..\lib;\$(ORX)\lib\dynamic; doesn't exsist. Some some steps setting up new project are missing.

I recently made the building of the Orx lib instructions more clear. Should be less of a barrier for new comers.

## Create an account

Register a new account

• 14
• 9
• 10
• 12
• 17
• ### Similar Content

• Hello there! I'd like to show you my new game - Hurry Birdie. It's an endless game where you have to dodge tree brunches and stones falling from above. Your birdie flies from side to side and speeds up when you press the screen.

Features:   * Nice design; * You can unlock new birdies; * Easy to play; * Leaderboard; * Good timekiller.   Download here: iOS: https://itunes.apple.com/app/id1434970622?mt=8 Android: https://play.google.com/store/apps/details?id=com.abdullakh.hurrybirdie

• Hello!
I'm trying to understand how to load models with Assimp. Well learning how to use this library isn't that hard, the thing is how to use the data. From what I understand so far, each model consists of several meshes which you can render individually in order to get the final result (the model). Also from what assimp says:
One mesh uses only a single material everywhere - if parts of the model use a different material, this part is moved to a separate mesh at the same node The only thing that confuses me is how to create the shader that will use these data to draw a mesh. Lets say I have all the information about a mesh like this:
class Meshe { std::vector<Texture> diffuse_textures; std::vector<Texture> specular_textures; std::vector<Vertex> vertices; std::vector<unsigned int> indices; } And lets make the simplest shaders:

#version 330 core layout(location = 0) in vec3 aPos; layout(location = 1) in vec3 aNormal; layout(location = 2) in vec2 aTexCoord; uniform vec3 model; uniform vec3 view; uniform vec3 projection; out vec2 TextureCoordinate; out vec3 Normals; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TextureCoordinate = aTexCoord Normals = normalize(mat3(transpose(inverse(model))) * aNormal); } Fragment Shader:
#version 330 core out vec4 Output; in vec2 TextureCoordinate; in vec3 Normals; uniform sampler2D diffuse; uniform sampler2D specular; void main() { Output = texture(diffuse, TextureCoordinate); }
Will this work? I mean, assimp says that each mesh has only one material that covers it, but that material how many diffuse and specular textures can it have? Does it makes sense for a material to have more than one diffuse or more that one specular textures?  If each material has only two textures, one for the diffuse and one for the specular then its easy, i'm using the specular texture on the lighting calculations and the diffuse on the actual output.
But what happens if the textures are more? How am i defining them on the fragment shader without knowing the actual number? Also how do i use them?
• By 999PING
I'm very often facing one small problem when trying to learn some new stuff - hard to choose what to learn next.
Even if the problem seems to be small it has a very huge impact on the final result I think. And because Game Programming offers so much to learn, I'm always feeling that I'm missing something important and wasting my time learning something not important or unneeded. Or usually, I'm afraid to focus on something specific and huge for a long time, because I think that I'll spend all my time on that particular filed and will not be able to solve another problem.

So I've tried to fit all my thoughts in this questions.
1) Are you trying to cover all the aspects of Game Programming? Or you trying to focus on some specific aspects like physics, animations, or networking etc.
2) What is your way to find a new theory or whatever else for your learning process? (Manuals, Courses, Books, Documentation? etc.)
3) When you trying to learn while practicing, are you search for learning because of a problem that appears, or because you wants to try new things? How do you choose this new thing? And finally, Which of this two approaches was the best for you if any?

Not actually in the scope of the topic, but I'm also very interested to hear your thoughts on this.
What is Game Programming for you? How would you describe what should Game Programmer able to solve?
• By Josheir
I'm having trouble with glew sharing some defines that I can't resolve.  Does anyone know of a way to get the following statements working instead of an include with glew (glew resolves the red squigglies too.)
glColor3f(0, 1, 0.); glRasterPos2i(10,10); I really want to use a quick glut command for now.  The command uses the statements above.
Thank You,
Josheir

• Hello everyone,
While I do have a B.S. in Game Development, I am currently unable to answer a very basic programming question. In the eyes of OpenGL, does it make any difference if the program uses integers or floats? More specifically, characters, models, and other items have coordinates. Right now, I am very tempted to use integers for the coordinates. The two reasons for this are accuracy and perhaps optimizing calculations. If multiplying two floats is more expensive in the eyes of the CPU, then this is a very powerful reason to not use floats to contain the positions, or vectors of game objects.
Please forgive me for my naivette, and not knowing the preferences of the GPU. I hope this thread becomes a way for us to learn how to program better as a community.

-Kevin