Pages:
1
2 |
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
It has been a pleasure for me, I hope that you can finish the game, and I hope to see soon a new demo.
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
Uh-oh, there is a problem: I wrote your code, it works fine when your energy is at 100%, at 75%, etc.; but when your energy is at 50% or less the
energy bar disappears, and it reappears when your life is bigger than 50%. I have adapted the same code for the magic bar, and the same problem
occurs. The bar does not show any graphic when your health is less than a half.
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
Mmmm yes, need another formula than, wait please.
[Edited on 23-11-2016 by CicTec]
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
I used your code changing only the words "energy_damage" to "daño"("damage" in spanish), the rest is the same, I think.
PROCESS barra_vida(x,y);
BEGIN graph=22;
z=-503;region=10;
LOOP
IF(daño>1)energy_bar=max_energy/daño;
IF(energy_bar<=0)energy_bar=1;END
define_region(10,2,3,100-(100/energy_bar),10);
ELSE
define_region(10,2,3,100,10);END
FRAME;END END
In the player process I wrote a line to control the "damage" variable, so it increases every time you are touched by an enemy, an it decreases when
you touch a recovery heart or a Red Flower and you recover part of your life. (the Recovery Heart refills your health and a Red Flower recovers 10
health points). As I said, the only problem is that the energy bar disappears when your life is under 50%, the rest of the time it works well.
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
You can use the formula of Mike, adapted for your 100 pixels bar:
Code: |
real_unit = 100000 / max_health;
health_unit = real_unit / 1000;
if(health_unit <= 0)
healt_unit = 1;
end
define_region(1, 0, 0, 100 - (health_unit * damage), 10);
|
But you'll have some inaccurate values, because the formula would require floating point currently not supported by DIV.
100000 is the value of your bar width (100 pixels) * 1000 (the decimal floating point conversion to INT).
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
It works, but it seems that when your energy/magic reaches 0, the bar still shows a little part of itself. I've used your second code for the health
and the magic bar, and this is the only problem, I recorded a video to show how it looks.
https://www.youtube.com/watch?v=TFH9HGZPgts
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
in which the minute video is shown?
It should be easy to solve, try:
Code: |
if(damage < max_health)
real_unit = 100000 / max_health;
health_unit = real_unit / 1000;
if(health_unit <= 0)
healt_unit = 1;
end
define_region(1, 0, 0, 100 - (health_unit * damage), 10);
else
region = -1;
end
|
if damage> = max_health simply the graph does not appear in any region.
[Edited on 24-11-2016 by CicTec]
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
No, it is not showed in the video. (Well, in second 0:23 the magic reaches 1 point). The video has been recorded to show how the new life and magic
bars work.
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
From the video it seems to work well, the issue of when it reaches 0 should be corrected with the above code, try please.
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
I' ve tried and when the health/magic reaches 0, the bar shows the full width.
Now this is the process "life bar" from my game:
PROCESS barra_vida(x,y);
PRIVATE real_unit;health_unit;
BEGIN graph=22;
z=-503;region=10;
LOOP
IF(daño<1)daño=1;END
IF(daño<max_energy)real_unit=100000/max_energy;
health_unit=real_unit/1000;
IF(health_unit<=0)health_unit=1;END
define_region(10,2,3,100-(health_unit*daño),10);
ELSE region=-1;END
FRAME;END END
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
I can't test for now with a really example, try:
Code: |
if(damage < max_health)
real_unit = 100000 / max_health;
health_unit = real_unit / 1000;
if(health_unit <= 0)
healt_unit = 1;
end
define_region(1, 0, 0, 100 - (health_unit * damage), 10);
else
define_region(1, 0, 0, 0, 0);
end
|
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
The bar is not accurate, but don't worry. At least, it works. In fact, perhaps the game is not going to be finished anyway.
|
|
BreadCaster
Loyalty Card Holder
Posts: 321
Registered: 2-3-2016
Member Is Offline
|
|
We'd all like to see the game finished, Dani!!
If you're really struggling with it, would you like me to send the source code for the health bar from Cybercrisis?
~*~ Princess of Pies and Pastries ~*~
|
|
CicTec
DIV Pro
Posts: 471
Registered: 6-8-2016
Member Is Offline
|
|
Unfortunately it is a loss of accuracy problem for INT, when the floating point support will be added to the formula will be accurate.
I hope you can finish the game.
|
|
Dani_Karmann
DIV Pro
Posts: 87
Registered: 4-8-2016
Member Is Offline
|
|
I will continue this in the "WIPS" section. Breadcaster, this is the energy bar process:
PROCESS barra_vida(x,y);
PRIVATE real_unit;health_unit;
BEGIN graph=22;
z=-503;region=10;
LOOP
IF(daño<1)daño=1;END
IF(daño<max_energy)real_unit=100000/max_energy;
health_unit=real_unit/1000;
IF(health_unit<=0)health_unit=1;END
define_region(10,2,3,100-(health_unit*daño),10);
ELSE define_region(10,2,26,0,0);END
FRAME;END END
//---
(Note: "daño" means "damage" in Spanish)
|
|
Pages:
1
2 |