|
Fragen aus dem Forum |
Top Previous Next |
|
F: Haben Sie ein kleines Beispiel für Clipping Range? A: Hier ist eine einfache Funktion mit Clipping, die weißen Nebel benutzt, damit es nicht auffällt.
starter set_clipping() { sleep (1); // wait a bit d3d_fogcolor1.red = 255; // set up white fog d3d_fogcolor1.green = 255; d3d_fogcolor1.blue = 255; fog_color = 1; // and enable it camera.clip_near = 10; // experimental value, play with it camera.clip_far = 10000; // clip everything outside the 10000 quants radius, play with 10000 camera.fog_start = 100; // experimental value, play with it camera.fog_end = 0.95 * camera.clip_far; // put dense fog close to the end of the clipping area }
F: Ich kann die AUM Skripte nicht im Vollbild ausführen, ich erhalte immer ein großes Fenster. Wie ändere ich das? A: Fügen Sie diese Zeile am Anfang des Skriptes ein.
var video_screen = 1;
F: Wie kann ich eine Entity auf eine andere ausrichten, die ein Event auslöste? Die Rotation sollte schrittweise vonstatten gehen und nur den Pan betreffen. A: Hier ist ein Beispiel.
function rotate_me { my.event = null; // trigger a single event while (you != null) { vec_set (temp.x, you.x); vec_sub (temp.x, my.x); vec_to_angle (my.skill40, temp); // use any free skill here my.pan -= ang(my.pan - my.skill40) * 0.1 * time; // 0.1 = rotation speed wait (1); } }
action trigger_me { my.enable_trigger = on; my.trigger_range = 200; my.event = rotate_me; }
F: Ich versuche mich an einem simplen “Sammle 10 Items um zu gewinnen” Spiel, aber ich verstehe nichts vom Coden. Ich möchte es gern so einrichten, dass man ein Geräusch hört, wenn man ein Item einsammelt und hätte gern ein Musikstück und einen Endbildschirm, wenn alle Items gesammelt wurden. A: Hier ist ein Ausschnitt:
var items_to_collect = 10; var items_collected = 0;
sound collected_wav = <collected.wav>; sound completed_wav = <completed.wav>;
bmap completed_pcx = <completed.pcx>;
panel completed_pan { bmap = completed_pcx; layer = 20; flags = overlay, refresh; }
action collectable_item // place 10 objects in the level and assign them this action { my.passable = on; while (player == null) {wait (1);} while (vec_dist (player.x, my.x) > 70) {wait (1);} snd_play (collected_wav, 50, 0); items_collected += 1; my.invisible = on; sleep (2); // wait until the entire sound has been played ent_remove (my); // now we can safely remove the entity }
starter objects_are_collected() { while (items_to_collect != items_collected) {wait (1);} sleep (1); snd_play (completed_wav, 100, 0); completed_pan.visible = on; }
F: Ich habe Stunden damit verbracht herauszufinden, wie man dem Code aus dem Workshop von AUM 52 Code fürs Springen hinzufügt. Können Sie helfen? A: Ersetzen Sie die Action players_code mit der unten gegebenen.
action players_code { var anim_percentage; // animation percentage var jump_percentage; // animation percentage for jumping var movement_speed; // player's movement speed var distance_to_ground; // the distance between player's origin and the ground var jump_height; var reached_height; player = my; // I'm the player while (1) { my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys vec_set (temp.x, my.x); // copy player's position to temp temp.z -= 5000; // set temp.z 5000 quants below player's origin distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box); movement_speed.x = 5 * (key_w - key_s) * time; // move the player using "W" and "S" movement_speed.y = 0; // don't move sideways if ((key_space == on) && (reached_height == 0)) { jump_height = min(40, jump_height + 5 * time); // 40 sets the height, 5 sets the ascending speed if (jump_height == 40) // reached the maximum height? Then start descending! { reached_height = 1; jump_height = max(0, jump_height - 5 * time); // 5 sets the falling speed } } else // space isn't pressed anymore? { jump_height = max(0, jump_height - 3 * time); // use a smaller falling speed (3) for (potential) smaller jumps if ((jump_height == 0) && (key_space == off)) // the player has touched the ground? { reached_height = 0; // then allow it to jump again } } movement_speed.z = - (distance_to_ground - 17) + jump_height; // 17 = experimental value movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed c_move (my, movement_speed.x, nullvector, glide); // move the player if (jump_height == 0) // the player isn't jumping? { if ((key_w == off) && (key_s == off)) // the player isn't moving? { ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation } else // the player is moving? { ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation } anim_percentage += 5 * time; // 5 = animation speed jump_percentage = 0; // always start jumping with the first frame } else // the player is jumping { jump_percentage += 5 * time; // 5 = jump animation speed ent_animate(my, "jump", jump_percentage, anm_cycle); // play the "jump" animation } wait (1); } }
F: Wie kann ich 3DGS prüfen lassen, ob das Spiel mit einem bestimmten Kommandozeilen Parameter gestartet wurde? Wenn dieser fehlt, möchte ich gern ein Panel anzeigen, das dem Spieler mitteilt, dass das Spiel nicht richtig gestartet wurde. A: Hier ist ein Beispiel:
bmap error_pcx = <error.pcx>;
panel error_pan { bmap = error_pcx; flags = overlay, refresh; }
function main() { ifndef hq; // the user didn't start the engine using the "-d hq" = high quality parameter error_pan.visible = on; // tell the user that he has forgotten to start the engine using the "hq" option while (key_any == off) {wait (1);} // wait until the user presses a key exit; // and then shut down the engine ifelse; // the user has used the "hq" command line video_switch(8, 0, 0); // so let's switch to 1024x768 pixels endif; // function main continues here ...................... }
F: Kann man verhindern, dass mein Charakter durch Teile meiner Models geht? Wenn ich einen Tisch mache, geht das Model hindurch bis es einen bestimmten Punkt trifft oder es kann nicht herum gehen, weil eine unsichtbare Barriere im Weg ist. A: Was Sie sehen ist die unsichtbare Bounding Box des Models, die für eine schnelle Kollisionserkennung genutzt wird. Verwenden Sie eine WMB Entity anstelle eines Models für den Tisch oder geben Sie ihm die folgende Action. Vergessen Sie nicht, Ihre Entities mit Hilfe von c_move zu bewegen, andernfalls können Sie nicht die neue, polygonbasierende Kollisionserkennung benutzen.
action proper_collision { my.polygon = on; }
F: Ich habe ein Menü für mein Spiel erstellt, das auch einen “Optionen” Bildschirm hat. Wie kann ich die Einstellungen speichern, damit sie nicht jedes Mal zurückgesetzt werden, wenn das Spiel gestartet wird? A: Hier ist ein Beispiel:
var filehandle; var video_resolution;
// run function save_settings at least once before running load_settings // otherwise, you won't have any settings.txt file to read from function save_settings() // call this function before exiting the game { filehandle = file_open_write("settings.txt"); file_var_write (filehandle, video_mode); // save the video resolution file_asc_write (filehandle, 13); // move on to the following line file_asc_write (filehandle, 10); file_var_write (filehandle, sound_vol); // save the sound volume file_asc_write (filehandle, 13); // move on to the following line file_asc_write (filehandle, 10); file_var_write (filehandle, midi_vol); // save the midi volume file_close(filehandle); // close the file }
// call this from function main() function load_settings() { sleep (1); filehandle = file_open_read("settings.txt"); // open the settings.txt file video_resolution = file_var_read(filehandle); // read the video resolution video_switch(video_resolution, 0, 0); // set the new video resolution sound_vol = file_var_read(filehandle); // set the volume of the sound midi_vol = file_var_read(filehandle); // set the volume of the midi music file_close(filehandle); // close the file; }
F: Ich möchte ein Geräusch mit zufälligen Frequenzänderungen ertönen lassen. Wenn ich das versuche, werden auch die Frequenzen von anderen Geräuschen im Spiel geändert. Wie ändere ich das? A: Schauen Sie sich den Ausschnitt unten an: er enthält einen Sound, der seine Frequenz ändert und einen anderen, der seine Frequenz behält.
sound siren1_wav = <siren1.wav>; sound siren2_wav = <siren2.wav>;
action variable_freq { var sound_handle; sound_handle = ent_playloop (my, siren1_wav, 40); while (1) { snd_tune (sound_handle, 0, (10 + random(290)), 0); // change the frequency from 10% to 300% sleep(1); } }
action fixed_freq { var sound_handle; sound_handle = ent_playloop (my, siren2_wav, 100); }
F: Wie kann man einen Knopf erstellen, der eine Filmsequenz im Vollbildmodus abspielt und dann wenn das Video fertig ist, ein Level lädt? A: Hier ist ein Beispiel:
var movie_handle;
bmap movie_pcx = <movie.pcx>; bmap playmovie1_pcx = <playmovie1.pcx>; bmap playmovie2_pcx = <playmovie2.pcx>;
function play_the_movie();
panel movie_pan { bmap = movie_pcx; layer = 5; button = 50, 150, playmovie2_pcx, playmovie1_pcx, playmovie2_pcx, play_the_movie, null, null; flags = overlay, refresh, visible; }
function play_the_movie() { movie_pan.visible = off; movie_handle = media_play("test.avi", null, 100); while (media_playing (movie_handle) == 0) {wait (1);} // wait until the movie starts playing while (media_playing (movie_handle) != 0) {wait (1);} // wait until the movie has stopped beep; beep; // load your new level here }
|