Menu – Level Selection – C++ Base Data

enumstructure

I’m listening to you guys. You wanted some C++ tutorials so here we go.  I will do more C++ stuff later.

Next step with the project is to add level selection screen. I will create base data classes in C++.

Design

There will be three levels in the game which:

  • will have different difficulty,
  • will have different type of enemies,
  • take some time to complete,
  • level icon reference,
  • level background reference,

All of those will be visible in level selection screen (which I don’t have yet )  so I will create structure and enums inside C++ for later use.

“I can’t code!”

I have the same problem so don’t be afraid to install Visual Studio and try using C++. Why you should use C++? Main arguments for me:

  • Storing variables and declaring structures / enums in C++ is stable, you won’t get issues that can come when using Blueprints. Another thing is that your blueprints will load faster. I suggest to store variables / structures / enums inside C++ and I will work this way from Today.,
  • Placing math to C++ will increase your game performance,

And last one – most important: if you know how to blueprint you can learn C++ to create variables and math functions without a problem. It will be hard from start to understand UE4 macros but you should try.

How to Learn?

  1. This book can help you a lot,
  2. Read this wiki page,
  3. Learn basics of C++,
  4. Learn by watching Epics code! This is the way I’m using. If I want to create blueprint pure function I’m searching one that was created earlier by Epic and trying to copy it with my variables / references.
  5. Watch all Youtube “UE4 C++ Tutorial” especially from Epic.

Enabling C++ creation

If you want to use C++ in your project simply add blank code to project. It will ask you to download Visual Studio – just do the whole steps. Restart your computer and again add code to project. Then restart your editor.

addcode

Adding Enums

If you don’t know how to open Visual Studio use FILE -> OPEN VISUAL STUDIO from Editor.

Navigate your project .h file. I have named my project “ShooterTutorial” so it’s ShooterTutorial.h file.

shootertutorialh

You can add Enums in every class. I’m using project .h file because it sounds like it’s global.

To add new Enum type add these to your project .h file: (PasteBin)

Please read comments inside the code for explanation. Now if you compile your project you can create new Enums in Blueprints from LevelEnemyType and LevelDifficulty.

Adding Structures

Here’s great Tutorial about structures in c++. And here’s my code – just copy it after enums declarations. (PasteBin)

Please read the comments for explanation. After compiling you can create new variable of LevelData structure type! It’s so simple!

I would need to move ShooterTutorial blog to custom server to get the code highlights…for now please use PasteBin links.  Here you can find whole code for enums and structures.  Remember that my project name is ShooterTutorial – your will be different!

Creating ShooterTutorial takes a lot of my free time.
Buy Now Button
If you want you can help me out! I will use your donation to buy better assets packs and you will be added to Credits /Backers page as well.

Implementing game is taking time but writing about it is taking much more effort!

5 thoughts on “Menu – Level Selection – C++ Base Data

    • For Blueprints just create new Enum named EnemyTypes with: Robots, Humans, Aliens. Another Enum named LevelDifficulty with: Easy, Medium, Hand. And structure with:
      – EnemyType enum,
      – LevelDifficulty enum,
      – float hiScore,
      – float LevelTime,
      – object reference SequenceData,

  1. Pingback: Menu – Level Selection – UMG | Shooter Game Tutorial

  2. Pingback: Adding Level Time to HUD | Shooter Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.