|
|
|
2 registered members (opm, 1 invisible),
14,409
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to change between functions?
[Re: FutureRaptor]
#349209
12/05/10 01:40
12/05/10 01:40
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
C-Script:
function ToggleCam()
{
cam_num += 1;
cam_num %= 6;
}
on_f4 = ToggleCam;
action Cam_1 //Action der Cam Entity für die erste Sequenz
{
my.passable = on;
my.invisible = on;
mouse_mode=2;
while(1)
{
if(cam_num==0)
{
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);
}
wait(1);
}
}
action Cam_2 //Action der Cam Entity für die erste Sequenz
{
my.passable = on;
my.invisible = on;
while(1)
{
if(cam_num==1)
{
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);
}
wait(1);
}
}
Small example, hope this helps. cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: How to change between functions?
[Re: rvL_eXile]
#349387
12/06/10 22:54
12/06/10 22:54
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
easiest way i can think of
void cam_global(){
}
void cam_player(){
}
void main(){
//...
while(1){
switch(cam_to_do){
case 1:
cam_global();
case 2:
cam_player();
}
wait(1);
}
}
obviously you can use if else here instead of switch if using only 2 camera mechanics
|
|
|
Re: How to change between functions?
[Re: FutureRaptor]
#349404
12/07/10 04:48
12/07/10 04:48
|
Joined: Feb 2010
Posts: 320 TANA/Madagascar
3dgs_snake
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
You need to test the keys and then store the state in a variable, You only change the variable when a key was pressed. You then only test the state of the variable.
#include <acknex.h>
#define STATE_1 1
#define STATE_2 2
// Variable initialisation
var current_state = STATE_1;
void main()
{
...
while(1)
{
if (key_...)
{
current_state = STATE_1 ;
}
else if ( key_... )
{
current_state = STATE_2 ;
}
...
switch ( current_state )
{
case STATE_1:
...
break;
case STATE_2:
...
break;
}
}
...
}
You can separate the codes in functions, eg handle_keys() ; do_stuff () ;
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|
|
|
|