action
avi_trigger
{
my.passable = on;
while (player == null) {wait (1);}
while (vec_dist(my.x, player.x) > 100) {wait (1);}
media_play("test.avi", null, 100);
}
F:
Ich benutze Ihr Dart Spiel aus Aum23. Wie kann ich verhindern, dass mehrere
Darts geworfen werden, wenn der Spieler die Maus mehrmals schnell hintereinander
betätigt?
A:
Nehmen Sie diese Zeile aus der Funktion stop_dart():
number_of_darts += 1; // another dart was fired
und schreiben Sie sie in die Main Funktion:
function
main()
{
camera.arc = 60; // normal field of view (fov)
fps_max = 30; // no need to have over 30 fps
level_load (board_wmb);
wait (2);
mouse_map = mouse_pcx; // it's a 2d dart picture
mouse_mode = 2; // the mouse can move freely
mouse_pos.x = 372; // center of the screen
mouse_pos.y = 272; // we substract 28 pixels = mouse pointer / 2
while (1)
{
if (key_t == 1) // press and hold "T" to get rid of the random dart movement,
just for calibration
{
mouse_pos.x = pointer.x; // "normal" mouse movement
mouse_pos.y = pointer.y;
}
else
{
counter += 1;
if (counter == 1) // set a random target then wait until it was reached
{
random_x = 20 - int(random(40)); // generate random numbers only once
random_y = 20 - int(random(40)); // generate integer random numbers
}
if (mouse_pos.x < pointer.x + random_x) {mouse_pos.x += 1;} // move
the mouse in the direction
if (mouse_pos.x > pointer.x + random_x) {mouse_pos.x -= 1;} // of the random
target
if (mouse_pos.y < pointer.y + random_y) {mouse_pos.y += 1;} // on x
and y
if (mouse_pos.y > pointer.y + random_y) {mouse_pos.y -= 1;}
if ((mouse_pos.x == pointer.x + random_x) && (mouse_pos.y == pointer.y
+ random_y)) // if the random target was reached
{
counter = 0; // generate a new pair of random numbers
}
}
if (mouse_left == 1 && number_of_darts < 5) // if we fire a
new dart and we haven't fired all the darts yet
{
while (mouse_left == 1) {wait (1);} // wait until we release the left mouse
button - disable autofire
number_of_darts += 1; // another dart was fired
dart_coords.x = mouse_pos.x + 28; // 28 = mouse pointer bitmap / 2
dart_coords.y = mouse_pos.y + 28;
dart_coords.z = 100; // 100 quants in front of the screen
vec_for_screen(dart_coords, camera); // change 2d coords to 3d coords
ent_create(dart_mdl, dart_coords, move_dart); // create the dart
}
wait (1);
}
}
F:
Wie kann man einen Balken oben links im Bildschirm anzeigen, der darstellt,
wieviel Rüstung übrig ist (wie ein Gesundheitsbalken)?
A:
Benutzen Sie diesen Code:
bmap armor_pcx = <armor.pcx>;
panel
armor_pan
{
pos_x = 0;
pos_y = 0;
layer = 10;
hbar = 5, 20, 100, armor_pcx, 1, player._armor;
flags = overlay, refresh, visible;
}
F:
Wie kann ich die Egoperspektive beibehalten, ohne dass sie gewechselt wird,
wenn der Spieler F7 drückt?
A:
Schreiben Sie diese Zeile in Ihre Main Funktion:
on_f7
= null;
F:
Wie kann ich ein Panel auf den Bildschirm bringen, das automatisch die
Quelldatei ändert, wenn die Auflösung sich ändert (640,
800 oder 1024 Pixel)?
A:
Mit Hilfe dieses Codes:
bmap
p640_pcx = <p640.pcx>;
bmap
p800_pcx = <p800.pcx>;
bmap
p1024_pcx = <p1024.pcx>;
panel
auto_pan
{
bmap = p640_pcx;
pos_x = 0;
pos_y = 0;
layer = 10;
flags = overlay, refresh, visible;
}
starter
change_pans()
{
while (1)
{
if (video_mode == 6) // 640 x 480 pixels
{
auto_pan.bmap = p640_pcx;
}
if (video_mode == 7) // 800 x 600 pixels
{
auto_pan.bmap = p800_pcx;
}
if (video_mode == 8) // 1024 x 768 pixels
{
auto_pan.bmap = p1024_pcx;
}
wait (1);
}
}
F:
Ich würde gern mit Hilfe der “R” Taste meine Waffen nachladen. Wie
geht das?
A:
So:
function
reload_weapons()
{
while (key_r == 1) {wait (1);}
ammo1 = 100; // give 100 bullets for the weapon that uses ammo1
ammo2 = 50; // give 50 bullets for the weapon that uses ammo2
......... // and so on
}
on_r reload_weapons;
F:
Ich erstelle ein Spiel und brauche ein Geräusch, wenn der Spieler
mit einem Block kollidiert, aber das Geräusch bleibt erhalten, während
der Spieler am Block steht. Wie kann ich das ändern, so dass es nur
einmal abgespielt wird, wenn man eine Wand trifft?
A:
Benutzen Sie diesen Code:
sound crash_wav = <crash.wav>;
function crash_event;
action
players_car
{
my.enable_block = on;
my.event = crash_event;
.................................
}
function
crash_event()
{
if (event_type == event_block)
{
snd_play (crash_wav, 50, 0);
my.event = null; // stop the event triggering
sleep (5); // for 5 seconds;
my.event = crash_event; // enable the event again
}
if (event_type == .........)
{
.............................
}
}
F:
Ich weiß nicht, wie ich die Breite und Höhe meiner Schriftart
definieren soll. Kann jemand helfen?
A:
Wenn ein Buchstabe z.B. 19 x 22 Pixel groß ist, sollte die Bitmap
dafür 19 * 32 x 22 * 4 = 608 x 88 Pixel groß sein. Es gibt nämlich
32 Spalten und 4 oder 8 Zeilen.
font my_font = <mybitmap.pcx>, 19, 22;
F:
Ich arbeite mit vielen Panels auf dem Bildschirm und möchte sie bewegen
können. Kann ich irgendwie herausfinden, welches Panel angeklickt
wurde?
A:
Das nächste Update (A6.1) enthält einen Panel Zeiger. Lesen Sie
mehr darüber in “Hot Features”, zusammen mit einem Beispiel.