|
Fragen aus dem Forum |
Top Previous Next |
|
F: Ich möchte gern den Überwachungskamera-Code aus AUM 10 modifizieren. Wenn der Spieler vor einem Monitor steht und diesen aktiviert, sollte der Code zwischen den Kamera hin- und herschalten. A: Hier ist ein Beispiel, das mit 3 Kameras funktioniert - verwenden Sie dieses als Basis für Ihren eigenen Code.
view surv_camera {}
function initcam_startup() { surv_camera.size_x = screen_size.x; // surv_camera has the same size and position surv_camera.size_y = screen_size.y; // like the original "camera" surv_camera.pos_x = 0; surv_camera.pos_y = 0; }
action camera_trigger // place several entities in the level and attach them this action { while (!player) {wait (1);} while (1) { my.skill10 = abs(ang(player.pan) - ang(my.pan)); // angle between the player and the camera trigger if ((vec_dist(player.x, my.x) < 100) && (my.skill10 > 150) && (my.skill10 < 210)) // if the player looks at the trigger { camera.visible = off; // hide the default "camera"
surv_camera.x = 100; // use your own x, y, z, pan, tilt, roll values here surv_camera.y = 200; surv_camera.z = 300; surv_camera.pan = 50; surv_camera.tilt = -30; surv_camera.roll = 0; surv_camera.visible = on; // and make it visible while (!key_ctrl) // press the "Ctrl" key to switch to the second camera { if (vec_dist (player.x, my.x) > 150) {break;} wait (1); } while (key_ctrl) {wait (1);} // now wait until the "Ctrl" key is released
surv_camera.x = 400; // use your own x, y, z, pan, tilt, roll values here surv_camera.y = -100; surv_camera.z = 230; surv_camera.pan = 150; surv_camera.tilt = -10; surv_camera.roll = 0; surv_camera.visible = on; while (!key_ctrl) // press the "Ctrl" key to switch to the second camera { if (vec_dist (player.x, my.x) > 150) {break;} wait (1); } while (key_ctrl) {wait (1);} // now wait until the "Ctrl" key is released
surv_camera.x = 1200; // use your own x, y, z, pan, tilt, roll values here surv_camera.y = -500; surv_camera.z = 50; surv_camera.pan = 30; surv_camera.tilt = 40; surv_camera.roll = 0; surv_camera.visible = on; while (!key_ctrl) // press the "Ctrl" key to switch to the second camera { if (vec_dist (player.x, my.x) > 150) {break;} wait (1); } while (key_ctrl) {wait (1);} // now wait until the "Ctrl" key is released
} else // the player has moved away from the camera trigger { surv_camera.visible = off; camera.visible = on; my.skill11 += 1; while (!key_ctrl) {wait (1);} while (key_ctrl) {wait (1);} } wait (1); } }
F: Wie kann ich ein Objekt um einen bestimmten Punkt im Level kreisen lassen? A: Plazieren Sie eine Entity an diesem Punkt und geben Sie dieser die folgende Action.
action object_orbits { var orbit_radius = 200; // use your own value here var orbit_speed = 4; // and here var temp_angle; var orbit_center; vec_set (orbit_center.x, my.x); // store the orbit center position while(1) { my.x = orbit_center.x + sin(temp_angle) * orbit_radius; my.y = orbit_center.y + cos(temp_angle) * orbit_radius; my.z = orbit_center.z; temp_angle += orbit_speed * time_step; wait(1); } }
F: Wie kann ich den Mauszeiger Partikel emittieren lassen? A: Hier ist ein Beispiel.
BMAP arrow_pcx = "arrow.pcx"; BMAP snow_tga = "snow.tga";
function mouse_startup() { mouse_mode = 2; mouse_map = arrow_pcx; while (1) { vec_set(mouse_pos, mouse_cursor); wait(1); } }
function fade_part() { my.ALPHA -= 15 * time_step; if (my.ALPHA < 0) {my.LIFESPAN = 0;} }
function mouse_particles() { var particle_direction; particle_direction.x = 0.2 * (random(1) - 2); particle_direction.y = 0.2 * (random(1) - 2); particle_direction.z = 0.1 * random(1); vec_add(my.VEL_X, particle_direction); my.ALPHA = 30 + random(65); my.FLARE = ON; my.BMAP = snow_tga; my.SIZE = 0.5; my.BRIGHT = ON; my.MOVE = ON; my.FUNCTION = fade_part; }
function particles_startup() { var particle_origin; while (1) { particle_origin.x = mouse_pos.x; particle_origin.y = mouse_pos.y; particle_origin.z = 40; vec_for_screen (particle_origin, camera); effect(mouse_particles, 1, particle_origin.x, normal); wait (1); } }
F: Ich möchte gern ein Video aus meinem Spiel aufnehmen und auf meiner PSP abspielen. Wie kann ich Acknex mit der entsprechenden Auflösung laufen lassen? A: Hier ist ein Beispiel. Sie benötigen noch ein Programm, welches das Video zur Laufzeit aufnimmt.
function switch_psp() { video_set(480, 272, 32, 2); // switch to 480x272 pixels, 32 bits, window mode }
on_p = switch_psp; // press the "P" key to switch to PSP mode
F: Ich möchte, dass die Kamera in einer Endlosschleife einem Pfad folgt. Wie geht das? A: Erstellen Sie einen Pfad im WED, plazieren Sie ein Model namens dummy.mdl in Ihrem Verzeichnis und geben Sie diesem die Action dummy_target.
var cam_speed = 1; // initial speed var dist_to_node; var current_node = 1; var angle_difference = 0; var temp_angle; var pos_node; // stores the position of the node
ENTITY* dummy_ent;
function move_dummy() { my.PASSABLE = ON; my.INVISIBLE = ON; while (1) { vec_set (my.x, you.x); wait (1); } }
function move_target() { while(1) { cam_speed = minv(15, cam_speed + 5 * time_step); // 15 gives the movement speed c_move(my, vector(cam_speed * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE); vec_to_angle (dummy_ent.pan, vec_diff (temp_angle, pos_node, my.x)); if(my.pan != dummy_ent.pan) { angle_difference = ang(dummy_ent.pan - my.pan); my.pan += angle_difference * 0.2 * time_step; } vec_set (camera.x, my.x); camera.pan = my.pan; camera.tilt = my.tilt; wait(1); } }
action dummy_target() { dummy_ent = ent_create ("dummy.mdl", nullvector, move_dummy); move_target(); result = path_scan(me, my.x, my.pan, vector(360, 180, 1000)); if (!result) {return;} path_getnode (my, 1, pos_node, NULL); vec_to_angle (my.pan, vec_diff (temp_angle, pos_node, my.x)); // rotate towards the node vec_to_angle (dummy_ent.pan, vec_diff (temp_angle, pos_node, my.x)); // rotate dummy_ent towards the node as well while (1) { dist_to_node = vec_dist(my.x, pos_node); if(dist_to_node < 300) // close to the node? { current_node = path_nextnode(my, current_node, 1); if (!current_node) {current_node = 1;} // reached the end of the path? Then start over! path_getnode (my, current_node, pos_node, NULL); } wait(1); } }
F: In einer 3rd Person Umgebung, bei der man gern anzeigen möchte, was der Spieler trägt, wie geht man dies an? Waffen, Rüstung, Haare, Kleidung etc. Noch besser, wie bringt man all diese Dinge am besten zusammen? A: Sehen Sie sich die Morrowing Serie aus den Ausgaben AUM 46 - AUM 50 an, um ein einfaches, funktionierendes Inventar zu sehen. Animieren Sie Ihren Charakter zusammen mit den Items, die er tragen soll und speichern Sie dann den Spieler und die Items als separate Models ab - auf diese Weise sind sie immer synchronisiert.
F: Mein Lernspiel verwendet 227 Panels, aber nicht alle zugleich. Wie kann ich Videospeicher sparen? Momentan werden etwa 160 MB gebraucht. A: Verwenden Sie pan_create, um die Panels zu erzeugen, wenn Sie diese brauchen und pan_remove um sie zu entfernen, wenn sie nicht mehr gebraucht werden.
PANEL* new_panel1; PANEL* new_panel2;
function panels_startup() { sleep (5); // wait for 5 seconds // now create and display the first panel; its layer is set to 10 new_panel1 = pan_create("bmap = test1.pcx; pos_x = 150; pos_y = 40; flags = OVERLAY | VISIBLE;", 10); sleep (3); // display the first panel for 3 seconds pan_remove (new_panel1); // now remove the panel from the memory sleep (2); // wait for 2 seconds // now create and display the second panel; its layer is set to 15 new_panel2 = pan_create("bmap = test2.pcx; pos_x = 50; pos_y = 140; flags = OVERLAY | VISIBLE;", 15); sleep (4); // display the second panel for 4 seconds pan_remove (new_panel2); // now remove the panel from the memory }
F: Ist es möglich, den Mauszeiger zu ändern, wenn er über einem bestimmten Panel ist? A: Sicher! Nehemn wir an, das Panel befindet sich bei x = 600 und y = 20 und ist 100 Pixel breit und 50 Pixel hoch. Unter diesen Bedingungen sieht der Code folgendermaßen aus:
BMAP arrow1_pcx = "arrow1.pcx"; BMAP arrow2_pcx = "arrow2.pcx";
function mouse_startup() { mouse_mode = 2; while (1) { vec_set(mouse_pos, mouse_cursor); if ((mouse_pos.x > 600) && (mouse_pos.x < 700) && (mouse_pos.y > 20) && (mouse_pos.y < 70)) { mouse_map = arrow2_pcx; } else { mouse_map = arrow1_pcx; } wait(1); } }
F: Ich frage mich, wie man eine Sounddatei in einer Schleife abspielt, während ein Titelbild angezeigt wird. Ich möchte, dass die Datei nicht endet bis die Leertaste das Spiel startet. A: Hier ist ein Beispiel.
var intro_playing;
PANEL splash_pan = { bmap = "splash.pcx"; pos_x = 0; pos_y = 0; layer = 15; flags = VISIBLE; }
function splash_startup() { intro_playing = media_loop("intro.wav", NULL, 80); // play intro.wav in a loop while (!key_space) {wait (1);} // wait until the "space" key is pressed while (key_space) {wait (1);} // wait until the "space" key is released media_stop (intro_playing); // now stop the music splash_pan.VISIBLE = OFF; // and hide the splash screen panel // put the rest of your game code here }
F: Ich möchte eine Frage auf dem Bildschirm anzeigen, die Antwort des Spielers erfragen und diese dann abspeichern. A: Hier ist ein Codeausschnitt.
var filehandle;
STRING answer1_str = " "; // accept up to 20 characters STRING answer2_str = " "; // accept up to 20 characters
TEXT name_txt = { layer = 15; pos_x = 250; pos_y = 50; string ("What is your name?"); }
TEXT answer1_txt = { layer = 15; pos_x = 380; pos_y = 50; string (answer1_str); }
TEXT age_txt = { layer = 15; pos_x = 250; pos_y = 50; string ("How old are you?"); }
TEXT answer2_txt = { layer = 15; pos_x = 380; pos_y = 50; string (answer2_str); }
function answers_startup() // gets the user's data and stores it inside the answers.txt file { sleep (3);
name_txt.visible = ON; answer1_txt.visible = ON; inkey(answer1_str); name_txt.visible = OFF; answer1_txt.visible = OFF;
age_txt.visible = ON; answer2_txt.visible = ON; inkey(answer2_str); age_txt.visible = OFF; answer2_txt.visible = OFF;
// the answers are stored inside answer1_str and answer2_str, so let's save them filehandle = file_open_write ("answers.txt"); // open the file for writing file_str_write (filehandle, answer1_str); // write the first answer (the name) file_asc_write (filehandle, 13); // write the second answer on a separate row file_asc_write (filehandle, 10); // using these 2 lines of code file_str_write (filehandle, answer2_str); // now write the second answer (the age) file_close (filehandle); // close the file }
|