Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
recharging code...many uses... #73549
05/08/06 01:28
05/08/06 01:28
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
okay, first of all the code below is meant for recharging energy and slowly boosting the player, and it recharges depending on how much is lost, this can be used for recharging shields, health, energy weapons, other ammo, and more...no credit necessary, although it would be nice...

Code:

var energy = 100;
var use_energy;

function energy_recharge()
{
while (1)
{
if (energy > 100) { energy = 100; }
if (energy < 0) { energy = 0; }
if (use_energy == 0)
{
if (energy < 20) { energy += 0.5 *time; } //if energy has been majorly depleted recharge slowly
if (energy >= 20 && energy < 30) { energy += 1 *time; } //start to speed up charge
if (energy >= 30 && energy < 50) { energy += 2 *time; }
if (energy >= 50 && energy < 74) { energy += 4 *time; }
if (energy >= 74 && energy < 100) { energy += 7 *time; }
}
wait (1);
}
}



now put this in the code where you want it to recharge

Code:

if (jump_key == on) //boost and drain energy
{
if (energy > 0)
{
use_energy = 1;
c_move (my, vector (0,0, my.boost_speed *time), nullvector, glide);
energy -= 5 *time;
}
}

else
{
use_energy = 0;
}



things in red need to be edited to your prefs.
believe me, this is the best way to do the recharge, as putting min/max will allow energy to go above or below what it should be...enjoy


- aka Manslayer101
Re: recharging code...many uses... [Re: mpdeveloper_B] #73550
06/04/06 04:23
06/04/06 04:23
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
i take it no one needed this....oh well


- aka Manslayer101
Re: recharging code...many uses... [Re: mpdeveloper_B] #73551
06/04/06 05:38
06/04/06 05:38
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Choose your own adventure:
*At least you took a gamble and put it out there.
*In my opinion, this demonstrates, in this instance, you've got the right spirit.
*At the very least, I respect that you took the time and initiative to contribute.

Re: recharging code...many uses... [Re: testDummy] #73552
06/06/06 06:09
06/06/06 06:09
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline
Senior Developer
Josh_Arldt  Offline
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
Thanks for the contribution man.
I find it helpfull.
Thanks.

Re: recharging code...many uses... [Re: Josh_Arldt] #73553
06/08/06 15:41
06/08/06 15:41
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
thank you guys now i'm happy, lol, now i'm off to play jedi academy...


- aka Manslayer101
Re: recharging code...many uses... [Re: mpdeveloper_B] #73554
06/08/06 21:18
06/08/06 21:18
Joined: Feb 2003
Posts: 204
England
BigDaz Offline
Member
BigDaz  Offline
Member

Joined: Feb 2003
Posts: 204
England
Thanks, I might make use of that

Re: recharging code...many uses... [Re: BigDaz] #73555
06/20/06 00:28
06/20/06 00:28
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
thanks again


- aka Manslayer101
Re: recharging code...many uses... [Re: mpdeveloper_B] #73556
06/23/06 06:12
06/23/06 06:12
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Marcio Esper Offline
Senior Member
Marcio Esper  Offline
Senior Member

Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
very cool and clean code.

I believe it will be very usefful for many users that are going out from templates.

Congratulations

BR

Marcio

Re: recharging code...many uses... [Re: Marcio Esper] #73557
06/25/06 01:54
06/25/06 01:54
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
well i myself am kindof a noob to wdl, well...i started with 3dgamestudio back in i'd say.....december, no wait....september, but i did not start scripting till december, i'm still kinda newb but i make use of the code i know ^^. i have been told by a few that alot of the code i make is clean, this code was just an idea i had since i am making a mecha fighting game


- aka Manslayer101
Re: recharging code...many uses... [Re: mpdeveloper_B] #73558
06/25/06 02:04
06/25/06 02:04
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
has anyone tested? tell me how u like it? or should i set up a demo?


- aka Manslayer101
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1