Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 4 1 2 3 4
Re: Falling Damage [Re: Ruben] #457007
12/18/15 20:26
12/18/15 20:26
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Originally Posted By: Ruben
Code:
action player_code()
{
   ...
   if(my.GRAVITY_VAR < -3.80)
   {
      beep(); // BEEP IS WORKING WHEN PLAYER IS FALLING,
              //    BEEPING LIKE CRAZY WHEN PLAYER FALLS

      timer(); // TIMER SHOULD START WHEN PLAYER FALLS
				
      if(my.GRAVITY_VAR >= -3.80)
      {
         time_elapsed = timer(); // TIMER SHOULD END WHEN 
                                 //    PLAYER LANDS ON GROUND,
                                 //    AND RECORD TIME IN
                                 //    time_elapsed VARIABLE
      }
   }
   ...
}



Aside from the pointed out nested "<" ">=" (which excludes the nested if from ever happening), I'll give you a tip on using these methods in a better way.
Making your gravity function separate from your player function gives you another possibility, to nest a while loop inside it.
Or even, separating the counting time function from the gravity function will still keep the gravity active while looping in its own while loop to count...

Meaning:
Code:
function fallTimeCounter() {
    while(1) {
        if( my.GRAVITY_VAR < -3.80 ) {
            timer();
            while( my.GRAVITY_VAR < -3.80 ) {
                wait(1);
            }
            time_elapsed = timer();
        }
        wait(1);
    }
}



Calling this in the beginning of your player or gravity function will make it work parallel to your gravity or player functions without interrupting them, but still counting the fall time.

Make sure that time_elapsed is a globally defined variable! (or a player skill, if you don't want global stuff.)


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Falling Damage [Re: EpsiloN] #457008
12/18/15 23:15
12/18/15 23:15

M
Malice
Unregistered
Malice
Unregistered
M



you don't need a timer so to say
Code:
var t_start=0;
var t_end=0;
var time_elapsed=0;

funcrion blah()
{

.....if(is==falling_start)
{
 if(!t_start)
  t_start=total_secs;

}
if( stopped == falling)
{
t_end=total_secs;
time_elapsed=t_end-t_start;
t_start = 0;
}



You should not need a measure smaller then 1 second, however if you feel you do, total_tick can be used and 16 ticks == 1 second.

lol

Last edited by Malice; 12/18/15 23:20.
Re: Falling Damage [Re: ] #457009
12/18/15 23:45
12/18/15 23:45

M
Malice
Unregistered
Malice
Unregistered
M



now lets use simple logic for falling and end of falling

Code:
vars...

function blah()
{
var last_z=0;
.....
while(..)
{
...... 
last_z=my.z;
c_trace(....)
if(a drop below)
grav = -50*time_step;
else
grav = 0;

c_move(....vector(x,x,grav)..)
if(grav) // unneeded check
if(my.z<last_z) // did the player drop?
{
if(last_z-my.z == grav) // did you fall unchecked
 // or
if(last_z-my.z > some measure) // did you drop more then a foot step??
{
  in_air = TRUE;
  if(!t_start)
  t_start=total_secs;
}
}
if(!grav) // c_trace found ground
{
if(my.z >= last_z)
{
  if(t_start)
{
  in_air = FALSE;
  t_end=total_secs;
  time_elapsed=t_end-t_start;
  t_start=0;
}
}
my.health -=time_elapsed*my.fall_damage;
time_elapsed=0;
}
}
}



Blah blah blah.... You'll never really learn this way. Blah Blah, I'm a lite-c vampire Blah Blah

lol

Last edited by Malice; 12/18/15 23:53.
Re: Falling Damage [Re: ] #457011
12/19/15 08:01
12/19/15 08:01
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Originally Posted By: Malice
you don't need a timer so to say

Yes. I only meant to point out to him that a separate function will run in parallel while counting laugh the actual implementation depends on the programmer's experience and preference and surrounding code.

This is why I suggested he starts from scratch. laugh We can give him 10 different ways, but while he's keeping his whole function a secret, nobody can help him but the author of this function...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Falling Damage [Re: EpsiloN] #457016
12/19/15 20:39
12/19/15 20:39

M
Malice
Unregistered
Malice
Unregistered
M



Quote:
We can give him 10 different ways, but while he's keeping his whole function a secret, nobody can help him but the author of this function...


I'm trying to help him ..lol

Glad you see the top secret crap too. It's like he got his hands on someone else's HDD full of code, no sure who.... wink
Quote:
This is why I suggested he starts from scratch.

Cut and paste and hack and mod, is a good way to play with code and learn. But a terrible way to create a project. Hell I've hacked up Superku's code and more the older examples. But not because line x and line y cause effect z. There are still pieces of code Super has given me that I never use, because I don't use others idea of code till I understand it.
If you do not understand both the actual actions in a lines of code and the governing logic, you can not effectively use them in any implementation. You can play and test to figure these things out.
Having no idea HOW a piece of code does, only WHAT it's end effect is, then plugging play and hack and mod is foolish.

Last edited by Malice; 12/19/15 20:45.
Page 4 of 4 1 2 3 4

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