Creating a Stat Generator in under 30 Events!

1

Attached Files

The following files have been attached to this tutorial:

.capx

txtbased-orig.capx

Download now 174.71 KB
.capx

Stats

3,010 visits, 4,020 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 24 Nov, 2014. Last updated 19 Feb, 2019

Hey guys!

As per request in my forum post about this project (which can be found here), I decided to make a tutorial for it.

Let's get started!

What You'll Need:

x18 Text Objects

x1 Button Object

Mouse Input

Getting the objects into your project

We'll create the objects needed in order to make dealing with the functionality easier later on.

First, go into your objects menu by double clicking anywhere. in the window. Then, under the sections, Form Controls and Input, add one button and include the Mouse Input into your project.

From there, create your 18 Text Objects. You can do this either by going into your objects window and creating them individually or right click on an already existing Text Object and click Clone object type. The reason you need 18 is because I decided to use 4 individual Text Objects per skill and 2 for the unallocated points

Name your objects properly!

You want to name these clearly and keep the same pattern so I kept my naming conventions simple.

In the picture below, you can see how I named the Health Text Objects.

These naming conventions are repeated through each skill.

Now that the necessary objects are in our project, we can start putting them all together. Onto the Event Sheet!

Creating your Player Stats

It's important to have a solid idea of what you want your game to be in order to create useful player stats we'd like our player to have. Once you know, create them as global variables. For now, we'll keep it simple and use 4 basic stats however, you can add as many as you like later on. You'll also need to create the maximum amount of stat points you'd like the player to be able to have and put it in a global variable.

Next, we can set up our button so everytime it's clicked, we reset our variables to their default values, assign them a new random value, and update and display the new value in their Text Objects.

Important Tip

if you add more skills for the player to put points into, make sure to update how much you're subtracting from them in the Events Sheet. For example, we have 4 skills the player can allocate points to, you'll notice the first skill, Health, generates a number between 1 & STAT_POINTS - 3 and the next skills do the same with the number being subtracted going down by 1

(i.e. 1 & STAT_POINTS - 3, 1 & STAT_POINTS - 2, ....) along with the skills preceding it.

This is because when generating a random number and you have a limit you'd like to stay within, our's being 100, you want to subtract 1 for every skill from then on to be sure each skill has a minimum of 1 point in it.

However, this only works down to the range of 1 & STAT_POINTS - 1 because for your last skill you calculate the total amount of points allowed - the total amount of points allocated and assign the remainder to your last skill. That's why you subtract 1 less than your total number of skills.

I call it Zero Based Subtraction! ;)

Lastly, you subtract all of your skill points from the total amount of points and display it.

Now, it's time to add some response!

Bringing it all together

Basically, what we're doing here is turning all your +'s and -'s into buttons. When they're clicked, they either add or take away 1 point from that skill and put it back into the available skill points waiting to be reallocated.

For further instruction, refer to the picture below:

Making It Pretty

We'll be showing the player when they can and can't allocate points by checking if each skill has <= 1 skill point. If it does, grey out the "-" button on that skill. Also, if the Skill has > 1 skill points, make it black again.

It's almost the same with the "+" button except they all turn on and off together because they are linked to the total points. If there are any unallocated points, the "+'s" are black, if all points are allocated, they are grey.

That's it!

The completed .capx is attached below along with an update to show an example of how to add additional skills.

I hope this helps anyone looking to do a similar project or expand off this and implement it into their own work. :)

Till next time!

.CAPX

txtbased-orig.capx

Download now 174.71 KB
.CAPX
  • 0 Comments

Want to leave a comment? Login or Register an account!