Most asked questions |
Top Previous Next |
Q: I would like to have a much bigger size digits for my Ammo / Health / Armor panel (original digfont.pcx). How can I achieve such a thing? A: Resize the font in any painting program from 384 x 64 to 1536 x 256 pixels (400 %), save it as digfont2.pcx and then paste the following code inside messages.wdl:
font digitbig_font = <digfont2.pcx>, 48, 64;
panel my_panel { pos_x = 20; pos_y = 20; digits = 0, 380, 3, digitbig_font, 1, show_ammo; digits = 200, 380, 3, digitbig_font, 1, show_health; digits = 400, 380, 3, digitbig_font, 1, show_armor; flags = transparent, refresh, visible; }
starter hide_old_panel() { while (1) { game_panel.visible = off; wait (1); } }
Q: How can I switch and fade between two cameras? A: You need to define a new "view". Place any model in your level, set its angle and position and then attach it the "new_view" action. Press "S" to switch the cameras.
view second_camera { layer = 10; pos_x = 0; pos_y = 0; }
action new_view { my.invisible = on; my.passable = on; second_camera.x = my.x; second_camera.y = my.y; second_camera.z = my.z; second_camera.pan = my.pan; second_camera.tilt = my.tilt; second_camera.roll = my.roll; }
function switch_cameras() { camera.alpha = 100; // no transparency for this camera yet second_camera.alpha = 0; // completely transparent camera.transparent = on; second_camera.transparent = on; second_camera.size_x = screen_size.x; second_camera.size_y = screen_size.y; second_camera.visible = on; while (camera.alpha > 5) { camera.alpha -= 3 * time; second_camera.alpha += 3 * time; wait (1); } camera.visible = off; second_camera.transparent = off; }
on_s = switch_cameras;
Q: I have a game over screen that currently fades in and out until the user presses a key. I was wondering if it was possible to dynamically scale the bmap so that it gave the impression of it going from small to big and back again. A: You need A6.21 or a newer version of the engine to do that. Use the code below.
bmap gameover_pcx = <gameover.pcx>;
panel gameover_pan { bmap = gameover_pcx; pos_x = 0; pos_y = 0; flags = overlay, refresh, visible; }
starter adjust_panel() { while (1) { while (gameover_pan.scale_x > 0.2) { gameover_pan.scale_x -= 0.01 * time; gameover_pan.scale_y -= 0.01 * time; gameover_pan.pos_x = (1 - gameover_pan.scale_x) * bmap_width (gameover_pcx) / 2; gameover_pan.pos_y = (1 - gameover_pan.scale_y) * bmap_height (gameover_pcx) / 2; wait (1); } while (gameover_pan.scale_x < 1) { gameover_pan.scale_x += 0.01 * time; gameover_pan.scale_y += 0.01 * time; gameover_pan.pos_x = (1 - gameover_pan.scale_x) * bmap_width (gameover_pcx) / 2; gameover_pan.pos_y = (1 - gameover_pan.scale_y) * bmap_height (gameover_pcx) / 2; wait (1); } wait (1); } }
Q: Has somebody done any working example playing an avi file on a mdl entity? A: Attach the action "movie_on_model" to your model. Press "M" to play the movie.
action movie_on_model { while (key_m == 0) {wait (1);} // press "M" to play the movie media_play ("highway.avi", bmap_for_entity (my, 0), 100); }
Q: How can I make cursor visible on a panel and allow user to enter string in it? A: You have to use a text and a panel, just like in the example below.
bmap input_pcx = <input.pcx>;
string temp_str = " "; // 20 characters
function input_text();
panel input_pan { bmap = input_pcx; pos_x = 0; pos_y = 0; layer = 10; on_click = input_text; flags = refresh, d3d, visible; }
text my_txt { layer = 20; pos_x = 30; pos_y = 35; font = standard_font; string = temp_str; }
text dummy_txt // displays the text that was input { layer = 20; pos_x = 15; pos_y = 450; font = standard_font; flags = visible; }
function input_text() { if ((mouse_pos.x > 7) && (mouse_pos.x < 215) && (mouse_pos.y > 20) && (mouse_pos.y < 45)) { my_txt.visible = on; str_cpy (temp_str, ""); inkey temp_str; my_txt.visible = off; // got the text in temp_str here dummy_txt.string = temp_str; // show the input text // ................. } }
Q: I would like a code to attach to all decorative entities (plants, trees), so that I can place them in Wed and the code will have them move down vertically so that they are on the terrain A: Attach the action below to every plant, tree, etc.
action smart_vegetation { my.skill1 = random (5) + 1; wait (my.skill1); vec_set (temp, my.pos); temp.z -= 3000; trace_mode = ignore_me + ignore_sprites + ignore_models + use_box; my.z -= trace (my.pos, temp) + 10; // set the correct height (the bottom of the model will sink 10 quants into the soil). }
Q: How can I make a light move throughout a level? I want the light to follow a certain path. A: Create a path named "lightpath", place a model near it and attach it the "moving_light" action.
action moving_light { d3d_lightres = 1; var light_pos; var current_speed; var distance; var acc_speed; var init_speed = 3; // movement speed ent_path("lightpath"); // walk on this path ent_waypoint(light_pos, 1); while (1) { my.lightrange = 300; my.lightred = 200; my.lightgreen = 200; my.lightblue = 200; temp.x = light_pos.x - my.x; temp.y = light_pos.y - my.y; temp.z = 0; if (vec_to_angle (my_angle, temp) < 20) { ent_nextpoint(light_pos); } my.z += 0.1 * (light_pos.z - my.z) * time; current_speed = init_speed; my_angle.pan = ang(my_angle.pan - my.pan); if (abs(my_angle.pan > 10)) { temp = sign(my_angle.pan) * current_speed * 0.1; } else { temp = current_speed * my_angle * 0.01; } my.pan += temp * min(1, time); acc_speed = acc_speed * max ((1 - time * 0.03), 0) + 0.2 * current_speed * time; distance = acc_speed * time; move_mode = ignore_you + ignore_push + activate_trigger + glide; ent_move (distance, nullskill); wait(1); } }
Q: I want the player to be able to load and save his position during the game. It's a short game, so a simple quick save / quick load would be enough. A: Use the built-in quick load and quick save functions as shown below.
on_s = _save(); // quick save, press "S" to save the game
on_l = _load(); // quick load, press "L" to load the game
|