Gamestudio Links
Zorro Links
Newest Posts
How to Change Multiplier
by vicknick. 06/02/23 03:27
How to buy tomorrow at open?
by vicknick. 06/02/23 03:19
Adding Position to Current Trade
by vicknick. 06/02/23 03:09
Unable to change multiplier of contract
by vicknick. 05/30/23 06:56
Wrong Definition of Sharpe Ratio in Zorro?
by vicknick. 05/29/23 06:32
Backtest strategy on bitcoin/crypto
by JamesHH. 05/26/23 04:36
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (vicknick, 7th_zorro, Quad), 1,020 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
BInnacle, androsa, XquicksnowX, danishinvest, Trail
18942 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
a problem with where to put some code #291526
09/25/09 22:39
09/25/09 22:39
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hello,
This is what I am trying, I am flying a ship into a space port. I have the camera at the same XYZ and pan as the ship. where ever the turns or go there go ther camera, works fine.
Camera 2 is with a object called ranger. Camera 2 as the same XYZ and pan as object ranger.

Now when I land at the space port, I can press let say Key"p" and I swith to camer 2,
code camera 2
vec_set(camera.x,ranger.x);
vec_set(camera.y,ranger.y);
vec_set(camera.z,ranger.z);
vec_set(camera.pan,ranger.pan);

and can walk all over the space port. all new control keys for camer2.

Where the problem is that ranger object is not with the ship, so when I press key "p" I am out in space some place. Ranger is not where the ship is. This is some of the things I have tryed.

//////////////////////////////////////////////////////////////
vec_set(ranger.x,ship.x);
vec_set(ranger.y,ship.y);
vec_set(ranger.z,ship.z=50);
/////////////////////////////////////////////////////////////

I tryed this, but if I put it in a while loop some place, then I can not move

If I put it not in a while loop the camera fails.

I would like to be able to put the ranger at the ship when I go from in the ship camera to out of the ship camera or from camera 1 to camera 2 by pressing Key"p". I have put the code all over the place and I can not get it to work. The only time this line of code should be used is when I press p to go to camera 2. and never looked at again unless Key "p" is pressed again.

Thank you
renny

CODE:

Code:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>        ///////////////////////////////////TWO CAMERA CODE/////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


ENTITY* ship;
ENTITY* ranger;


var look = 1;


function camera_walking();
function camera_ship();

	 
 
	


action act_ship()
{
ship = me;
me.ambient = 10;
while(1)
{
if(look==1)
{camera_ship();}
   

else
if(look==0)
{camera_walking();}

if (key_o) {look=0;}
if (key_p) {look=1;}
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}
if (key_a){c_move (me,vector( 5,0,0),nullvector,GLIDE);}
if (key_s){c_move (me,vector( -5,0,0),nullvector,GLIDE);}
if (key_q){c_move (me,vector( 0,0,1),nullvector,GLIDE);}
if (key_e){c_move (me,vector( 0,0,-1),nullvector,GLIDE);}
if (key_c) {me.tilt += 3*time_step;}
if (key_v) {me.tilt -= 3*time_step;}
if (key_r) {me.roll -= 3*time_step;}
if (key_t) {me.roll += 3*time_step;}





	


wait(1);
}
}



action act_ranger()
{
ranger = me;
me.ambient = 10;
while(1)
{
if(look==1)
{camera_ship();}
else
if(look==0)
{camera_walking();}

	

	

if (key_k){c_move (me,vector( 5,0,0),nullvector,GLIDE);}
if (key_l){c_move (me,vector( -5,0,0),nullvector,GLIDE);}
if (key_h) {me.pan += 3*time_step;}
if (key_j) {me.pan -= 3*time_step;}
{c_move (me,vector(0,0,-.5),nullvector,GLIDE);}

if (key_o) {look=0;}
if (key_p) {look=1;}


wait(1);
}
}



function main()
{
	video_screen = 1;
	video_mode = 7;
	max_entities = 1000; // alows up to 1000 Entities. 
	level_load ("place.wmb");
  wait(3);
	
	ent_create("ship.mdl", vector(-3000, 0, 60), act_ship);
	ent_create("ranger.mdl", vector(100, 0, 30), act_ranger);
	
}	

 
	

     
   




function camera_ship()

 {
 	
 	
 
 if(look==1)	
 vec_set(camera.x,ship.x);
 if(look==1)
  vec_set(camera.y,ship.y);
  if(look==1)
  vec_set(camera.z,ship.z);// move the camera together with the ship entity
  if(look==1)
  vec_set(camera.pan,ship.pan);
 

 	
 	
}


function camera_walking()

{
	
	
if(look==0)	
 vec_set(camera.x,ranger.x);
 if(look==0)
  vec_set(camera.y,ranger.y);
  if(look==0)
  vec_set(camera.z,ranger.z+50);// move the camera together with the ship entity
  if(look==0)
  vec_set(camera.pan,ranger.pan);	
  



}




I have A7 Commercial .............. Now I just need to learn how to use it

Re: a problem with where to put some code [Re: sadsack] #291894
09/28/09 19:00
09/28/09 19:00
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi,
I see that know one know what to do about this. Well let me ask this, if there is a way to have a action for a object that has not been loaded yet or have been deleted. Some thing like:
( if object (exist) then do this if not than don't do anything)

I just can't get camera number 2 to work right. All I need to do is put the object that camera2 is tied too at the ship when one want to get out of the ship and walk around. I have tried 50 ways and none work like I want.
Thank you
renny

Last edited by sadsack; 09/28/09 19:02.

I have A7 Commercial .............. Now I just need to learn how to use it

Re: a problem with where to put some code [Re: sadsack] #291899
09/28/09 19:33
09/28/09 19:33
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
rehash sample only
-- untested, probably contains faults
-- primary fault with original code
---- incorrect use of vec_set instructions?
------ vec_set sets all three elements of VECTOR x,y,z, using pointer to first element x of source VECTOR?
------ do not vec_set(v.y, -), vec_set(v.z, -)
Code:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>        ///////////////////////////////////TWO CAMERA CODE/////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define look_ship 1
#define look_ranger 0

ENTITY* pl_ship;
ENTITY* pl_ranger;
ENTITY* player1;
var look = 1;

function camera_walking();
function camera_ship();

action act_ship() {
	pl_ship = me;
	me.ambient = 10;
	while(pl_ranger == NULL) { wait(1); }
	while(me != NULL) {
		if (player1 == me) {
			reset(me, PASSABLE);
			camera_ship();
			if (key_o) { // key_o sets to ranger mode
				player1 = pl_ranger; 
				set(me, PASSABLE);	// set ship to PASSABLE so ranger doesn't get stuck
			}
			if (key_z) {me.pan += 3*time_step;}
			if (key_x) {me.pan -= 3*time_step;}
			if (key_a){c_move (me,vector( 5,0,0),nullvector,GLIDE);}
			if (key_s){c_move (me,vector( -5,0,0),nullvector,GLIDE);}
			if (key_q){c_move (me,vector( 0,0,1),nullvector,GLIDE);}
			if (key_e){c_move (me,vector( 0,0,-1),nullvector,GLIDE);}
			if (key_c) {me.tilt += 3*time_step;}
			if (key_v) {me.tilt -= 3*time_step;}
			if (key_r) {me.roll -= 3*time_step;}
			if (key_t) {me.roll += 3*time_step;}
		}
		wait(1);
	}
}

action act_ranger() {
	pl_ranger = me;
	me.ambient = 10;
	while(pl_ship == NULL) { wait(1); }
	while(me != NULL) {
		if (player1 == NULL) { player1 = me; }		// defaults to pl_ranger
		if (player1 == me) {
			reset(me, PASSABLE);
			reset(me, INVISIBLE);
			camera_walking();
		
			if (key_k){c_move (me,vector( 5,0,0),nullvector,GLIDE);}
			if (key_l){c_move (me,vector( -5,0,0),nullvector,GLIDE);}
			if (key_h) {me.pan += 3*time_step;}
			if (key_j) {me.pan -= 3*time_step;}
			c_move (me,vector(0,0,-.5),nullvector,GLIDE);
			if (key_p) {	// key_p sets to ship mode
				player1 = pl_ship;
				set(me, PASSABLE | INVISIBLE);	// hide ranger
			}
		}
		wait(1);
	}
}

function main() {
	player1 = NULL;
	video_screen = 1;
	video_mode = 7;
	max_entities = 1000; // alows up to 1000 Entities. 
	level_load ("place.wmb");
	wait(3);
	
	ent_create("ship.mdl", vector(-3000, 0, 60), act_ship);
	ent_create("ranger.mdl", vector(100, 0, 30), act_ranger);
}	

function camera_ship() {
	if (player1 == NULL) { return 0; }
	// move the camera together with the player1 entity
	vec_set(camera.x, player1.x);
	vec_set(camera.pan, player1.pan);
}


function camera_walking() {
	if (player1 == NULL) { return 0; }
	// move the camera together with the player1 entity
	vec_set(camera.x, vector(player1.x, player1.y, player1.z + 50));
	vec_set(camera.pan, player1.pan);	
}




Last edited by testDummy; 09/29/09 19:12. Reason: 2009.09.29a syntax error
Re: a problem with where to put some code [Re: testDummy] #292023
09/29/09 17:58
09/29/09 17:58
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi testDummy,
You are right, the code does not work, does not compile. I am going to look at very line of code and see if I can see what you are trying to do. Then I will try to make my code work using you code.
Thank you for all the work you went too.
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: a problem with where to put some code [Re: sadsack] #292035
09/29/09 19:23
09/29/09 19:23
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
above source edited:
2009.09.29a function prototype "camera_pl_ship" renamed to "camera_ship"

Might compile and do something now.
(Tested slightly with Lite-C FREE. Don't have A7.)

Re: a problem with where to put some code [Re: testDummy] #292058
09/29/09 22:05
09/29/09 22:05
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi testDummy,
i don't see camera_pl_ship any place in the code you have here.

here is what you had for the func.
function camera_walking();
function camera_ship();
I could not find a func. camera_pl_ship

Thank you
renny
EDIT: OK I see that you have changedthe code, so i tryed it. But it does what my code does, the walk about camera is where the ship is at when the game start, so when I move the ship to in side the space port and goto the other camera I am out side where the ship use to be. But I thing with your help i am colse to working this out.
Thank you.
P.S. I sent you a PM.


Last edited by sadsack; 09/29/09 22:12.

I have A7 Commercial .............. Now I just need to learn how to use it

Re: a problem with where to put some code [Re: sadsack] #292068
09/29/09 23:56
09/29/09 23:56
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi all and testDummy,
I got the problem with the ranger fixed, what I did testDummt was this:

Code:
if (key_o) { // key_o sets to ranger mode
			   vec_set(pl_ranger.x, vector(pl_ship.x, pl_ship.y, pl_ship.z ));
			   vec_set(pl_ranger.pan,pl_ship.pan);
				player1 = pl_ranger;
				set(me, PASSABLE);	// set ship to PASSABLE so ranger doesn't get stu




Now when I go from in the ship to out walking about I am right where the ship is.
I still have to work on getting the ship to come up first instead of the player(walk about function.) I was thinking that would be easy, but it turned out to be the hard one to do.
thank testDummy, you got me going here.
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: a problem with where to put some code [Re: sadsack] #292124
09/30/09 14:09
09/30/09 14:09
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
vec_set(pl_ranger.x, pl_ship.x);
That copies all 3 vectors, write this and no more...

the same with:
vec_set(pl_ranger.pan,pl_ship.pan);
copies the pan,tilt AND roll from pl_ship to pl_ranger.

Last edited by Widi; 09/30/09 14:11.
Re: a problem with where to put some code [Re: Widi] #292130
09/30/09 15:19
09/30/09 15:19
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Ok will try that
Thank you
renny


I have A7 Commercial .............. Now I just need to learn how to use it


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