Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, 1 invisible), 1,404 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to change between functions? #349208
12/05/10 01:37
12/05/10 01:37
Joined: Sep 2010
Posts: 67
FutureRaptor Offline OP
Junior Member
FutureRaptor  Offline OP
Junior Member

Joined: Sep 2010
Posts: 67
I need to change between functions for the different cameras I have set up. Every time I press key_2 I need to turn on camera two and when I press it again switch back to the camera one function. How can I get that to work. If anybody has any idea how to switch between cameras even if they dont use my method pls help. Thanks!

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 Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
C-Script:
Code:
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
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
easiest way i can think of
Code:
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] #349402
12/07/10 03:30
12/07/10 03:30
Joined: Sep 2010
Posts: 67
FutureRaptor Offline OP
Junior Member
FutureRaptor  Offline OP
Junior Member

Joined: Sep 2010
Posts: 67
Thanks for the help. When using the IF function how can I make it so when the player presses a key(whatever key) the conditions set in the IF turn on without the player having to hold the key to make the conditions continue. I hope you get my explanation..

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 Offline
Senior Member
3dgs_snake  Offline
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.

Code:
#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 () ;


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1