Gamestudio Links
Zorro Links
Newest Posts
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
NOMAX undeclared identifier.
by Petra. 01/09/26 21:12
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 2,814 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joe_kane, Namitha_NN, Syndrela, agasior, mosfet
19189 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 | 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