Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, 7th_zorro, TedMar), 1,243 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem understanding c_trace and vec_dist #313391
03/01/10 09:27
03/01/10 09:27
Joined: Dec 2009
Posts: 71
N
ncc1701d Offline OP
Junior Member
ncc1701d  Offline OP
Junior Member
N

Joined: Dec 2009
Posts: 71
newby here
can someone take a look at this and tell me what I am doing wrong? I am just trying to use c_trace and vec_dist for the first time. I am trying to display the distance between 2 balls using those 2 types of code tools. thanks

///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>

////////////////////////////////////////////
var distance = 0;//ok
ENTITY* ball1;
ENTITY* ball2;


PANEL* first_pan =
{
digits (30, 30, 2, *, 1, distance);
flags = VISIBLE;
}


function earth()
{
ball1 = my;
my.ambient = 100;
c_trace(my.z,ball2.z,USE_BOX);
distance = vec_dist(my.z,ball2.z);

}


function testball()
{
ball2 = my;
my.ambient = 0;
}


function main()
{
level_load("small.hmp");
ball1 = ent_create("earth.mdl", vector(0, 0, 30), earth);
ball2 = ent_create("testball.mdl", vector(0, 0, 65), testball);
}

Re: problem understanding c_trace and vec_dist [Re: ncc1701d] #313393
03/01/10 09:31
03/01/10 09:31
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
you dont need c_trace.
only vec_dist will be good enough.

vec_dist returns the distance between 2 vectors.
c_trace creates a line between 2 points, and checks for collision along the way.
if it hit's anything, it will return the distance from the position it traces to the point it hits something.

hope I made some sence there.

regards,

EDIT: after looking more closely at your code, there are several issues.
Dont load a .hmp file, create a wmb with WED that you load.
also, here is the script fixes I made in your code.
now it should work:

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

////////////////////////////////////////////
var distance = 0;//ok
ENTITY* ball1;
ENTITY* ball2;

PANEL* first_pan =
{
	digits (30, 30, 2, *, 1, distance);
	flags = VISIBLE;
}

function main()
{
	level_load("small.wmb");
	wait(5);
	
	ball1 = ent_create("earth.mdl", vector(0, 0, 30), NULL);
	ball2 = ent_create("testball.mdl", vector(0, 0, 65), NULL);
	
	distance = vec_dist(ball1.x, ball2.x);
}



If you want to constantly update the distance, put the vec_dist calculation in a loop in your main function.

Last edited by Helghast; 03/01/10 09:35.

Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: problem understanding c_trace and vec_dist [Re: Helghast] #313547
03/02/10 00:20
03/02/10 00:20
Joined: Dec 2009
Posts: 71
N
ncc1701d Offline OP
Junior Member
ncc1701d  Offline OP
Junior Member
N

Joined: Dec 2009
Posts: 71
Thank you. Thats a huge help. I assumed I had to use c-trace but I was way over complicating this.
But now do I have to use c-trace somehow to display the distance from the ball to the the landcape on the floor of the level? I might think not based on what your telling me but then someone else mentioned i need that so I wanted your expert opinion on if I need c-trace to show distance from landscape ground and the ball. Thanks

Re: problem understanding c_trace and vec_dist [Re: ncc1701d] #313551
03/02/10 01:03
03/02/10 01:03
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
AFAIK it's okay to load a hmp (level_load("small.hmp")), not a wmb (this was impossible in prior gamestudio versions, though).

Quote:
I am trying to display the distance between 2 balls using those 2 types of code tools.

Quote:
But now do I have to use c-trace somehow to display the distance from the ball to the the landcape on the floor of the level?


Are you dealing with two different problems or is your issue just the first one? In the latter case Helghast's code is fine.


"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: problem understanding c_trace and vec_dist [Re: Superku] #313555
03/02/10 03:30
03/02/10 03:30
Joined: Dec 2009
Posts: 71
N
ncc1701d Offline OP
Junior Member
ncc1701d  Offline OP
Junior Member
N

Joined: Dec 2009
Posts: 71
It would be the same sitution only displaying distance from 1 ball to the ground


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