Source form AUM70

Q: I have a hard time setting the proper size of the entities in my level; is there a possibility to change their size at runtime?

A: Here's an example that changes the size on the z axis for any entity that is touched with the mouse pointer. A panel displays the z scale, which can then be used in Wed.

Code:
BMAP* arrow_pcx = "arrow.pcx";
PANEL* size_pan =
{
       digits(100, 50, 3.3, *, 1, mouse_ent.scale_z);
       flags = visible;
}

function mouse_startup()
{  
  mouse_mode = 2;
  mouse_map = arrow_pcx;
  while (1)
  {  
       vec_set(mouse_pos, mouse_cursor);
       wait(1);
  }
}

function change_entities_startup()
{
       while (1)
       {
               if (mouse_ent) // if the mouse is touching an entity
               {
                       if (key_1) {mouse_ent.scale_z += 0.1 * time_step;}
                       if (key_2) {mouse_ent.scale_z -= 0.1 * time_step;}
               }
               wait (1);
       }
}

action players_code() // simple player and 1st person camera code
{ 
       player = my; // I'm the player
       set (my, INVISIBLE); // no need to see player's model in 1st person mode
       while (1)
       {
               // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed
               c_move (my, vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0), nullvector, GLIDE);
               vec_set (camera.x, player.x); // use player's x and y for the camera as well
               camera.z += 30; // place the camera 30 quants above the player on the z axis (approximate eye level)
               camera.pan -= 5 * mouse_force.x * time_step; // rotate the camera around by moving the mouse
               camera.tilt += 3 * mouse_force.y * time_step; // on its x and y axis
               player.pan = camera.pan; // the camera and the player have the same pan angle
               wait (1);
       }
}





Last edited by wacek; 01/17/10 10:34.