|
Fragen aus dem Forum |
Top Previous Next |
|
F: Ist es möglich, einen View auf ein Target wie etwa ein Modell, eine Textur oder eine bmap zu rendern? Ich würde das beispielsweise gerne für einen Spiegel benutzen. A: Sicher, schauen Sie hier:
ENTITY* mirrorsprite;
VIEW* mirror_view;
action mirror_sprite() // attach this action to a sprite / model that will be used for the mirror { mirrorsprite = my; set (my, PASSABLE | DECAL); }
function mirror_startup() { while (!mirror_sprite) {wait (1);} mirror_view = view_create(10); // set the layer value for the new view to 10 wait (2); set (mirror_view, SHOW); mirror_view.size_x = 128; mirror_view.size_y = 128; // the mirror sprite has 128x128 pixels mirror_view.bmap = bmap_for_entity(mirrorsprite, 0); vec_set(mirror_view.x, vector(1000, 500, 100)); // set the position of the mirror "eye" vec_set(mirror_view.pan, vector(0, -10, 0)); // set the angles of the mirror "eye" }
F: Gibt es eine Möglichkeit, einen View in einem Kreis auszuschneiden? Ich würde das gerne für Cut-Szenen im Cartoonstil benutzen, rechteckige Views sehen nach einer Weile langweilig aus... A: Verwenden Sie ein rundes Modell und rendern Sie den View auf dessen Skin. So wie im Beispiel unten:
VIEW* cutscene_view;
ENTITY* cutscene_model = { x = 100; // tweak these values until you set the desired position and size of the circular view y = -40; z = 20; type = "teler.mdl"; // use your own model name here layer = 20; flags2 = SHOW; // show the model }
function cut_scene_startup() { while (!cutscene_model) {wait (1);} cutscene_view = view_create(10); // set the layer value for the view to 10 wait (2); set (cutscene_view, SHOW); // the view will have 256x256 pixels; increase these values and the skin of the model if you need a higher resolution cutscene_view.size_x = 256; cutscene_view.size_y = 256; cutscene_view.bmap = bmap_for_entity(cutscene_model, 0); cutscene_view.arc = 90; // play with this value vec_set(cutscene_view.x, vector(30, 120, -175)); // set the position of the cutscene view "eye" vec_set(cutscene_view.pan, vector(0, 10, 0)); // set the angles of the cutscene "eye" }
F: Wie mache ich es, daß meine Levelblocks ihre Schatten dynamisch unter Verwendung von sun_light und sun_color verändern? A: Die Shadow-Maps für die Levelblocks werden erstell, wenn Sie das Level "builden", sie lassen sich also nicht zur Laufzeit verändern. Um sie alle zu beeinflussen, verwenden Sie camera.ambient oder verwenden Sie Modelle für Ihre Level - diese reagieren auf sun_light und sun_color.
F: Ich muß, wenn mein Player ein Objekt berührt, ein Bild darstellen. Wie kriege ich das hin? Ein Beispiel wäre hilfreich. A: Bitteschön:
BMAP* pointer_tga = "pointer.tga";
PANEL* temp_pan;
function mouse_startup() { mouse_mode = 2; mouse_map = pointer_tga; while (1) { vec_set(mouse_pos, mouse_cursor); wait(1); } }
function tooltips_startup() { var panel_on = 0; while (1) { if (mouse_ent) { // use different skill1 values and expand this piece of code if you want to display different images for different entities if (mouse_ent.skill1 == 1) { if (panel_on == 0) // the image isn't visible already? Then let's create it! { panel_on = 1; temp_pan = pan_create("bmap = circle.tga;", 10); // create a panel that uses the circle.tga bitmap and has a layer of 10 temp_pan.pos_x = 30; // set your desired pos_x and pos_y values for the panel temp_pan.pos_y = 50; temp_pan.flags |= SHOW; // and then make it visible } } } else // the mouse pointer didn't touch any entity? { if (panel_on == 1) // the panel was created? (no need to remove it more than once) { panel_on = 0; // reset panel_on ptr_remove(temp_pan); // and then let's remove the panel } } wait (1); } }
F: Kann irgendjemand mir ein Tutorial über das Erstellen einer Textbox geben? Ich brauche eine Textbox zum Abfragen des Playernamens. A: Hier ist ein Beispiel, das ein Panel als Hintergrundbitmap benutzt und einen Text zur Eingabe:
BMAP* pointer_tga = "pointer.tga";
STRING* name_str = "Click to input your name";
function input_name();
TEXT* name_txt = { pos_x = 300; pos_y = 50; layer = 20; string(name_str); flags = SHOW; }
PANEL* input_pan = // used only as a background for the text box { bmap = "hud.tga"; pos_x = 280; pos_y = 40; layer = 10; on_click = input_name; flags = SHOW; }
function input_name() { while (mouse_left) {wait (1);} // wait until the player releases the mouse button str_cpy(name_str, "#50"); // reset the input string inkey(name_str); // let's input player's name }
function mouse_startup() { mouse_mode = 2; mouse_map = pointer_tga; while (1) { vec_set(mouse_pos, mouse_cursor); wait(1); } }
F: Ich wüßte gerne wie man Wolken mit Partikeln macht. A: Hier ein einfaches Beispiel.
BMAP* cloud_tga = "cloud.tga";
function fade_cloud(PARTICLE *p) { p.lifespan = 100; // comment this line to have the coulds disappear after a few seconds and // p.alpha -= 0.1 * time_step; // remove the comments for these 2 lines to have the clouds fade away as the time passes // if (p.alpha < 0) {p.lifespan = 0;} }
function cloud_particle(PARTICLE *p) { p->vel_x = 0.9 * (1 - random(2)); // slightly random p->vel_y = 0.8 * (1 - random(2)); // horizontal speed p->vel_z = 0.5 * (1 - random(2)); // and vertical speed p.alpha = 30 + random(40); // cloud transparency, play with this value p.bmap = cloud_tga; p.size = 150 + random(50); // slightly random cloud size p.flags |= (BRIGHT | MOVE); p.event = fade_cloud; }
// Attach this action to several entities placed up high in the sky - they will become your invisible cloud generators action cloud_particles() { set (my, INVISIBLE); var i; VECTOR temp; for (i = 0; i < 100; i++) // generate 100 clouds for each entity { temp.x = my.x + 500 - random(1000); temp.y = my.y + 500 - random(1000); temp.z = my.z - 100 + random(200); effect (cloud_particle, 1, temp.x, normal); } }
F: Ich möchte ein Tag- / Nacht-Himmelssystem erstellen, das sich in Echtzeit verändert. Kann mir jemand helfen? A: Hier ein einfaches und doch voll funktionierendes Beispiel:
ENTITY* my_sky;
function sky_startup() { my_sky = ent_createlayer("skycube+6.tga", SKY | CUBE | SHOW, 1); while (1) { // allow the sky colors to change from 1 to 255 my_sky.red = 128 + 127 * sin(total_ticks * 0.003); // 0.003 gives the day / night transition speed my_sky.green = my_sky.red; my_sky.blue = my_sky.red; wait (1); } }
F: Ist es mithilfe von c_scan möglich, zu prüfen ob eine bestimmte Entity gefunden wurde? Es gibt nur einen "you"-Pointer und wenn ich diverse Entities im Level habe, kann ich nicht sagen, ob die Entity, an der ich interessiert war, entdeckt wurde oder nicht. A: Bittesehr:
TEXT* normal_txt = { pos_x = 100; pos_y = 30; string("Normal entity detected!"); }
TEXT* special_txt = { pos_x = 300; pos_y = 30; string("Special entity detected!"); }
function got_scanned() { while (event_type == EVENT_SCAN) { if (my.skill99 == 1) // I'm the special entity? { set(special_txt, SHOW); } else // detected one of the regular entities? { set (normal_txt, SHOW); } wait (1); } reset (normal_txt, SHOW); reset (special_txt, SHOW); }
action my_regular_entities() // attach this action to your regular entities { my.emask |= ENABLE_SCAN; // make the entity sensitive to scanning my.event = got_scanned; }
action my_special_entity() // attach this action to your special entity { my.skill99 = 1; // this makes your entity special (different) my.emask |= ENABLE_SCAN; // make the entity sensitive to scanning my.event = got_scanned; }
action players_code() // simple player / camera code, includes scanning 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
// the following line makes the player scan up to 300 quants around it c_scan(my.x, my.pan, vector(360, 180, 300), IGNORE_ME); wait (1); } }
F: Wie kann ich in meinem Game ein Panel über einer Entity platzieren? pos_x = entity.x kann ich nicht benutzen, denn wenn die Position 2500 ist, liegt das Panel ausserhalb meines Bildschirms. A: Bitteschön:
PANEL* temp_pan;
action panel_guy() // attach thi action to the entity that should display the panel above its head { wait (-3); var anim_percentage; VECTOR temp_pos; temp_pan = pan_create("bmap = block.pcx;", 10); // create a panel that uses the block.pcx bitmap and has a layer of 10 temp_pan.flags |= SHOW; // and then make it visible while (1) { c_move (my, vector(5 * time_step, 0, 0), nullvector, GLIDE); // "5" controls the walking speed my.pan += 4 * time_step; // this line makes the entity walk in a circle ent_animate(my, "walk", anim_percentage, ANM_CYCLE); anim_percentage += 4 * time_step; // "4" controls the "walk" animation speed
vec_set (temp_pos, my.x); // copy the xyz coordinates of the entity to temp_pos temp_pos.z += 60; // play with this value, sets the distance between the entity's origin and the panel vec_to_screen (temp_pos, camera); // convert the 3D position to 2D screen coordinates temp_pan.pos_x = temp_pos.x; // and then set the position of the text temp_pan.pos_y = temp_pos.y; // on x and y wait (1); } }
F: Ich habe diverse Panels mit individuellen Pointern und ich muß deren Position uniform verändern. Gibt es irgendeine Möglichkeit zum Schreiben einer Gruppierungsfunktion, so daß ich nicht für jedes Panel ein separates pos_x / pos_y schreiben muß? A: Hier ein Schnipsel, das durch alle Panels durchgeht (Sie brauchen ihnen noch nicht einmal Pointer zuzuweisen) und ihre pos_x- und pos_y-Werte nach Ihren Erfordernissen verändert:
PANEL* next_pan;
PANEL* panel_test = { layer = 15; pos_x = 300; pos_y = 200; bmap = "test.tga"; flags = SHOW; }
PANEL* panel_test2 = { layer = 15; pos_x = 400; pos_y = 250; bmap = "test.tga"; flags = SHOW; }
PANEL* panel_test3 = // feel free to add as many panels as you want { layer = 15; pos_x = 500; pos_y = 300; bmap = "test.tga"; flags = SHOW; }
// go through all the panels function move_panels(offset_x, offset_y) { next_pan = ptr_first(panel_test); while (next_pan) { next_pan.pos_x += offset_x; next_pan.pos_y += offset_y; next_pan = next_pan.link.next; } }
function move_startup() { while (1) { if (key_1) { while (key_1) {wait (1);} move_panels(20, 40); // add 20 pixels on the x axis and 40 pixels on the y axis to all the panels } wait (1); } }
|