The Daily Click ::. Forums ::. Klik Coding Help ::. Decimals in Counter Object
 

Post Reply  Post Oekaki 
 

Posted By Message

DUGaming



Registered
  09/02/2009
Points
  0
9th February, 2009 at 12:42:47 -

I need some help here, I am trying to use a 'Counter Object' to calculate the accuracy of hits vs misses as in the accuracy of a shooting at an object in a game. I'm pretty sure to calculate the accuracy don't you go like h/m*100 or something, i'm seriously like lazy when it comes to maths. And when I add this condition the counter object that is supposed to show the accuracy always shows zero, I think it's because it wont go negative or show decimals, how do I get it to give me something else than 0? Don't worry I have tested if it is even calculating something aswell and it is but when it comes to going below zero it won't do anything!

This may be a really stupid question to you experts around here but I am like cbf working this out myself so plz help meh!

Edited by DUGaming

 
______________________________
Down Under Gaming
Melbourne, Australia
Follow your dream

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
9th February, 2009 at 13:03:21 -

You have to force decimals in MMF by using numbers with decimals in them. Multiply by 100.0 instead of 100: h/m*100.0

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

DUGaming



Registered
  09/02/2009
Points
  0
9th February, 2009 at 20:41:13 -

Oh really, cool I will try it out

 
______________________________
Down Under Gaming
Melbourne, Australia
Follow your dream

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
9th February, 2009 at 21:25:11 -

MMF2 has extremely fuzzy rules on when it will use integers and when it will use floats.

The expression editor will always default to integers. However, whenever any float is used inside the equation, whether it comes from one of the retrieved datas or if it is in the expression, the result will always be a float:

$someinteger + 100 = an integer
$somefloat + 100 = a float
$someinteger + 100.0 = a float

I'm not sure but maybe even an expression like this:
$someinteger + (1.0 - 1.0) = a float?
would work. Don't quote me on that.


But it gets fuzzy because, some places where you can *store* the numbers can only take integers. For example, if you have an equation that gives a result of 3.2847, a float, and store it into your objects alterable value A, when you retrieve it, it will just be 3, an integer. But counters can store floats apparently. I think its a toggleable option on them.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th February, 2009 at 22:30:31 -

Not sure what you mean about the alterable values only returning integers - if you force MMF2 to set the value as a float, it'll still be a float when you retrieve it. That's the whole point of storing coordinates in alterable values when you make a custom movement.

The thing I find *really* annoying though, is that you when you set an initial value in the properties panel, it will only accept whole numbers.
A lot of the time I want them to be numbers like "0.05" so I always end up having to add loads of events like this:

+ Start of frame
-> Set Alterable Value A("Player") to Alterable Value A("Player") / 100.0
-> Set Alterable Value B("Player") to Alterable Value B("Player") / 100.0 ...and so on.

 
n/a

DUGaming



Registered
  09/02/2009
Points
  0
10th February, 2009 at 11:03:47 -

Sorry Andy but how would I write what you say? I have just got the simple 'set counter' condition then I use 2 other counters to give me how many hits and misses there are, last time I had written in: value( "hits" )/value( "Misses" )*100 i have no idea if thats right, please help!

Edited by DUGaming

 
______________________________
Down Under Gaming
Melbourne, Australia
Follow your dream

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th February, 2009 at 13:56:31 -

You don't need to worry about the float problem if you multiply by 100 *before* the division.
Also, you need to divide by the *total* number of shots, not the number of missses.

Correct formula is:

Accuracy = (Hits * 100) / (Hits + Misses)



 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
11th February, 2009 at 08:07:31 -

You say it won't do anything "below zero" ...

Did you make sure to set the Minumum that the Counter can go to -99999999999 or whatever?
It starts the Min at 0 by default in TGF, I'd guess it's the same in MMF too.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

DUGaming



Registered
  09/02/2009
Points
  0
11th February, 2009 at 09:49:31 -

Dont worry guys, I worked out what to do, thanks a lot

 
______________________________
Down Under Gaming
Melbourne, Australia
Follow your dream
   

Post Reply



 



Advertisement

Worth A Click