0 registered members (),
1,094
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
display XYZ to screen
#292585
10/05/09 00:25
10/05/09 00:25
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hello, I would like to displayed the XYZ of a object on the screen as it move around the map. I know I have to use str_cpy and STRING. what code do I need to put in the string. some thing like vec player (x,y,z)
Thank you renny
p.s. I know that you can see that by pressing I think f11 two time. I need it to be on the screen all the time.
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: display XYZ to screen
[Re: sadsack]
#292642
10/05/09 15:12
10/05/09 15:12
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Look into the manual for more information:
VECTOR object_pos;
PANEL* pnl_show_xyz = { digits(20,20,5,*,1,object_pos.x); digits(20,40,5,*,1,object_pos.y); digits(20,60,5,*,1,object_pos.z); flags = SHOW; layer = 1; }
function update_position_startup() { while(!player) { wait(1); } while(player) { vec_set(object_pos,player.x); wait(1); } }
should work.
"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: display XYZ to screen
[Re: Superku]
#292656
10/05/09 19:08
10/05/09 19:08
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hello H.F.Pohl, I been trying to make you code work for a hour or more, it will not compile. I may not have it in the right place. here what I been working on CODE:
#include <acknex.h>
#include <default.c>
ENTITY*player1;
function update_position_startup();
VECTOR object_pos;
PANEL* pnl_show_xyz = {
digits(20,20,5,*,1,player1_pos.x);
digits(20,40,5,*,1,player1_pos.y);
digits(20,60,5,*,1,player1_pos.z);
flags = SHOW;
layer = 1;
}
action act_player1();
{
player1 = me;
me.ambient = 10;
while(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);
}
}
function main()
{
level_load ("");
wait(2); // wait until the level is loaded
ent_create("player1.mdl", vector(500, 0, 0),act_player1);
}
function update_position_startup() {
while(!player1) { wait(1); }
while(player1) {
vec_set(object_pos,player1.x);
wait(1);
}
}
so if you have time to look at this and maybe point me to the right steps to take to make it work. Thank You renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: display XYZ to screen
[Re: yorisimo]
#292658
10/05/09 19:41
10/05/09 19:41
|
Joined: Feb 2006
Posts: 385 Oldenburg,Germany
Ralph
Senior Member
|
Senior Member
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
|
This code works:
ENTITY* player1;
VECTOR* object_pos = {x=0;y=0;z=0;}
PANEL* pnl_show_xyz = {
digits(20,20,"Player Position X=%.0f",*,1,object_pos.x);
digits(20,40,"Player Position Y=%.0f",*,1,object_pos.y);
digits(20,60,"Player Position Z=%.0f",*,1,object_pos.z);
flags = SHOW;
layer = 1;
}
function act_player1()
{
while(!me){wait(1);}
player1 = me;
me.ambient = 10;
while(me)
{
my.pan += 3 * (key_z-key_x) * time_step;
my.skill1 = 5 * (key_w-key_s) * time_step;
my.skill2 = 5 * (key_a-key_d) * time_step;
my.tilt += 3 * (key_c-key_v) * time_step;
my.roll += 3 * (key_r-key_t) * time_step;
c_move (me,my.skill1,nullvector,GLIDE);
vec_set(object_pos,player1.x);
wait(1);
}
}
function main()
{
level_load ("");
wait(2); // wait until the level is loaded
ent_create("cube.mdl",vector(500,0,0),act_player1);
}
Greetings Ralph
|
|
|
Re: display XYZ to screen
[Re: Ralph]
#292662
10/05/09 20:25
10/05/09 20:25
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Ralph, that code works fine.Thank you very much.
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: display XYZ to screen
[Re: sadsack]
#292683
10/05/09 23:56
10/05/09 23:56
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi Ralph, Well I intergraded your code into my space game, It took a will for me to make it work, but It is working very good now. I will not get lost again in deep space Thanks to you. There is some parts of your code that I do not under stand, do you have time to tell me what the line does, well I know what the line does I just don't know how it does it? sh...t I am on the quick reply, well maybe I still can use the code tab. Let see:
digits(20,20,"Player Position X=%.0f",*,1,object_pos.x);
I understand what this does
digits(20,20,"Player Position
but what does this do thank you for your help renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: display XYZ to screen
[Re: sadsack]
#292687
10/06/09 00:22
10/06/09 00:22
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
Hey,
digits(20,20,"Player PositionX="
writes Player PositionX= at 20, 20 uses c style string manipulation (and closes the string) tells the engine to use standard font (Arial#10 or Arial#12 i think) is the factor of what's displayed (change to 2 and everthing will be doubled) obvioulsy the variable being displayed hope this helps (sorry to intrude)
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|