Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 692 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Camera crashes #319750
04/17/10 14:26
04/17/10 14:26
Joined: Oct 2009
Posts: 90
WickWoody Offline OP
Junior Member
WickWoody  Offline OP
Junior Member

Joined: Oct 2009
Posts: 90
I create a trigonometric camera code but that is crashes game.

Code:
camera.x = govde.x - 25 * cos(govde.pan);
camera.y = govde.y - 25 * sin(govde.pan);
camera.z = govde.z + 25;
camera.pan = govde.pan;



I used to this code before perfectly, but now giving error.

Re: Camera crashes [Re: WickWoody] #319752
04/17/10 14:47
04/17/10 14:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Probably govde is invalid. You have two options:

1)
if(govde) {
camera.x = govde.x - 25 * cos(govde.pan);
camera.y = govde.y - 25 * sin(govde.pan);
camera.z = govde.z + 25;
camera.pan = govde.pan;
}


2)
while(!govde) { wait(1); }
while(1) {
camera.x = govde.x - 25 * cos(govde.pan);
camera.y = govde.y - 25 * sin(govde.pan);
camera.z = govde.z + 25;
camera.pan = govde.pan;
wait(1);
}


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Camera crashes [Re: Superku] #319756
04/17/10 15:16
04/17/10 15:16
Joined: Oct 2009
Posts: 90
WickWoody Offline OP
Junior Member
WickWoody  Offline OP
Junior Member

Joined: Oct 2009
Posts: 90
I disagree. Review my code:

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

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

var on_sag;
var on_sol;
var arka_sag;
var arka_sol;

var donus_hizi;
var ana_hiz;
var hiz_kontr;

ENTITY* govde;

action aGovde()
{
	govde = me;
	player = me;
	set(my, SHADOW | CAST);
	
	phent_settype (govde, PH_RIGID, PH_BOX);
	phent_setmass (govde, 15, PH_BOX);
	phent_setgroup (govde, 2);
	phent_setfriction (govde, 20);  
	phent_setdamping (govde, 5, 5);
	phent_setelasticity (govde, 10, 100);
	
}

function tekerlek_fizik_init()
{
	set(my, SHADOW);
	
	phent_settype(me, PH_RIGID, PH_SPHERE);
	phent_setmass(me, 30, PH_SPHERE);
	phent_setgroup(me, 2);
	
	phent_setfriction(me, 100);
	phent_setdamping(me, 20, 20);
	phent_setelasticity(me, 0, 100);
}

action on_sagg()
{
	tekerlek_fizik_init();
	
	on_sag = phcon_add(PH_WHEEL, govde, me);
	
	phcon_setparams1(on_sag, my.x, vector(0,0,1), nullvector);
	phcon_setparams2(on_sag, nullvector, nullvector, nullvector);
}

action on_soll()
{
	tekerlek_fizik_init();
	
	on_sol = phcon_add(PH_WHEEL, govde, me);
	
	phcon_setparams1(on_sol, my.x, vector(0,0,1), nullvector);
	phcon_setparams2(on_sol, nullvector, nullvector, nullvector);
}

action arka_sagg()
{		
	tekerlek_fizik_init();
	
	arka_sag = phcon_add (PH_WHEEL, govde, my);
	phcon_setparams1 (arka_sag, my.x, nullvector, vector (0,1,0));
	phcon_setparams2 (arka_sag, nullvector, nullvector, nullvector);
}

action arka_soll()
{		
	tekerlek_fizik_init();

	arka_sol = phcon_add (PH_WHEEL, govde, my);
	phcon_setparams1 (arka_sol, my.x, nullvector, vector (0,1,0));
	phcon_setparams2 (arka_sol, nullvector, nullvector, nullvector);
}

function main()
{
  vec_set(screen_size,vector(800,600,0));
  vec_set(sky_color,vector(256,256,256)); // dark blue
  video_window(NULL,NULL,0,"Ferrari Racing: Drag");
  d3d_antialias = 1;
  shadow_stencil = 3;
  
  level_load("cevre.wmb");
  
  ph_setgravity(vector(0,0, -386));
  
  
  while(1)
  {
  	/* //kamera
  	camera.x = govde.x - 25 * cos(govde.pan);
  	camera.y = govde.y - 25 * sin(govde.pan);
  	camera.z = govde.z + 25;
  	camera.pan = govde.pan; */
  	
  	
  	hiz_kontr = (key_w - key_s);
  	
  	donus_hizi = hiz_kontr * 100 * time_step;
  	
  	phcon_setmotor(arka_sol, nullvector, vector(-donus_hizi, 1500, 0), nullvector);
  	phcon_setmotor(arka_sag, nullvector, vector(-donus_hizi, 1500, 0), nullvector);
  	
  	wait(1);
  }
}



Re: Camera crashes [Re: WickWoody] #319758
04/17/10 15:22
04/17/10 15:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Again, the pointer is invalid. (govde will be valid one or more frames later, though, but before it is valid, the while loop gets executed.)

Last edited by Superku; 04/17/10 15:24.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Camera crashes [Re: Superku] #319762
04/17/10 15:29
04/17/10 15:29
Joined: Oct 2009
Posts: 90
WickWoody Offline OP
Junior Member
WickWoody  Offline OP
Junior Member

Joined: Oct 2009
Posts: 90
You're right x) Thanks.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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