New engine features

Top  Previous  Next

key_pressed improvements

 

The improved key_pressed instruction now also allows you to reset all keys to their non-pressed state; this can be useful if your computer is waking up from standby mode, for example.

 

function keyspressed_startup()

{

       var f1_pressed = 0;

       while (1)

       {

               // this loop will run for as long as the F1 key is pressed

               while(key_pressed(59))

               {

                       f1_pressed = 1;

                       if (integer(random(300)) == 290) // random(300) = 290? Then let's reset key_pressed!

                               key_pressed(-1); // this instruction gets us out of the loop, even though we continue to keep the F1 key pressed

                       wait(1);

               }

               if (f1_pressed) // we got out of the loop here

               {

                       beep();

                       beep();

               }

               wait (1);

       }

}

 

 

intern_collision flag improvements

 

The intern_collision flag, which is used by the pXcon_add instruction, now also works for 6D joints.

 

 

pX_stats

 

This new function returns the number of registered physics entities.

 

var num_ents;

 

PANEL* counter_pan =

{

       pos_x = 40;

       pos_y = 10;

       layer = 15;

       digits(45, 90, "Number of physics entities: %.f", *, 1, num_ents);

       flags = SHOW;

}

 

function count_physents()

{

       num_ents = pX_stats(1);

}

 

function go_startup()

{

       on_c = count_physents; // press the "C" key to display the number of physics-based entities

}