How To Make A Game with GDevelop - UI Hacks (E08)

Victris Games
30 Jan 202214:00

Summary

TLDRIn this eighth tutorial by Tristan from Victrus Games, viewers are guided through adding unique UI elements to a game using GDevelop. The video, dubbed 'UI Hacks,' teaches how to create a speedometer displaying the player's velocity and a progress tracker indicating the player's advancement through the level. Tristan demonstrates utilizing scene variables, the Shape Painter object for a dynamic speedometer, and repurposes a draggable slider for a visual progress indicator, enhancing the gaming experience with these creative hacks.

Takeaways

  • 🎼 Tristan from Victrus Games is teaching how to make a game with GDevelop, a 2D open-source game engine.
  • đŸ› ïž The video focuses on adding UI elements, specifically a speedometer and a progress tracker, using some unconventional methods.
  • 🔱 The speedometer displays the player's current speed, calculated from the object's linear velocity in the Y direction.
  • 📝 A scene variable 'player speed' is used to store the current speed, which is then displayed using a text object.
  • 🔄 Negative speed values are corrected by multiplying by -1, and the speed is rounded and divided by 10 for readability.
  • 🎹 A shape painter object is introduced to create a visual speedometer, using an arc instead of a full circle for a dynamic effect.
  • ✹ The shape painter object is customized with an outline color, large outline size, and zero opacity fill for a speedometer look.
  • 📊 A progress tracker is created using a repurposed draggable slider to show how far the player has traveled in the level.
  • 🔄 The slider's position is dynamically updated based on the player's distance traveled, calculated as a percentage of the total track length.
  • 📈 A number object is used to display the percentage of the level completed, with the value clamped between 0 and 1 for accuracy.
  • 🔧 The tutorial includes tips on customizing the appearance of the UI elements, such as changing colors, shapes, and adding effects like glow.

Q & A

  • What is the main focus of the eighth video by Tristan from Victrus Games?

    -The main focus of the video is to add UI elements such as a speedometer and a progress tracker to a game using the GDevelop 2D open source game engine.

  • How does the video suggest to determine the player's current speed in the game?

    -The video suggests using a scene variable called 'player speed' and setting it to the value of the object's linear velocity in the Y direction using the Physics 2 behavior.

  • What object is used to display the player's speed in the game?

    -A text object is used to display the player's speed, which is modified to show the value of the 'player speed' variable.

  • Why does the speed value initially show as a negative number?

    -The speed value initially shows as negative because the Y-axis increases as you go down, and since the player is moving up, the speed is negative.

  • How is the negative speed value corrected in the video?

    -The negative speed value is corrected by multiplying the value by negative one to make it positive.

  • What is the purpose of using a Shape Painter object in the video?

    -The Shape Painter object is used to create a visual representation of a speedometer by drawing an arc that moves dynamically based on the player's speed.

  • How is the progress tracker UI element created in the video?

    -The progress tracker is created by repurposing a draggable slider and using a number object to display the percentage of the level completed.

  • What extension is mentioned for creating a slider in the game?

    -An extension created by the author is mentioned, which uses a Shape Painter and adds the draggable slider behavior.

  • How does the video suggest to calculate the percentage of the level that the player has completed?

    -The video suggests calculating the distance traveled by the player, dividing it by the total track length, and then using the result to set the slider value and update the text object displaying the percentage.

  • What function is used to ensure the percentage value does not exceed 100 or go below 0?

    -The 'clamp' function is used to enforce a minimum value of 0 and a maximum value of 1 on the percentage value.

  • What does the video suggest for the next steps after creating the UI elements?

    -The video suggests creating more levels by tweaking the procedural generation algorithm to add variety to the game in the next video.

Outlines

00:00

🎼 Game Development UI Hacks

This paragraph introduces the video's focus on UI elements in game development using GDevelop, an open-source 2D game engine. The video will demonstrate how to create a speedometer and a progress tracker for the player. The speedometer will display the player's current speed, while the progress tracker will show how far the player has traveled in the game level. The tutorial begins by explaining how to save the current speed as a variable and then how to use a text object to display this variable. The speed value is adjusted for readability and a shape painter object is introduced to create a visual speedometer using an arc drawing technique.

05:00

📊 Crafting a Dynamic Speedometer

The speaker discusses the process of creating a dynamic speedometer using a shape painter object in GDevelop. They explain how to draw an arc that represents the speedometer, starting with a half-circle arc from 180 to 360 degrees. The appearance of the shape painter is customized with an outline color and size, and the fill is made transparent. A glow effect is added to enhance the visual appeal. The dynamic movement of the speedometer is achieved by linking it to the player's speed variable, adjusting the angle to reflect the current speed. The tutorial also covers how to scale the speed value to fit the visual design and ensure it remains within the desired range.

10:00

📏 Progress Tracker Using UI Slider Hack

This section covers the creation of a progress tracker using a draggable slider, repurposed as a visual indicator of the player's progress through the game level. The tutorial starts with installing the necessary extension for the draggable slider behavior. The default appearance and functionality of the slider are explained, including its range and numerical representation. The speaker then describes how to modify the slider's appearance, including the thumb color and shape, and adding a glow effect. The key part of the tutorial is setting up events to update the slider's position based on the player's movement across the level and displaying the progress percentage using a text object. The tutorial concludes with a test of the progress tracker and a summary of the video's content, with a teaser for the next video on creating varied game levels.

Mindmap

Keywords

💡GDevelop

GDevelop is an open-source 2D game engine that allows users to create games without writing any code. It is the main tool discussed in the video, where the tutorial focuses on adding UI elements to a game. The script mentions using GDevelop to create a speedometer and progress tracker, demonstrating its versatility for game development.

💡UI Elements

UI Elements refer to the visual components used in a game's user interface, such as buttons, sliders, and text displays. In the context of the video, the creator is adding a speedometer and progress tracker as UI elements to enhance the player's experience and provide real-time feedback on the game's status.

💡Speedometer

A speedometer is a device that measures and displays the speed of a vehicle or, in the case of this video, a game character. The script describes creating a custom speedometer in GDevelop to show the player's current speed, using a combination of variables, text objects, and a shape painter object.

💡Progress Tracker

A progress tracker is a UI element that visually represents how far a player has advanced in a game level or task. The video script details the creation of a progress tracker using a draggable slider repurposed to automatically move based on the player's position in the game level.

💡Physics2

Physics2 is a behavior in GDevelop that allows for the simulation of realistic physics in a game. The script uses Physics2 to access the linear velocity of the game object, which is then utilized to calculate the player's speed for the speedometer.

💡Variable

In the context of game development and scripting, a variable is a storage location paired with an associated symbolic name, which contains some known or unknown quantity or information, a value. The video script mentions creating variables like 'player speed' to store and manipulate data within the game.

💡Scene Variable

A scene variable in GDevelop is used to store information that persists throughout a game scene. The script refers to creating scene variables such as 'track length' and 'distance traveled' to keep track of the level's length and the player's progress.

💡Shape Painter

The Shape Painter is an object in GDevelop that can draw various shapes on the game screen. The video uses a Shape Painter object to create a custom speedometer dial by drawing an arc and manipulating its properties to match the desired visual effect.

💡Draggable Slider

A draggable slider is a UI element that allows users to interact by dragging a thumb along a track to select a value. In the video, the creator repurposes this element to create a non-interactive progress tracker that automatically updates based on the player's position in the game.

💡Event

In GDevelop, an event is a set of actions triggered by a condition. The script describes using events to create behaviors, such as updating the speedometer and progress tracker based on the player's actions and the game's state.

💡Clamp Function

The clamp function is a mathematical operation used to restrict a value within a specified range. In the video, the clamp function is used to ensure that the progress tracker's value stays between 0 and 1, preventing it from displaying incorrect values.

Highlights

Introduction to the eighth tutorial video on creating a game with GDevelop, focusing on UI elements.

Adding a speedometer to display the player's current speed using unusual object manipulation.

Utilizing scene variables to store the player's speed and accessing Physics 2 properties.

Creating a text object to display the player's speed with modifications for readability.

Addressing the issue of negative speed values due to the Y-axis direction and resolving it.

Introducing the Shape Painter object for versatile and creative UI elements.

Using a Shape Painter object to create a dynamic speedometer with an arc.

Customizing the appearance of the speedometer with effects like glow for aesthetics.

Dynamically adjusting the speedometer's angle based on the player's speed.

Creating a progress tracker to visualize how far the player has traveled in the level.

Repurposing the draggable slider as a progress tracker in an innovative UI hack.

Setting up a variable to track the player's distance traveled and calculating the percentage of level completion.

Using the clamp function to ensure the progress percentage displays correctly without decimals.

Adjusting the slider's properties for a customized look that matches the game's theme.

Linking the progress tracker to the player's movement to update dynamically as the player advances.

Preview of upcoming video content focusing on creating varied levels through procedural generation tweaks.

Invitation for viewers to like, subscribe, and follow on social media for more game development content.

Transcripts

play00:00

this is tristan with victrus games

play00:03

hello and welcome back this is our

play00:05

eighth video on how to make a game with

play00:07

g develop the 2d open source game engine

play00:10

in this video we'll add a couple more ui

play00:13

elements

play00:14

i'm calling this video ui hacks because

play00:16

we're going to be using some objects in

play00:18

slightly unusual ways

play00:20

we will add a speedometer that shows the

play00:22

player's current speed and also a

play00:24

progress tracker that shows how far the

play00:26

player has traveled in the level

play00:29

our ui ready to get started

play00:37

if we're gonna make a speedometer the

play00:39

first thing we need to do is find out

play00:41

how fast we're going let's see if we can

play00:43

save our current speed as a variable

play00:47

we'll pick a scene variable

play00:50

call it

play00:51

[Music]

play00:53

player speed and we will set it to

play00:55

the value of our speed to find out what

play00:58

our speed is let's start by typing our

play01:00

object name

play01:04

at the top here where it says physics 2

play01:06

this will give us access to the

play01:08

properties that are specific to the

play01:10

physics 2 behavior there are a ton of

play01:13

things you can learn about the object

play01:15

the one that we are most interested in

play01:16

is this linear velocity in the y

play01:18

direction okay that saves it as a

play01:21

variable however there's nothing for us

play01:22

to look at let's create a text object to

play01:25

display that variable

play01:28

i like the way this race timer text

play01:30

object looks so let's just duplicate it

play01:33

and that'll keep all of the existing

play01:35

sizes colors and effects

play01:37

[Music]

play01:38

and we'll drag it down here make sure

play01:40

this object is on the ui layer let's

play01:42

change the text to display the value of

play01:44

this variable so the action will apply

play01:47

to the player speed text object modify

play01:50

the text

play01:52

we'll need to use our tostring function

play01:54

because the text object wants a string

play01:56

and the speed is a number the variable

play01:59

player

play02:01

speed

play02:05

okay let's see what it looks like

play02:08

let's move forward and see what happens

play02:13

oh

play02:15

so we have a negative number and we've

play02:17

got all these decimal points the reason

play02:20

we have negative numbers is because the

play02:21

y-axis increases as you go down and

play02:24

since we're moving up that's why the

play02:26

speed is negative okay to fix the

play02:29

negative number let's just multiply this

play02:31

value by negative one

play02:35

and then to get rid of the decimal

play02:36

points let's round the text that's being

play02:38

displayed let's see what it looks like

play02:40

now

play02:44

there we go we have no negative numbers

play02:46

no decimal points i still think it's

play02:48

kind of hard to read with all these

play02:50

numbers changing so quickly i think i'm

play02:52

just going to divide everything by 10 to

play02:54

keep us under 100 units of speed

play02:56

[Music]

play03:00

i'm just going to divide the number

play03:02

that's displayed by 10.

play03:07

okay now our speed seems to be easy to

play03:10

read and looks good now having a number

play03:12

is great but wouldn't it be cool if it

play03:15

actually was similar to what a

play03:16

speedometer does i figured out a simple

play03:18

way for us to do this using a shape

play03:20

painter object we haven't talked about

play03:22

shape painter objects before but they're

play03:24

very useful and versatile let's add one

play03:32

let's start with it with the default

play03:34

values you'll have a black outline color

play03:36

and the fill color the inside will be

play03:38

white

play03:41

now when we drag this shape painter

play03:42

object onto the screen

play03:45

it'll show a placeholder icon here

play03:47

however it doesn't actually show up in

play03:49

the game to make it do anything you're

play03:51

gonna have to create an event that draws

play03:53

something

play03:56

you click on the speedometer

play03:59

and down towards the bottom you'll see a

play04:01

group of actions called drawing for

play04:03

instance you could draw a circle

play04:05

position in this circle will make zero

play04:08

zero and the radius will be one hundred

play04:11

that zero zero location

play04:13

is based off the position of the where

play04:15

we place this shape painter object you

play04:18

can verify that by looking at the shape

play04:20

painter and this top option draw the

play04:22

shapes relative to the object position

play04:24

in the scene if you take this off

play04:26

then it is absolute positions so zero

play04:29

zero is the top left of the screen and

play04:31

sometimes that's useful but in this case

play04:33

we're going to leave this checked and

play04:34

it'll draw it right where we place this

play04:36

icon all right do you want to see what a

play04:38

circle looks like

play04:40

that's the default look of the shape

play04:42

painter with the default values drawing

play04:44

a circle not too exciting but like i

play04:46

said it's highly versatile and it could

play04:47

do so many things i use this for quite a

play04:50

few interesting extensions that i've

play04:52

made and so in this case we're going to

play04:54

do something kind of a hack because

play04:56

we're going to use only part of a

play04:58

drawing let me explain what i mean by

play05:00

that instead of drawing a circle

play05:02

let's try drawing a arc let's start this

play05:06

angle at 180 and end it at 360. if you

play05:09

imagine like a half circle 180 is the

play05:12

left side and it'll go up

play05:14

to 270 at the top

play05:16

and then 360 is over here at the right

play05:20

so this should draw a half circle

play05:23

[Music]

play05:25

let's change the way it looks a little

play05:27

bit

play05:29

i'm going to change the outline color

play05:33

the outline size and make it pretty big

play05:37

and for the fill i'm going to actually

play05:38

set the opacity to zero so that instead

play05:40

of having a white fill there's going to

play05:42

be no fill at all

play05:44

and let's see what this looks like

play05:47

there we go that kind of looks a little

play05:48

bit like a speedometer let's add another

play05:51

effect so it looks nicer let's add the

play05:53

glow effect to the shape painter

play05:56

[Music]

play06:00

choose the black color

play06:03

and see what it looks like

play06:06

i think i needed to be a little bit

play06:08

bigger

play06:10

so on our draw event we'll change it

play06:12

from the radius of 100 pixels to 150

play06:15

pixels on the radius

play06:17

and it wasn't quite centered so let's

play06:19

scoot it over a little bit

play06:20

[Music]

play06:23

okay that's good enough

play06:25

oh i've got to get on the right layer i

play06:28

always make that mistake

play06:29

[Music]

play06:32

there we go

play06:34

i might scoot the text over a little bit

play06:37

but other than that it's looking really

play06:39

well this speedometer currently starts

play06:41

at the angle of 180 and goes to 360. to

play06:44

make the speedometer move dynamically

play06:46

what if we set this amount equal to our

play06:49

speed let me show you what that looks

play06:51

like

play06:52

so i'm going to leave our starting angle

play06:54

at 180 but instead of doing a static 360

play06:57

let's take the starting angle which is

play06:59

180 and let's add our variable

play07:02

[Music]

play07:03

player speed

play07:06

so whatever our player speed is will be

play07:08

added to 100 180 degrees

play07:13

so that's working pretty good however

play07:16

it's going way past what i wanted to go

play07:17

past so the number is too big to shrink

play07:20

the number we can just divide it let's

play07:21

divide this number by six

play07:25

okay i like the way this looks

play07:27

i think the speedometer is finished next

play07:29

i want to create a visual indicator that

play07:32

players can see how far along the level

play07:34

they have gone for this i'm going to use

play07:36

another ui hack by repurposing the

play07:39

draggable slider let me show you what a

play07:41

slider normally looks like first we need

play07:43

to install the extension

play07:46

[Music]

play07:50

this is an extension that i made to use

play07:53

it you create a shape painter

play07:57

and then you add the draggable slider

play07:59

behavior there's a lot of options here

play08:01

that will let you choose how it looks

play08:03

like but let's just show you what the

play08:05

default look of the slider is

play08:08

we'll put on our ui layer all right

play08:10

let's test this

play08:12

okay so this is what the default slider

play08:14

looks like it's a ui element that lets

play08:16

users select a numerical number by

play08:18

dragging this thumb by default it's a

play08:21

range of numbers between zero here on

play08:23

the left and when it's full that's a

play08:25

value of one so you can almost think of

play08:28

any number in here is a number between

play08:29

zero and one

play08:30

and the middle of course will be 0.5

play08:33

we're going to use this in a way that

play08:35

doesn't let the users interact with it

play08:36

instead our events are going to change

play08:39

the position of the slider based on how

play08:41

far the player has moved across the

play08:42

level let's also create a number that

play08:45

will display the progress i'll copy the

play08:48

player speed object

play08:52

[Music]

play08:55

and i'll use this to display the percent

play08:57

complete

play09:01

i'll change the placeholder text to show

play09:03

that it's a percent

play09:06

[Music]

play09:08

let's see if we can make this slider

play09:10

look a little nicer

play09:13

to change the way a slider looks you

play09:15

will change the properties under the

play09:18

behavior feel free to set these however

play09:20

you like i'm going to choose what i

play09:22

think looks nice

play09:26

i'm going to make the thumb color match

play09:28

the color of the player let's change the

play09:30

thumb shape from a circle to a rectangle

play09:33

[Music]

play09:40

let's also add the glow effect to this

play09:42

shape painter

play09:47

and let's see how it looks now

play09:51

nice

play09:52

what we want is for this progress

play09:53

tracker just to move along the track the

play09:56

same percentage that the actual player

play09:59

is traveling

play10:00

okay let's see if we can set that using

play10:02

events

play10:03

[Music]

play10:07

in order for us to calculate the

play10:08

percentage of the level that the player

play10:10

has completed we first need to know how

play10:13

long the actual level is

play10:15

let's set a variable to keep track of

play10:17

this

play10:18

[Music]

play10:21

we'll set it to the distance between the

play10:23

starting and finish line

play10:27

and we want to know about their y values

play10:33

and the track length is not going to

play10:34

change so let's just do it one time at

play10:37

the beginning of the scene this will

play10:38

save us some cpu cycles next we need to

play10:41

know how far the player has traveled so

play10:44

let's do another scene variable

play10:48

distance traveled and instead of

play10:50

measuring between the starting and

play10:52

finish line let's measure between the

play10:54

starting line and the player

play11:01

now that we've calculated the distance

play11:03

traveled and we know the length of the

play11:05

track we can easily divide those to find

play11:07

the percentage that has been traveled so

play11:09

far

play11:14

[Music]

play11:18

so let's use this number we just

play11:19

calculated and put it inside the text

play11:22

object for percent traveled

play11:24

[Music]

play11:24

[Applause]

play11:27

modify the text

play11:29

and we'll set it to that variable we'll

play11:30

have to use the tostring function to

play11:32

convert the number into a string

play11:38

let's do a quick test

play11:42

okay it's showing a negative number with

play11:44

a lot of decimals

play11:46

the reason it's the negative number is

play11:47

because we're below the starting line

play11:50

and it gets to about zero at the start

play11:52

line and becomes positive so we can fix

play11:54

that by using the clamp function the

play11:56

clamp function is very useful it

play11:58

basically enforces a minimum and a

play11:59

maximum value

play12:01

so there's a clamp function

play12:03

and the first parameter is your starting

play12:06

number and then the minimum number and

play12:08

the maximum number so this clamp is

play12:10

going to make sure that whatever this

play12:12

calculates out to be it will set a

play12:14

minimum value of zero and a maximum of

play12:15

one to get rid of those extra decimal

play12:18

points let's multiply this number by 100

play12:22

[Music]

play12:24

and we will round it

play12:27

and let's also add that percent symbol

play12:29

at the end

play12:36

[Music]

play12:39

okay our number is incrementing but our

play12:41

slider is not moving

play12:47

so for action

play12:48

we will choose the slider progress

play12:50

tracker

play12:52

[Music]

play12:53

and we're going to set the slider value

play12:57

we'll set it to the variable

play12:59

let's see if that worked

play13:01

[Music]

play13:06

there it goes it's sliding across

play13:10

because we have that clam function it

play13:12

should stop at the 100

play13:14

complete i'll do my best to make it

play13:16

through this level

play13:17

[Music]

play13:26

100

play13:27

that's all for this video in our next

play13:29

video we will create a few more levels

play13:31

by tweaking our procedural generation

play13:33

algorithm to give some variety to the

play13:35

game if you're finding these videos

play13:37

valuable please give a like and

play13:38

subscribe and if you want to see what

play13:40

else i'm working on follow me at

play13:42

victorusgames on twitter and lastly you

play13:45

are welcome to join us on our discord

play13:46

server thanks for watching and i'll see

play13:48

you on the next video

Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Étiquettes Connexes
Game DevelopmentUI DesignGDevelopSpeedometerProgress Tracker2D EngineVideo TutorialGame MechanicsLevel DesignDraggable SliderShape Painter
Besoin d'un résumé en anglais ?