Lose Hearts by falling
#1
Posted 04 March 2012 - 08:41 AM
how would you do this so if they fall it removes a Heart the more you fall the more Hearts get removed\
please help
#2
Posted 04 March 2012 - 09:01 AM
Edited by greep, 04 March 2012 - 09:02 AM.
#3
Posted 04 March 2012 - 10:05 AM
Example, removes 1 heart for every 5 over the safe speed.
if (vspeed > safe_speed) hearts -= ceil((vspeed - safe_speed) / 5);
#4
Posted 04 March 2012 - 10:19 AM
#5
Posted 04 March 2012 - 11:59 AM
nah, yours would work too .. just check for how long in air with positive vspeedActually on second thought, only his code would work anyways, as if you jumped on a trampoline an bounced really high, e.g., my code would fail.
counter += vspeed>0
#6
Posted 10 March 2012 - 10:07 AM
I don't understand were i put the code??Or even easier, in a collision event with your floor object check the vspeed, if it's greater than the safe speed remove hearts.
Example, removes 1 heart for every 5 over the safe speed.if (vspeed > safe_speed) hearts -= ceil((vspeed - safe_speed) / 5);
#7
Posted 10 March 2012 - 10:28 AM
#8
Posted 10 March 2012 - 10:40 AM
Edited by DaRk_bLaDe, 10 March 2012 - 10:41 AM.
#9
Posted 09 April 2012 - 12:52 AM
#10
Posted 09 April 2012 - 01:03 AM
when your on the ground. Last_On = Z (or Y)
then next time you land. check if Now_On < Last_On. then check if the gap is big enough to deal damage.
#11
Posted 09 April 2012 - 08:10 AM
Ok but were am i supposed to put that and yes i understand that's how minecraft does it but minecraft is written in javathis is how minecraft deals with it:
when your on the ground. Last_On = Z (or Y)
then next time you land. check if Now_On < Last_On. then check if the gap is big enough to deal damage.
Edited by ThatOneGuyX, 09 April 2012 - 08:10 AM.
#12
Posted 09 April 2012 - 07:31 PM
i have not much coding experience with platformers, but in theory, your using place_meet or a function like that to see if the player lands on the ground.
lets just for example the below code (the place_meat is basicly, this is a example extending your gravity stop code)
if( place_meet(x,y-16) = true)
{//this is start of block
gravity = 0; //stop gravity
dif = last_y - y; //different in levels
if last_y > y and dif > 32 //if the last gound usage is BELOW (meaning a fall) AND difference is enough to take damage (32 pixels)
{//start of block
health -= (dif-32)/32; //every 32 pixels = 1 health damage, tinker with values to check it. 32 pixels is a safe non-hurt
}
last_y = y; //now set our ground_level
}
Edited by fireblade212, 09 April 2012 - 07:34 PM.
#13
Posted 09 April 2012 - 10:13 PM
Im guessing you put this in step event and by the way place_meet is an unknown code it dose to work with game makerlanguage means nothing.
i have not much coding experience with platformers, but in theory, your using place_meet or a function like that to see if the player lands on the ground.
lets just for example the below code (the place_meat is basicly, this is a example extending your gravity stop code)
if( place_meet(x,y-16) = true)
{//this is start of block
gravity = 0; //stop gravity
dif = last_y - y; //different in levels
if last_y > y and dif > 32 //if the last gound usage is BELOW (meaning a fall) AND difference is enough to take damage (32 pixels)
{//start of block
health -= (dif-32)/32; //every 32 pixels = 1 health damage, tinker with values to check it. 32 pixels is a safe non-hurt
}
last_y = y; //now set our ground_level
}
Edited by ThatOneGuyX, 09 April 2012 - 10:16 PM.
#14
Posted 09 April 2012 - 11:19 PM
#15
Posted 10 April 2012 - 03:20 AM
Yes for the playersorry, i was under the assumption you knew what your current code does. You DO have a working gravity system in your platform game, correct?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











