Building a First-Person Shooter Part 1.0: Creating a Room

Published August 13, 2013 by Chris Vossen, posted by ChrisVossen
Do you see issues with this article? Let us know.
Advertisement
This is the first lesson in a set of tutorials that demonstrate how to build a complete first-person shooter game, from start to finish. Download the files used in this lesson: FPSGame.zip

Getting Started

We're going to write this game in the programming language C++. C++ compiles to native code, which gives us the fastest possible performance on mobile devices. The object-oriented nature of C++ makes it great for games. We begin by creating a new C++ project. To open the project manager, select the File > Project Manager menu item. When it appears, press the Import button and select the zip file posted at the top of this lesson. (In older versions of Leadwerks, you will need to create a new project called "FPSGame" and then manually extract the zip file into this project's folder.)
If you do not have a copy of the Leadwerks engine, a free 30-day trial can be downloaded to use with this tutorial
ccs-1364-0-11791300-1367301963.png

Using Brushes to Sketch Out a Room

Since this tutorial is focused on the player class we are only going to sketch out a simple rectangular room for our player to run around in. Select the box primitive brush from either the Objects tab or the shortcut box brush icon located on the left toolbar. In the X/Z viewport sketch out a box that has a width and length of 16 and height of about 0.25. This will be the floor of our level. Create four more boxes to form the walls, and finally top it off with a ceiling. ccs-5181-0-94166300-1366929131_thumb.png

Room Materials

At this point our room should look like a very bland box, luckily it's time to spice things up and bring our room to life with materials. Left click on the asset browser and expand then select the Materials->Spaceship folder. Inside should be a group of textures and materials. Next drag and drop the "scificeilingb" material to the ceiling box in the 3D viewport, the changes should immediately appear. Scroll down in the asset browser to the "scififloorb" material and drag and drop it onto the floor box. Finally select the "scifiwall_basea2" material and drag it onto all four walls. ccs-5181-0-62180100-1366929250_thumb.png ccs-5181-0-45510600-1366929258_thumb.png ccs-5181-0-33356600-1366929267_thumb.png

UV Manipulations

When you take some time to look around the room, the first thing that jumps out at you is that the material pattern is repeating itself very often thus drawing too much attention to itself. To remedy this we are going to scale the materials texture. Start off by opening the objects tab on the right toolbar. Next we are going to change to selection mode to "Select Surface" Edit->Select Surface or alternatively click the "Select Surface" shortcut icon located second from the top on the left toolbar. In the 3D viewport left click on the floor of the room, then under the Texture Mapping section of the objects tab change both scale values to 4.0. After repeating the texture scaling on all four walls and the ceiling it will be time to move onto lights. ccs-5181-0-41660300-1366929118_thumb.png

Lights

Now that we have our room's materials set it is time to add some lights to the room. For this tutorial we are going to add in four point lights, these lights emit light in a radius similar to that of a traditional light bulb. On the left toolbar there is an icon showing a light bulb, this is the point light shortcut, left click on the icon. With the light bulb icon selected, left click anywhere in a 2D view port and press the Enter key and a point light will be added into the map. Create four of these to illuminate your room. ccs-5181-0-11531900-1366929322_thumb.png Now it's time to adjust the light ranges. Left click on the map tab and select the four point lights in the Scene Browser. Next left click on the "Light" tab and set the range value to 9.0. This will increase the radius of the light. ccs-5181-0-70419600-1366929337_thumb.png ccs-5181-0-75452100-1366929349_thumb.png Our final step is to create the map's lightmap, so that our lights take effect on static objects. In the top toolbar navigate to Tools->Calculate Lighting (or press ctrl+L), a Calculate Lighting window should pop up. Click Render and after the lighting is calculated close both windows and we are done adding lights. ccs-5181-0-14695200-1366929365_thumb.png ccs-5181-0-59571400-1366929376_thumb.png ccs-5181-0-47037100-1366929389_thumb.png The level is now complete, now it's time to create a player to run around in our room. Before moving on don't forget to save the map. Select the File > Save menu item and save the map as "start.map". ccs-1364-0-22322900-1366933402_thumb.jpg The next lesson will cover setting up Visual Studio so we can code some functionality into the level.
Cancel Save
0 Likes 2 Comments

Comments

Getov

Hello, nice tutorial there !

I've got a problem. When I did the "Lights" part, something went crazy and the room(box) went all gray and the textures are gone.

Any idea what could have messed up ?

May 10, 2013 06:17 AM
TyphoonEnt

Hello! I'm having trouble finding the rest of these threads. I was wondering if you might provide the links to the rest of them, thankyou!

May 13, 2015 02:56 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement