Skip to content

StaffsUniGames/S2DPlatformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example Game

Loading the Project

Cick the Green Code button on the repository and then Download Zip

Then find the folder in downloads, and using 7-Zip, Unzip Here

Now, in the unzipped folder, open the S2DPlatformer.sln file

Today we will look at an example game built with the programming framework we use over the first 12 weeks of Fundamentals of Games and Graphical Systems Development module.

The game we will be looking at today has been built using Visual Studio 2022 and uses a variety of technologies which have been wrapped up into a helpful programming framework called S2D written in the industry standard language, C++.

The underlying technologies at work in this framework are OpenGL, OpenAL and freeglut. You find out more about these throughout the modules.

Visual Studio is a very complex piece of software with many features. You will learn about many of these throughout modules taught on the Games Technology degree programs.

Debug Menus and The Code Window.

Green Local Windows Debugger Button : Runs the Application.

Solution Explorer Window : Lists all of the files in the Solution.

Double Click a folder, then a file to open in the Code Window.

Try double clicking ‘PlatformerGame.cpp’!

The solution explorer contains all the files that comprise the project.

All the files that have the .h extension are called header files.

These describe the functionality that will be containing in the matching .cpp file. The .cpp files (C++ source files) implement what the header files say will be included.

You will learn a lot more about header and source files later within modules. Be careful not to delete any files from the solution as they are all necessary to compile and run the game!

Building and Debugging the Game

Choose ‘Local Windows Debugger' from the overlay. Play the game using the following controls:
WASD : Movement
Space : Jump

Code Window

This is the area you write your code. You’re currently looking at ‘PlatformerGame.cpp’ An important file of the Platformer Demo which controls the game logic.

Making Modifications

There are many aspects of this game which can be modified, in fact everything can be modified since you have access to the source code.

Open the ‘Enemy.cpp’ file. You should notice some Constant floating point values have been defined called ‘MaxWaitTime’ and ‘MoveSpeed’. You can see they've been given the decimal values 0.5f, and 64.0f

Change these values and see what effect this has on the enemies in level 2 and 3.

Modify a Level

The platformer demo provides code that can automatically load new levels from the text files.

The text files are named in numerical sequential order starting from zero E.g., 0.txt, 1.txt, 2.txt.

Look at level 0 by double clicking the text file. Examine the contents of this file that comprise the first level. It looks like the following:

Each level is a 20-character by 16-character grid.
Code is already in place to load each tile of the game world from the text file.
Each time the player reaches an exit, the next level is loaded from the text file and the game continues.

The supported characters that represent game tiles are:
Period (.) – represents blank space
X – Exit
G – collectable gem
Hyphen (-) – floating platform
A, B, C, D – represent different types of monsters
Tilde (~) – platform block
Colon (:) – Variety platform tile
1 – Player start position
Hash (#) – impassable block (floor)

Try mdifying 0.txt level map with the above characters.

Add a level

Right Click S2DPlatformer in the Solution Explorer and Add a New Item
Name this "3.txt" and it will create in the Solution Explorer.
You can click and drag this into the LevelMaps filter.

The text files are not compiled like code and are treated as external items.

Next open ‘PlatformerGame.cpp’ in Visual Studio from the Solution Explorer and locate the constant variable called NumberOfLevels near the top of the file. Change this value to 4 and you should now have a new 4th level.

You may notice your level doesn’t look quite right...can you work out what is wrong?

Challenge

By right clicking S2DPlatformer in the Solution Explorer, we can Open Folder in File Explorer Try and solve the problem with the 4th level

Alternatively, try changing the sprites loaded to customise the look of your game.

Summary

Congratulations!
You have completed an introduction to game programming using S2D, built on OpenGL and OpenAL.
Having completed the exercises, you will have experienced first-hand games programming using C++. This tutorial has only begun to touch on the potential of Games Programming. A lot of work and expertise goes from starting with something like this, into the next GTA game!

You will get the opportunity to build new games in a variety of frameworks on this course.

Have fun, happy coding

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published