Random numbers are useful for a lot of reasons in games. Perhaps you could use them for determining what card the player is dealt with. This video demonstrates using random numbers to determine the starting location and the speed of the bee and the clouds
- [Instructor] Hey, welcome to video Random Numbers.…Previously, we looked at adding clouds, a tree…and a buzzing bee.…In this video, we are going to take a look at…generating random numbers in C++.…Random numbers are useful for lots of reasons in games.…Perhaps you could use them for determining…what card the player is dealt or how much damage…within a certain range is subtracted from…an enemy's health.…As hinted at, we will use random numbers to determine…the starting location and the speed of the bee…and the clouds.…
To generate random numbers, we will need to use…some more C++ functions, two more, to be precise.…Don't add any code to the game yet.…Let's just take a look at the syntax…and the steps required with some hypothetical code.…Computers can't actually pick random numbers.…They can only use algorithms, calculations to pick a number…that appear to be random.…So that this algorithm doesn't constantly return…to the same value, we must seed the random number generator.…The seed can be any integer number,…
This course was created and produced by Packt Publishing. We are honored to host this training in our library.
- Creating the main game loop
- Drawing the game background
- Handling errors
- Manipulating C++ variables
- Randomizing numbers
- Making decisions with if, else, and switch
- Moving game objects
- Pausing and restarting games
- Adding scoring and messages
- Using class enumerations and arrays
- Adding sound effects
- Object-oriented programming in C++
- C++ references
- Texture management
- Collision detection
- Implementing the HUD
- Finishing the game
Skill Level Beginner
1. C++, SFML, Visual Studio, and Starting the First Game
2. Variables, Operators, and Decisions
3. C++ Strings, SFML Time, Player Input, and HUD
4. Loops, Arrays, Switch, Enumerations, and Functions
5. Collisions, Sound, and End Conditions
6. Object-Oriented Programming, Classes, and SFML Views
7. C ++ References, Sprite Sheets, and Vertex Arrays
8. Pointers, the Standard Template Library, and Texture Management
9. Collision Detection, Pickups, and Bullets
10. Layering Views and Implementing the HUD
Updating the HUD each frame3m 24s
11. Sound Effects, File I/O, and Finishing the Game
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.