Q:
I'm using the blades from Aum in my level. How can I make them come out
of the floor? I want to have them active all the time..up and down.
A:
Replace action slicing_blades with the one below:
action
slicing_blades
{
my.enable_impact = on;
my.enable_entity = on;
my.enable_push = on;
my.push = -5;
my.event = kill_player;
my.skill10 = my.z;
while (1)
{
while (my.z < my.skill10 + 300)
{
my.z += 15 * time;
wait (1);
}
while (my.z > my.skill10 - 300)
{
my.z -= 15 * time;
wait (1);
}
wait (1);
}
}
Q:
I like the tank code in Aum21 and I want to improve the AI for the enemy
tanks. How can I compute the tilt angle for their turrets if I know the
distance to the player?
A:
Here's the formula that describes the range of an object thrown at angle
theta when the speed is known. The biggest distance is obtained with theta
(tilt) = 45 degrees; g = earth gravity .
Q:
How can I make entity1 to look at entity2?
A:
Use this piece of code:
vec_set
(temp.x, entity2.x);
vec_sub
(temp.x, entity1.x);
vec_to_angle
(entity1.pan, temp);
Q:
I need some code for a fighting game. The camera should look to a point
between the player and the enemy.
A:
Here's your code; it includes 2 entities that can move with the keys AS
and KL:
// place this line at the end of main: set_camera();
function set_camera();
entity*
karate_kid;
entity*
karate_granny;
action
kid
{
karate_kid = me;
while (1)
{
if (key_a == 1) {my.x -= 30 * time;}
if (key_s == 1) {my.x += 30 * time;}
wait (1);
}
}
action
granny
{
karate_granny = me;
while (1)
{
if (key_k == 1) {my.x -= 30 * time;}
if (key_l == 1) {my.x += 30 * time;}
wait (1);
}
}
function
set_camera()
{
camera.pan += 90;
camera.tilt -= 15;
while ((karate_kid == null) || (karate_granny == null)) {wait (1);}
while (1)
{
camera.x = (karate_kid.x + karate_granny.x) / 2;
camera.y = min(karate_kid.y, karate_granny.y) - vec_dist (karate_kid.x,
karate_granny.x) - 400;
camera.z = 200;
wait (1);
}
}
Q:
I would like to load several levels using different strings that are set
at runtime. Is this possible?
A:
Sure. The code below should get you started:
string
office_wmb = <office.wmb>;
string
test_str;
//
the lines below should go in main
str_cpy
(test_str, office_wmb);
level_load(test_str);
Q:
How can I backup my flags and skills, before I do a level change?
A:
Place me = null;
in any action or function and it will continue to run during and after
the level change.
Q:
Does the file packer pack everything into one file, or can you set it up
to create multiple files?
A:
You can have several resource files. Create a wdl file and use bind
<resource_name.extension>; for all the
entities that will appear in the wrs file. Open Wed, click File - New and
then File - Map properties. Choose your newly created wdl file and resource
the project.
Q:
Why and how should I use trigger_range and event_trigger?
A:
Event_trigger will run when 2 objects move closer to each other; trigger_range
sets the distance that will trigger the event. Here's an example:
function alarm();
action
trigger_me
{
my.enable_trigger = on;
my.trigger_range = 300;
my.event = alarm;
}
function
alarm()
{
if (event_type == event_trigger)
{
beep;
}
}