How do I... use a non-integer in variables?

Get help using Construct 2

Post » Mon Apr 07, 2014 3:40 am

Hi guys-

I'm really not sure how to word what it is I want to do, but I'll try anyways!

Being new to construct and making my first game, I'm wonder if it possible to "split" a point scored in the game into two different variables.

For instance, if the player successfully picks up an object- instead of earning "1" point they would instead earn "2/3rd"s of a point in one category/variable and the remaining "1/3rd" of the point into another category/variable.

Any help would be very much appreciated as I'm my game is actually for a project! :D
Posts: 2
Reputation: 229

Post » Mon Apr 07, 2014 6:44 am

VarPoints=3 (divisible by 3)
VarScore = VarPoints/3
VarScore would equal 1 in this case

Player only sees "I have five points" but the variable will read 15. This way the single digits can be put in the proper category? I recommend this way because you don't have to work with decimals. From here you can say "one point to this category, two points to that one. Just a suggestion.
Posts: 273
Reputation: 3,887

Post » Mon Apr 07, 2014 8:15 am

or perhaps more simply

score1 = score1 + new_points*033
score 2 = score2 + new_points*0.66
total_score = score1 + score2

or you could do

score1 = score1 + new_points
score 2 = score2 + new_points
total_score = (score1 + 2*score2)/3

lots of different ways to do this. what I would say is that sometimes it's nice to convert scores back to integer numbers or a fixed number of decimals.. so

integers, use floor or round or ceil
fixed decimal places, I use (floor ( score*100))/100
Posts: 184
Reputation: 1,352

Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 4 guests