4 registered members (ozgur, Ayumi, VHX, monarch),
1,161
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: how to code .....
[Re: Aaron]
#112492
02/17/07 18:32
02/17/07 18:32
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Main menu: use media_loop() Code:
//Volume for media define MenuVol, 100; //Sound File string sndMMBG = "Menu.mp3"; // var BGSound; Function StartMenu() { BGSound = media_loop(sndMMBG, null, MenuVol); } Function EndMenu() { media_stop(BGSound); }
Texture for footsteps: Use a trace from the player to the ground. You can either name your textures starting with a x digit code such as dirtblabla.tga or graswhatever.bmp. Then in your trace include the flag scan_texture. then you'd use string comparisons to get the tex name, copy and clip it to 4 (or so) digits, then use IF statements to figure out which sound to use... Code:
//volume for footsteps define StepVol, 100; // string tstr; function PlayFootstep(Texname) { str_cpy(tstr, Texname); var i; i = str_len(tstr); if (i < 5) {return(0);} i -= 4; str_trunc(tstr, i); // if (str_cmpi(tstr, "dirt")) {ent_playsound(my, sndStepDirt, StepVol); return(1);} if (str_cmpi(tstr, "gras")) {ent_playsound(my, sndStepGrass, StepVol); return(1);} if (str_cmpi(tstr, "metl")) {ent_playsound(my, sndStepMetal, StepVol); return(1);} return(2); }
Use: call PlayFootstep(tex_name); after using a trace with the scan_texture flag. returns: 0: the input string had less than enough characters 1: function ran successfully 2: No matching sound could be found Code:
Function Footstep() { vec_set(temp, my.x); temp.z -= 500; c_trace(my.x, temp, scan_texture); PlayFootstep(tex_name); }
xXxGuitar511 - Programmer
|
|
|
Re: how to code .....
[Re: Aaron]
#112494
02/18/07 00:56
02/18/07 00:56
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
HI Aaron! Have you read all or part of the AUMS. That's where I found out how many things work. Hope this helps Ottawa
|
|
|
Re: how to code .....
[Re: Aaron]
#112496
02/18/07 06:12
02/18/07 06:12
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
1st) It's called the MANUAL... You will hear this very often, lol. It contains (almost) everything you need to know. 2nd) It's SPRITE (like the soda), not SPIRIT (like a ghost). sprites are simply images. The problem is, what you are trying to do (shattering on the window) requires decals, and A6 currently does NOT support this. However, it is an upcomming feature. However, you may also position a sprite along the window, but you'd have to carefully place your window so that the sprite does not show up anywhere past the window. 3rd) Writing code "from the air". Well, I wish it were simply in the air to grab, but it's not . In truth, I still use the manual, but rarely. After you've been writing it for >3 years, you start to remember basic concepts of how things work. However, sometimes you have to look up the syntax of a function (which parameters to use), like i do. finally) I've seem to be helpin you out alot lately, so why stop now . First off, the gate code. Now, physics gates (like in Manhunt) are a little harder to make, so I'm just gonna give you one that opens when the player is close to it. You will need to put the origin of the model on one of the sides of the gate (where the hinges would be). Code:
ACTION GATE { // Distance from center... my.skill1 = 500; // // Gate Speed... my.skill2 = 5; // // Gate Angle to swing to my.skill3 = 130; // // Set center of gate... var MCenter[3]; vec_set(MCenter, my.x); vec_add(MCenter, my.max_x); MCenter.x -= ((my.max_x - my.min_x) / 2); MCenter.y -= ((my.max_y - my.min_y) / 2); MCenter.z -= ((my.max_z - my.min_z) / 2); // // Wait until close enough... while(vec_dist(MCenter, player.x) < my.skill1) {wait(1);} // // Remember original pan angle... my.skill11 = my.pan; // // contains angle to add to original angle my.skill10 = 0; // // Wait until gate reaches angle while(my.skill10 < my.skill3) { // increase gates angle by speed, but don't go too far! my.skill10 = min(my.skill10 + (my.skill2 * time), my.skill3); // // Set pan to original pan + new angle my.pan = my.skill11 + my.skill10; wait(1); } // // Done! }
This is the most work I've ever put into a post, so I hope it's helpful. You're lucky you caught me in a good mood . As for animating, here's a short example... Code:
// The name of the scene in MED (default: Frame) string SceneGlassBreak = "Break"; // // Speed to animate var AnimSpeed = 10; // ... // variable for holding animate position (in percent) var i = 0; // // cycle until animation is done while(i < 100) { // increase i by AnimSpeed, but not past 100% i = min(i + (AnimSpeed * time), 100); // // Animate entity (non cycling animation)... ent_animate(my, SceneGlassBreak, i, null); // wait(1); } // Done! ...
Good luck!
xXxGuitar511 - Programmer
|
|
|
Re: how to code .....
[Re: xXxGuitar511]
#112497
02/18/07 12:17
02/18/07 12:17
|
Joined: Dec 2006
Posts: 1,086 Queensland - Australia
Nidhogg
Serious User
|
Serious User
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
|
Hey Guitar, Sorry to correct you, But isn't time succeded by time_step now. Forget from what version though, 6.3 I think..
Also not a correction but info:- You must have a wait() in a while loop otherwise the engine crashes...
Windows XP SP3 Intel Dual Core CPU: E5200 @ 2.5GHz 4.00GB DDR3 Ram ASUS P5G41T-M LX PCIE x16 GeForce GTS 450 1Gb SB Audigy 4 Spyware Doctor with AntiVirus
|
|
|
|