Most asked questions |
Top Previous Next |
Q: I'd like to have a tv that turns itself on / off depending on how close the player is to it. Can you help?
var tv_handle;
action tv_sprite
Q: I need to display a picture when the player approaches an invisible object at the end of the game.
bmap gameover_pcx = <gameover.pcx>;
panel gameover_pan
action invisible_object
Q: I was wondering if you could tell me how to create a star wars lightsaber effect.
bmap flare_pcx = <flare.pcx>;
var sword_vertex; var ray_size;
function remove_flares()
function attach_rays()
action monster_with_sword
Q: I use the starfield code from your "Planet Survivor" series. Is it possible to modify the code so that the starfield is always in front of my spaceship, even if I change its pan and tilt and I move it? A: Sure. Use the code below:
bmap star_tga = <star.tga>;
string gibbit_mdl = <gibbit.mdl>;
var starfield_speed = 2; // controls the global speed of the starfield
function size_particles() { my.size += 0.01 * time; }
function particle_init() { temp.x = -(2 + random (15)) * starfield_speed; temp.y = 0; temp.z = 0; vec_add (my.vel_x, temp); my.bmap = star_tga; my.alpha = 40 + random(60); // play with this value my.size = 5 + random(5); my.bright = on; my.move = on; my.lifespan = 500; my.function = size_particles; }
function init_starfield() { my.invisible = on; my.passable = on; while (1) { vec_set(temp, vector(1000, 0, 0)); // keep the starfield generator 1000 quants in front of the camera all the time vec_rotate(temp, camera.pan); vec_add(temp, camera.x); vec_set(my.x, temp); temp.x = my.x + 500 - random(1000); temp.y = my.y + 500 - random(1000); temp.z = my.z + 500 - random(1000); effect (particle_init, 15 * time, temp, normal); wait (1); } }
starter particle_generator() { while (player == null) {wait (1);} ent_create (gibbit_mdl, player.x, init_starfield); }
Q: I'd like to be able to go back and forth in my levels, while keeping the initial player pan angle. How can I do that? A: Use the code below:
var players_pan; // global variable
string level1_wmb = <office.wmb>; string level2_wmb = <level2.wmb>;
function change_levels_12 { players_pan = player.pan; // store the initial pan wait (1); if (you != player) {return;} // the entity that collided with me isn't the player? me = null; // keep this function running even after load_level level_load (level2_wmb); // load the new level sleep (0.1); // wait a bit player.pan = players_pan; // restore the initial pan }
function change_levels_21 { players_pan = player.pan; // store the initial pan wait (1); if (you != player) {return;} // the entity that collided with me isn't the player? me = null; // keep this function running even after load_level level_load (level2_wmb); // load the new level sleep (0.1); // wait a bit player.pan = players_pan; // restore the initial pan }
action level_12 // place an entity in the level and attach it this action { my.enable_impact = on; // this entity is sensitive to impact my.event = change_levels_12; // changes the level when the player runs into it }
action level_21 // place an entity in the level and attach it this action { my.enable_impact = on; // this entity is sensitive to impact my.event = change_levels_21; // changes the level when the player runs into it }
Q: How can I create a cylinder of particles? A: Use the code below:
var cylinder_radius = 20; var cylinder_height = 40; var temp_angle = 0;
bmap effect_tga = <effect.tga>;
function particle_cylinder(); function fade_particles();
action cylinder { my.invisible = on; my.passable = on; while(1) { temp.x = my.x + cylinder_radius * cos(temp_angle); temp.y = my.y + cylinder_radius * sin(temp_angle); temp.z = my.z + random(cylinder_height); effect(particle_cylinder, 100 * time, temp.x, nullvector); temp_angle += 31; // experimental value wait(1); } }
function particle_cylinder() { temp.x = 0; temp.y = 0; temp.z = random(2) + 2; vec_set(my.vel_x,temp); my.bmap = effect_tga; my.size = 2; my.flare = on; my.bright = on; my.move = on; my.streak = on; // if your engine version supports it my.alpha = 50 + random(50); my.lifespan = 50; my.function = fade_particles; }
function fade_particles() { my.alpha -= 2 * time; if(my.alpha < 0) { my.lifespan = 0; } }
Q: If I have a panel with 3 buttons, can I hide one or two of them at times and show them again at another time? A: Hide the buttons by moving them outside the screen with pan_setpos:
bmap test_pcx = <test.pcx>; bmap confirmyes1_pcx = <confirmyes1.pcx>; bmap confirmyes2_pcx = <confirmyes2.pcx>; bmap confirmyes3_pcx = <confirmyes3.pcx>;
panel test_pan { bmap = test_pcx; button = 90, 136, confirmyes3_pcx, confirmyes1_pcx, confirmyes2_pcx, null, null, null; flags = refresh, visible; }
function hide_button() { pan_setpos(test_pan, 3, 0, vector(1000, 1000, 0)); // moving a button (=3) to (1000, 1000) pixels (outside the screen) }
on_h = hide_button; // press the "H" key to hide the button
Q: Can you show us how to use the mouse wheel in order to zoom in and out smoothly? A: Use this example:
starter wheel_zoom() { while (1) { if (mickey.z > 1) { camera.arc += 10 * time; // play with "10" } if (mickey.z < -1) { camera.arc -= 10 * time; // play with "10" } camera.arc = min (max (camera.arc, 10), 120); // limit camera.arc to 10..120 wait (1); } }
|