Contacts
صفحه اصلی پورتال | صفحه اصلی تالار | ثبت نام | اعضاء | گروه ها | جستجو | پرسش و پاسخ | فروشگاه الکترونیکی | خرید پستی بازی های کامپیوتری





صفحه اول انجمنها -> ساخت بازی با نرم افزار 3D Game Studio -> سوال و جواب فنی مجلات AUM - بخش چهارم
 

ارسال يك موضوع جديد   پاسخ به يك موضوع ديدن موضوع قبلي :: ديدن موضوع بعدي

سوال و جواب فنی مجلات AUM - بخش چهار
نويسنده
پيغام
مهمان







3 شنبه 27 تير 1385 - 10:24
پاسخ بصورت نقل قول
سلام ..

بخش چهارم سوال و جواب های AUM را تقدیم میکنم . امیدوارم پاسخگوی بخشی از سوالات شما باشد :

كد:


Q: How can I play several music files in a loop, one after the other?

A: Use the following example.

 

var track_handle;

 

starter game_music()

{

       while (player == null) {wait (1);}

       while (1)

       {

               track_handle = media_play("track1.mid", null, 50);

               while (media_playing(track_handle)) {wait (1);}

               track_handle = media_play("track2.mid", null, 50);

               while (media_playing(track_handle)) {wait (1);}

               track_handle = media_play("track3.mid", null, 50);

               while (media_playing(track_handle)) {wait (1);}

               track_handle = media_play("track4.mid", null, 50);

               while (media_playing(track_handle)) {wait (1);}

               wait (1);

       }

}

 

 

Q: How can I highlight an object in my strategy game by moving the mouse over it?

A: Use this snippet.

 

function highlight_me()

{

       if (event_type == event_touch)

       {

               my.ambient = 100; // highlight the unit

       }

       while (event_type != event_release) {wait (1);}

       my.ambient = 0;

}

 

action my_unit

{

       my.enable_touch = on;

       my.enable_release = on;

       my.event = highlight_me;

}

 

 

Q: How can I run a "while" loop (every frame) for a specified number of seconds?

A: Use this example.

 

function countdown_timer()

{

       var time_passed = 12; // the loop will run for 12 seconds

       while (time_passed > 0)

       {

               time_passed -= time / 16; // decrease time_passed every frame

               // do something useful here for 12 seconds

               camera.ambient = random(100); // now that's useful stuff!

               wait (1);

       }

       // the action would goes on here after 12 seconds

}

 

on_c = countdown_timer; // press "C" to run the function

 

 

Q: How can I create a decent looking torch effect?

A: Use this snippet.

 

bmap fire_tga = <fire.tga>;

bmap smoke1_tga = <smoke1.tga>;

bmap smoke2_tga = <smoke2.tga>;

 

function fire_effect();

function fade_flames();

function smoke_effect();

function fade_smoke();

 

action my_torch

{

       my.passable = on;

       while (1)

       {

               vec_set(temp.x, my.x);

               vec_add(temp.x, vector(random(2) - 4, random(2) - 4, 25 + random(3))); // play with 25

               effect (fire_effect, 10 * time, temp.x, normal); // play with 10

               if (random(1) > 0.85)

               {

                       temp.z += 5 + random(5); // play with 5

                       effect (smoke_effect, 1, temp.x, normal);

               }

               my.lightrange = 200;

               my.lightred = 200;

               my.lightgreen = 150 + random(50);

               my.lightblue = 100;

               wait (1);

       }

}

 

function fire_effect()

{

       temp.x = random(4) - 2;

       temp.y = random(4) - 2;

       temp.z = random(2); // play with 2

       vec_add (my.vel_x, temp);

       my.alpha = 20 + random(80);

       my.bmap = fire_tga;

       my.size = 25; // play with 25       

       my.bright = on;

       my.move = on;

       my.lifespan = 5;

       my.function = fade_flames;

}

 

function fade_flames()

{

       my.vel_x /= 2;

       my.alpha -= 2 * time;

       if (my.alpha < 0) {my.lifespan = 0;}

}

 

function smoke_effect()

{

       temp.x = random(1) - 0.5;

       temp.y = random(1) - 0.5;

       temp.z = random(1); // play with 1

       vec_add (my.vel_x, temp);

       my.alpha = 20 + random(20);

       if (random(1) > 0.7)

       {

               my.bmap = smoke2_tga;

       }

       else

       {

               my.bmap = smoke1_tga;       

       }

       my.size = 20; // play with 20

       my.bright = on;

       my.move = on;

       my.lifespan = 500;

       my.function = fade_smoke;

}

 

function fade_smoke()

{

       my.alpha -= 0.2 * time; // play with 0.2

       if (my.alpha < 0) {my.lifespan = 0;}

}


Q: Can I play an animated movie (my logo) at the beginning of the game, and then display the main menu?

A: Use this piece of code.

 

var logo_handle;

 

function main()

{

       fps_max = 60; // limit the frame rate to 60 fps

       logo_handle = media_play("logo.avi", null, 100); // play your logo movie

       while (media_playing(logo_handle)) {wait (1);} // wait until the movie has ended

       level_load (mylevel_wmb); // now load the level

       wait (3); // wait until the level is loaded

       mainmenu_pan.visible = on; // don't forget to define this panel first

       // put the rest of the code for function main here

}

 

 

Q: How can I have an object that follows the player at all times? I'd like to be able to specify the distance to the player as well...

A: Use this example:

 

string follower_mdl = <follower.mdl>;

 

function follow_player()

{

       proc_late();

       while (1)

       {

               vec_set (my.x, vector (100, 50, 30)); // play with these values

               vec_rotate (my.x, player.pan);

               vec_add (my.x, player.x);

               my.pan = player.pan; // only if you need this as well

               wait (1);

       }

}

 

 

action player1

{

       player = my; // I'm the player

       ent_create (follower_mdl, my.x, follow_player);

       ................................

}

 

 

Q: I'd like to control the ambient in my game using the mouse wheel. Is this even possible?

A: Sure. Examine the code below.

 

starter set_ambient()

{

       while (1)

       {

               camera.ambient -= 0.2 * mickey.z * time;

               camera.ambient = min (max (camera.ambient, 0), 100); // limit camera.ambient to 0...100

               wait (1);

       }

}

 

 

Q: Do you know of a tool that can create robotic speech?

A: Try the good old SayIt from AnalogX - www.analogx.com

 

 

Q: I want an entity to become "player" if I click on it.

A: Use the following snippet.

 

function become_player()

{

       player = my;

}

 

action potential_player // attach this action to several entities

{

       my.enable_click = on;

       my.event = become_player;

}

 

starter control_player()

{

       while (1)

       {

               if (player != null)

               {

                       player.pan += 1 * time;

               }

               wait (1);

       }

}

 

 

Q: How can I animate a sprite using ent_animate? I can't see the animation frames!

A: Use this example.

 

action animated_sprite // attach this action to a sprite that contains several frames

{

       var anim_speed;

       while (1)

       {

               ent_animate(my, "test", anim_speed, anm_cycle); // put any animation name here ("test", "stand", whatever)

               anim_speed += 5 * time; // "5" controls the animation speed

               wait (1);

       }

}

 


موفق باشید : ستاره
ارسال  بازگشت به بالا
 

نويسنده
پيغام
jonathan
مدیر انجمن
مدیر انجمن


تاريخ عضويت: جمعه 8 ارديبهشت 1385
تعداد ارسالها: 1166
محل سكونت: شيراز


3 شنبه 27 تير 1385 - 14:57
پاسخ بصورت نقل قول
100٪

ممنون

_________________
Then you came right in
tearing out my soul
tearing out my soul
tearing out my soul
tearing out my soul
tearing out my soul
ارسال  بازگشت به بالا
ديدن مشخصات كاربر ارسال پيغام خصوصي
 

نمايش نامه هاي ارسال شده قبلي:   
ارسال يك موضوع جديد   پاسخ به يك موضوع    صفحه 1 از 1 تمام ساعات و تاريخها بر حسب 3.5+ ساعت گرينويچ مي باشد


 
پرش به:  


شما نمي توانيد در اين انجمن نامه ارسال كنيد.
شما نمي توانيد به موضوعات اين انجمن پاسخ دهيد
شما نمي توانيد نامه هاي ارسالي خود را در اين انجمن ويرايش كنيد
شما نمي توانيد نامه هاي ارسالي خود را در اين انجمن حذف كنيد
شما نمي توانيد در نظر سنجي هاي اين انجمن شركت كنيد


unity3d

بازگردانی به فارسی : علی کسایی @ توسعه مجازی کادوس 2004-2011
Powered by phpBB © 2001, 2011 phpBB Group
| Home | عضويت | ليست اعضا | گروه هاي كاربران | جستجو | راهنماي اين انجمن | Log In |