Featured Digital Mechanic:
Currency
Game currency can be all about coins but can also be a way to assign value to elements in the game. Let's explore!
Let's explore currency through a digital mechanic...
01 Build an RNG
Here we will take you through some ways to explore luck mechanic through random number generator. Check out our step-by-step guide below!
WHAT WE ARE BUILDING:
A functioning RNG that can simplify parsing random numbers vs just using a generic rand function. A class that handles all your random number queries with simple commands vs manually asking for them each time. Use this to generate a loot table system to create random drops based on %s
- Open GDevelop and click on "Create a New Project."
- Choose any template or select "Empty Project" to start from scratch.
- In the project dashboard, you should have a default scene.
- If it’s not there, click on the "+" icon next to Scenes and select "Add a Scene."
- Name the scene if needed.
- Click on the "Objects" tab on the right and then click "+ Add a new object."
- Choose "Text" from the list of object types.
- Name your text object, such as RandomText, and adjust the text size, font, and position as necessary.
- Drag and drop the text object onto your scene to place it.
- Switch to the Events tab at the top of the screen to begin adding logic to your game.
- Click on "Add a new event" and select the event to trigger the random number generation. For simplicity, we can use a "Key Press" event to trigger the action:
- In the Conditions section, click on "Add a condition."
- Search for Key Pressed and select it.
- Set the key, for example, Spacebar.
- In the Actions section of the same event, click on "Add an Action."
- In the search bar, type Do = RandomInRange and select the appropriate action.
- Set the action to change the text of the RandomText object:
- Select the Modify the text of an object action.
- Choose RandomText as the object.
- In the text field, write the expression: ToString(RandomInRange(1, 100))
- This will generate a random number between 1 and 100 and convert it to text format so that it can be displayed.
- Click on the play icon to preview the scene.
- When you press the spacebar, the text object should update to display a new random number each time.
- You can change the range of the random number by adjusting the parameters in RandomInRange(1, 100).
- You can also trigger the random number generation with other events, like clicking a button or after a certain amount of time passes.
02 Using RNG
Check out some ways to use RNG in a game context and explore how to manipulate and tune things quickly.
- You can jump into one of our game templates to see how RNG used in a game - feel free to grab and reuse to get you on your way!
- Check out GDevelop Documentation wiki here
- GDevelop RNG tutorial on YouTube
03 Your Turn
How will you explore luck in your game? How does luck work in your favorite games? How might a RNG be incorporated into your game?
Now keep building
Double click to change this paragraph text. This is not a Lorem Ipsum text, but we still want to keep it long, blah-blah-blah, is it long yet? Oh it's enough, double click to edit :)
Get inspired
Check out these games to modify or recreate to explore more ways to use RNG in games:
Build an experience
Use these a template to kickstart your game...add elements and try manipulating RNG to introduce luck into your game.
Share with us
Connect with our Brand page inside GDevelop and save your game here:
URL TBD