Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
I need explain this code ? #287318
08/31/09 11:34
08/31/09 11:34
Joined: Aug 2009
Posts: 20
N
Noctis Offline OP
Newbie
Noctis  Offline OP
Newbie
N

Joined: Aug 2009
Posts: 20
I am studying how to set gravity and I am studying c_trace, but I dont know here:
Quote:

var dist_to_wall = 0;
var tempZoom = 0;
void plyr()
{
var cam_height;
var cam_angle = 0; // set the initial camera angle here, thiet lap goc quay camera
var zoom = 200;
VECTOR temp;
c_setminmax(me);
set(my,TRANSLUCENT);
my.alpha = 100;
trace_mode=IGNORE_ME|IGNORE_PASSABLE;
result=trace(vector(my.x,my.y,my.z),vector(my.x+100,my.y,my.z));
//result=c_trace(vector(my.x,my.y,my.z),vector(my.x+100,my.y,my.z),IGNORE_ME);
while(1)
{
wait(1);
zoom += 2 * (key_pgup - key_pgdn) * time_step;

dist_to_wall = c_trace(camera.x,my.x,IGNORE_ME);// Khoang cach toi buc tuong, c_trace gui 1 tia tu vi tri nay
//toi vi tri kia và kiem tra tia nay co dung chuong ngai vat tren duong no chieu hay ko

if(dist_to_wall != 0)
{
tempZoom = 10;
}
else
{
tempZoom = 0;
}

cam_height += 3 * (key_cuu - key_cud) * time_step; // thiet lap do cao cua camera
cam_height = clamp(cam_height, 50, 300);

zoom += 2 * (key_pgup - key_pgdn - tempZoom) * time_step;// zoom camera
zoom = clamp(zoom, 20, 500);

my.alpha = zoom;
my.alpha = clamp(my.alpha,10,100);

//camera.x = my.x - zoom * cos(cam_angle);
//camera.y = my.y - zoom * sin(cam_angle);
camera.x = my.x - zoom* cos(cam_angle);
camera.y = my.y - zoom* sin(cam_angle);
camera.z = my.z + cam_height;

cam_angle += 5 * (key_cur - key_cul) * time_step; // 5 gives the camera rotation speed , xoay camara

//temp.x=my.x;// cai nay ko the thay the cho vec_set vi 1 ly do nao do
vec_set(temp.x, my.x);
//temp.x-=camera.x; cai nay ko the thay the cho vec_sub vi 1 ly do nao do
vec_sub(temp.x, camera.x);// temp.x=temp.x - camera.x
vec_to_angle(camera.pan, temp); // rotate the camera towards the player at all times

my.x += key_w - key_s;// di chuyen nhan vat
my.y += key_a - key_d;// di chuyen nhan vat

}
}

void main()
{
fps_max = 60;
video_mode = 6; // 6=640x480 7=800*600 8=1024x768 9=1280x960
video_depth = 16; // 16 bit colour D3D mode

video_switch(0,0,2); // 1 = Full Screen 2 = window
tex_share = 1; // when set to on all entities share their textures saving memory
level_load("test.wmb"); //load the level

}


Ok,Iam calculating distance from player to 100 quants front side the player. Will c_trace return ( >0 :Distance to the hit polygon of the target or of the next obstacle in the way.
=0:No polygon was hit. < 0 A polygon was hit from behind. The from position lies within a solid object, or the me entity intersects with a target entity.)? But when I add watch result in SED, result always is 120 confused , and When I move box into wall, the value changes but not negative value. Can I help me ?? This full code is here http://www.mediafire.com/download.php?yggnmqzt3zj

Re: I need explain this code ? [Re: Noctis] #288019
09/03/09 16:40
09/03/09 16:40
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Try replacing:
Code:
dist_to_wall = c_trace(camera.x,my.x,IGNORE_ME);// Khoang cach toi buc tuong, c_trace gui 1 tia tu vi tri nay
//toi vi tri kia và kiem tra tia nay co dung chuong ngai vat tren duong no chieu hay ko



with:
Code:
dist_to_wall = c_trace(vector(my.x,my.y,my.z),vector(my.x+100,my.y,my.z),IGNORE_ME);// Khoang cach toi buc tuong, c_trace gui 1 tia tu vi tri nay
		//toi vi tri kia và kiem tra tia nay co dung chuong ngai vat tren duong no chieu hay ko
draw_text(str_for_num(NULL,dist_to_wall),0,0,vector(255,255,255)); //this just displays the trace result on screen



A bit confused but maybe that helps. Good luck.


Moderated by  HeelX, Spirit 

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