Questions from the forum |
Top Previous Next |
Q: The lap counter for the car AI code from Aum35 doesn't work with the new A6.4 - can you help? A: I have included the updated project in this month's downloadable "Resources" archive.
Q: I use your countdown timer from Aum23's faq. Would it be possible to change the code, allowing the timer to display minutes and seconds separated by a ":" sign? A: Use the following example.
string time_str; string temp_str;
var seconds = 185; // number of seconds to be counted down var temp_seconds;
starter count_down() { while(seconds > 0) { sleep (1); seconds -= 1; temp = int(seconds / 60); // compute the number of minutes str_for_num(time_str, temp); str_cat (time_str, " : "); temp_seconds = seconds - temp * 60; // compute the remainder (the number of seconds) str_for_num(temp_str, temp_seconds); if (temp_seconds < 10) { str_cat (time_str, "0"); // add a zero (if needed) } str_cat (time_str, temp_str); } }
text time_txt { pos_x = 300; pos_y = 20; string = time_str; flags = visible; }
Q: In workshop 34 from Aum 59, would it be possible to edit the code so that the bullet holes don't hit the skies? A: The easy way of solving this problem is to make the walls that are used for the sky "special". I chose to check their flag1 and track its state in my code - see the code for the modified workshop in this month's "Resources".
Q: How can I calculate the size (in quants) of my terrain? A: Paste the following code at the end of your main script file, place any entity in the level and attach it the terrain_size action; you will see its size on the screen.
var t_sizex; var t_sizey; var t_sizez;
panel size_pan { pos_x = 40; pos_y = 40; digits (0, 10, "Size on x: %.0f", *, 1, t_sizex); digits (0, 40, "Size on y: %.0f", *, 1, t_sizey); digits (0, 70, "Size on z: %.0f", *, 1, t_sizez); flags = visible; }
action terrain_size { c_setminmax (my); t_sizex = my.max_x - my.min_x; t_sizey = my.max_y - my.min_y; t_sizez = my.max_z - my.min_z; }
Q: What are the ways to quickly manufacture a non interactive background for a game? A: Surround your level with a hollowed cube, check the "sky" flag for all the blocks that create it, and then paste this piece of code in your script.
bmap background_tga = <background+6.tga>; // that would be your background
sky background_cube { type = <background+6.tga>; layer = 10; z = 10; // play with this value flags = cube, visible; }
Q: Why isn't 3DGS playing all the wav files from my game folder? They work fine with Media Player... A: GameStudio supports sample rates of 11, 22 and 44KHz, with 8 and 16 bits data. Convert all the other wav files to one of these rates using (as an example) the free Audacity audio editor.
Q: I'd like my player to trigger a level change when it enters a certain area from the current level. How can I do that? A: Attach the following action to any entity that is placed in the desired area; play with skill1 until you are happy with the result.
string newlevel_wmb = <work34.wmb>; // put the name of your level here
define trigger_distance, skill1; // set the trigger distance in skill1
// uses trigger_distance action level_trigger { while (player == null) {wait (1);} // wait until the player is loaded if (my.trigger_distance == 0) // the player has forgotten to set the distance in skill1? { my.trigger_distance = 200; // then use a default value of 200 quants } my.skill40 = 0; while (my.skill40 == 0) { if (vec_dist (my.x, player.x) < my.trigger_distance) // the player has come close? { my.skill40 = 1; // don't run this loop anymore level_load (newlevel_wmb); // load the new level } wait (1); } }
Q: How can I use animation blending? I try to use it for transition animations, for example from "wait" to "work" A: Use this example.
action wait_to_work { while (key_b == off) // play the "wait" animation until the player presses the "B" key { ent_animate (me, "wait", my.skill46, anm_cycle); my.skill46 += 1 * time_step; my.skill46 %= 100; wait (1); } my.skill42 = 0; while(my.skill42 < 100) { ent_animate (me, "wait", my.skill42, anm_cycle); ent_blend("work", 0, my.skill42); // blend "wait" into "work" my.skill42 += 10 * time_step; wait(1); } while (1) { ent_animate (me, "work", my.skill47, anm_cycle); my.skill47 += 1 * time_step; my.skill47 %= 100; wait (1); } }
Q: I am looking for a quick example of a shooting game like moorhuhn. It is a game where you are supposed to kill birds that pass by and you get points for what you hit. A: I have created a simple example for you; examine the code from the \moorhuhn folder inside this month's "Resources".
Q: I know that you can create view entities, but can you create view particles? Otherwise it's a trigonometric nightmare trying to get the particles to the same position as the view entity. A: You can't create view particles, but you can use a view entity and place the particles at the proper position in the 3D world. Here's an example for a torch that uses a view entity and particles that are created in the "real" level and keep a proper position at all times.
bmap flame_tga = <flame.tga>;
function flame_init(); function fade_flames();
entity torch_ent { type = <torch.mdl>; // torch model x = 55; y = -22; z = -25; tilt = -10; flags = visible; }
starter flames_on() { proc_late(); var flame_pos; while(1) { vec_set (flame_pos.x, vector (25, -9, -3)); // play with these values vec_rotate (flame_pos.x, camera.pan); vec_add (flame_pos.x, camera.x); effect(flame_init, 2, flame_pos.x, nullvector); wait (1); } }
function flame_init() { temp.x = (random(2) - 1) / 2; temp.y = (random(2) - 1) / 2; temp.z = random(1) + 1; vec_set(my.vel_x, temp); my.move = on; my.bmap = flame_tga; my.flare = on; my.bright = on; my.alpha = 70; my.lifespan = 100; my.size = 12; my.function = fade_flames; }
function fade_flames() { my.alpha -= 25 * time_step; // play with 25 if(my.alpha < 0) {my.lifespan = 0;} }
|