The Daily Click ::. Forums ::. Klik Coding Help ::. And who is he who is so wise in the ways of science!?
 

Post Reply  Post Oekaki 
 

Posted By Message

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
17th February, 2007 at 08:12:36 -

Okay, now I know that this math is correct, but for whatever reason I CAN NOT get this stupid thing to work for me! (I'm using MMF1.5) I figure the tons of math gurus on here might know what I'm doing incorrectly.

What I want: To display a counter (that has 101 frames of animation to look like a "life bar", from value 0 to 100). But instead of showing raw HP, I want it to show the percentage of life left on the enemy.

I have this for the calculation:

set EnemyLifeBar Value to Int((Health("enemy") / MaxHealth("enemy")) * 100) + 1

So say an enemy had 8 of its maximum 10 HP left, 8 / 10 = .8 * 100 = 80%
So it would show the bar at 80% full.

The "+1" is so the animation frame matches up correctly, so frame #1 is when the enemy has 0 life, and frame 101 is when it's at 100% health.

I've run this on the calculator with numerous values and it all works perfectly. The problem is that whenever I change the value of the enemy's health, the counter sets itself to 1. ALL THE TIME. I also have a string label that constantly displays the current monster HP so I know that the value doesn't get set to zero by accident (which would make the bar show up as empty.) I've tried changing its starting value so that it starts out with less than maximum HP, and the counter sets itself to zero. I've tried taking the "Int" part of the equation out (I don't know why, I just had to try everything) but also no dice. The counter's values are set to 0 minimum, 101 maximum, and I have all the frames for it drawn and loaded already. In fact, if you set the counter's value to the enemy's HP it works great- only it shows the actual HP instead of the overall health percentage like I want it to. (So that a rabbit with 2 or its max 4 HP should display a health bar half full instead of a tiny "2 out of 100" sliver of life on the bar.)

I don't want to compromise my game and just have it display the actual HP, especially since this would limit my monsters to a maximum of 100 HP for the whole game! Is it just a wanky MMF bug?

Image Edited by the Author.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
17th February, 2007 at 08:20:29 -

Did you try sticking some .0s in there so that it knows to handle the decimals properly?

set EnemyLifeBar Value to Int((Health("enemy") / MaxHealth("enemy")) * 100.0) + 1.0

MMF needs convincing when it comes to that sometimes.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
17th February, 2007 at 08:58:10 -

No, I never thought of that! I'll try that later for sure, thank you Radix!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
19th February, 2007 at 02:15:50 -

i remember having these problems with both TGF and MMF. How does MMF2 handle this? the same way ?

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
19th February, 2007 at 05:45:38 -

I think it automatically floors decimals mid-calculation unless you use one in the equation, in which case it does it properly.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
19th February, 2007 at 08:58:31 -

Okay, it works but what was weird is that by adding the .0 to the calculation didn't make it work- I had to add the .0s to the Alt Variables themselves.

Thanks again Radix, what a difference it makes

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
19th February, 2007 at 17:55:34 -

I dont understand the advantage of doing this... but currently in a game I'm working on, the enemies have health and a max health value. When you hit an enemy, the enemy health counter is set to those values... so it should automatically show a percentage, right?

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
20th February, 2007 at 11:08:11 -

Yep, it's an animation counter. BUT it's not one of those default crappy health bars. I had to actually draw ONE HUNDRED (and one) STINKIN' FRAMES to make a decent-looking health bar. And to top it off, there are different colored variations of these bars throughout my game that I had to go through all the frames. (There's red, blue, purple, green, yellow, brown, and grey!) It was a big, big pain in the ass, but at least they're all completed now.

You can sort of see the bar in the inventory screenshot of my Equin 3 preview, but that's a REALLY old screenshot so don't worry the whole thing looks much better now.

Phizzy said: Which doesn't really make sense

Yep, that pretty much sums up my coding style in MMF at least, lol. The end result is the goal, even if the road there is full of crazy, crazy, twists and turns that don't need to be.

Image Edited by the Author.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
21st February, 2007 at 11:08:05 -

I don't think so. Sure, it's still technically a bar, but instead of the default skinny solid bar I now have colored bars with different shades to them. Not to mention a border around each one.

This was nothing compared to the pain in the ass that all the drawing / copying / pasting to different backgrounds per animation frames that I did for Equin Adventures. That was probably the most taxing and tedious thing in programming that I've ever done.

Here's why:

3 frames of animation for walking w/ regular sword for 4 directions on the grass(12)
3 frames of animation for a regular sword attack in 4 directions the grass (12)
3 frames of animation for getting hit for 4 directions on the grass (12)
3 frames of animation for walking with a shield & reg sword for 4 directions on grass (12)
3 frames of animation for walking with a shield & shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ regular sword with a shield for 4 directions on grass (12)
3 frames of animation for walking with the shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ shadow sword for 4 directions on grass (12)
3 frames of animation for attacking w/ shadow sword and shield for 4 directions on grass (12)
4 frames of animation (frontal) for dying while on the grass (4)
1 frame of animation (frontal) for blocking with the shield (1)


Ready for the kicker? Each of the above had to be done for grass, dirt, wood floors, and snow! For the inside areas the shadow sword also had a glow around it, so it wasn't a simple cut / paste for those ones. The walking animation for different swords was done so that the player could see the different sword slung on Equin's back.

So that's 113 pictures x 4 backgrounds = 452 pictures. For the main character alone!

I didn't learn about bitblt until Equin Village, otherwise it would have saved me a couple of weeks at least.

So I don't stress the life bar too much lol.


 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
21st February, 2007 at 19:21:05 -

Even without using the default bars, you could create and position bar segments dynamically or something and save yourself a lot of effort.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
22nd February, 2007 at 08:04:41 -

G.I. Joe said it best:

"Now you know!"
"And knowing is half the battle!"

I repent! Next time I'll look into easier methods, but for now I need to find a cat o' nine tails and an empty church tower

Thanks for the information and help, even you Phizzy!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!
   

Post Reply



 



Advertisement

Worth A Click