Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
vec_for_screen and vec_to_screen Frustrations #140269
07/10/07 03:53
07/10/07 03:53
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I can't seem to get anything to work right. I try to look at the manual, and improvise from there to fit my needs, but no cigar.

I just want to make it so that you can touch the entity with the mouse and light it up, but apparently it's way more complicated than I thought.

Here's my Code:

var video_mode= 8;
var video_screen= 1;
var video_depth= 32;

bmap cur= "bcursor.pcx";

function mouse_toggle()
{
mouse_mode+= 1;
mouse_mode%= 3;
mouse_map= cur;
while(1)
{
mouse_pos.x= pointer.x;
mouse_pos.y= pointer.y;
wait(1);
}
}

function main()
{
level_load ("vec_test.wmb");
on_m= mouse_toggle;
while(1)
{
vec_for_screen(vector(mouse_pos.x,mouse_pos.y,-1000),camera);
wait(1);
}
}

action dummy_cam
{
my.fat= on;
my.narrow= on;
c_setminmax(me);
while(1)
{
camera.x= my.x;
camera.y= my.y;
camera.z= my.z;
my.pan= camera.pan;
my.tilt= camera.tilt;
my.roll= camera.roll;
if (mouse_left== on) && (mouse_mode<= 1)
{
c_move (my,vector(20 * time_step,0,0),nullvector,glide);
}
if(mouse_right== on) && (mouse_mode<= 1)
{
c_move (my,vector(-20 * time_step,0,0),nullvector,glide);
}
if(mouse_left== on) && (key_shift== on) && (mouse_mode<= 1)
{
c_move (my,vector(30 * time_step,0,0),nullvector,glide);
}
if(key_z== on) && (mouse_mode<= 1)
{
c_move (my,vector(0,10 * time_step,0),nullvector,glide);
}
if(key_x== on) && (mouse_mode<= 1)
{
c_move (my,vector(0,-10 * time_step,0),nullvector,glide);
}
camera.pan-= mouse_force.x * 10 * time_step;
camera.tilt+= mouse_force.y * 10 * time_step;
wait(1);
}
}

function light_event()
{
if(event_type== event_touch)
{
my.ambient= 200;
}
}

action light_when_touched
{
my.enable_touch= on;
my.event= light_event;
my.polygon= on;
while(1)
{
vec_to_screen(vector(my.x,my.y,my.z),camera);
wait(1);
}
}



EDIT: Sorry for the "tone", I'm just a little frustrated.

Last edited by MrCode; 07/10/07 04:26.

Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: vec_for_screen and vec_to_screen Frustrations [Re: MrCode] #140270
07/10/07 06:38
07/10/07 06:38
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
it's not so hard
and in this case you don't need to vec_to_scrreen or vec_for_screen function

in main function:
mouse_mode =1;
mouse_range = 9999;

in entity's action:
my.enable_touch = on;
my.enable_release = on;
my.event = some_event;

function some_event
{
if(event_type == event_touch){my.transparent = on; my.flare = on;}
if(event_type == event_release){my.transparent = off; my.flare = off;}
}

BTW:
vec_to_scrren you are usin when you want to check if something is visible on the screen, f.e. if sun is visible create flare
Code:

vec_set(temp,you.x); //you = sun, enemy... etc
if (vec_to_screen(temp,camera)){make some action like create panel or flare etc}



vec_for_scrren you are using when you want to f.e. trace from camera to mouse position in 3d world to create f.e. bullet hole on the wall
Code:

MOUSE_POS.x = pointer.x; MOUSE_POS.y = pointer.y;
temp.x = MOUSE_POS.x;
temp.y = MOUSE_POS.y;
temp.z = 1000; //this could be f.e. gun range
vec_for_screen(temp,CAMERA);
c_trace(player.x,temp,ignore_me | ignore_passable);
if(mouse_left ==1) && (result !=0){vec_set(temp.x,target);ent_CREATE("hole.tga",temp.x,hole_function};




Last edited by tompo; 07/10/07 07:10.
Re: vec_for_screen and vec_to_screen Frustrations [Re: tompo] #140271
07/10/07 19:45
07/10/07 19:45
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Ok, but it's still not doing anything. Maybe I need to put the ifs into a while(1) loop?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: vec_for_screen and vec_to_screen Frustrations [Re: MrCode] #140272
07/10/07 22:19
07/10/07 22:19
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
About vec_for_screen / vec_to_screen:
Of'course You have to put those codes into a loop

About events:
You don't have to


Never say never.

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