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
1 registered members (Grant), 999 guests, and 2 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
click-move script #270771
06/09/09 19:54
06/09/09 19:54
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
i am having trouble making a script that moves an entity when i click a certain position on the screen. heres what ive got:

////////////////////////////////
#include <pure.c>//this file only contains include acknex + default
////////////////////////////////
BMAP* cursor = "cursor.bmp";
ENTITY*p;
ENTITY*po;
ENTITY*flag;
var moving=0;
////////////////////////////////

function ajus()
{
VECTOR pos1, pos2;
pos1.x = mouse_pos.x;
pos1.y = mouse_pos.y;
pos1.z = 0;
vec_for_screen (pos1, camera);
pos2.x = mouse_pos.x;
pos2.y = mouse_pos.y;
pos2.z = 20000;
vec_for_screen (pos2, camera);
c_trace (pos1.x, pos2.x, IGNORE_PASSABLE);
moving=1;
}

action disker()
{
while(1)
{
vec_set(my.x,target);
wait(1);
}
}


action move()
{
my.pan=0;
VECTOR temp;
var cam_angle = 0;
var turn = 0;
VECTOR temp2;
p=me;
var anim_a;
var anim_b;
while(1)
{
vec_set(temp,target);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);


if(moving==0)
{
anim_a += 0.2;
ent_animate(me,"idle",anim_a,ANM_CYCLE);
}
else
{
anim_b += 2;
ent_animate(me,"run",anim_b,ANM_CYCLE);
c_move (my, vector(8*time_step, 0, 0), nullvector, GLIDE);
}

my.tilt=0;
camera.x = my.x - 200 * cos(my.pan);
camera.y = my.y - 200 * sin(my.pan);
camera.z = my.z + 50;
vec_set(temp2.x, my.x);
vec_sub(temp2.x, camera.x);
vec_to_angle(camera.pan, temp2);
wait(1);
}
}
MATERIAL* night =
{
ambient_blue = 50;
ambient_green = 50;
ambient_red = 50;
diffuse_blue = 50;
diffuse_green = 50;
diffuse_red = 50;
specular_blue = 50;
specular_green = 50;
specular_red = 50;
power = 10;
}
function main()
{
fps_max=60;
video_screen=1;
shadow_stencil=3;
mouse_mode=1;
mouse_map=cursor;
level_load("small.hmp");
ENTITY* sky = ent_createlayer("skycube+6.dds", SKY | CUBE | SHOW, 0);
sky.material=night;
on_mouse_left = ajus;
p = ent_create("armor knight.mdl",vector(0,100,20), move);
po = ent_create ("disk.mdl", target, disker);
set (po, TRANSLUCENT | PASSABLE);
set(p,SHADOW);
while (1)
{
vec_set(mouse_pos, mouse_cursor);
wait(1);
}
}


One day there will be an unfixable bug,
That day is not today.
Re: click-move script [Re: dakilla] #270772
06/09/09 19:56
06/09/09 19:56
Joined: Apr 2009
Posts: 141
dakilla Offline OP
Member
dakilla  Offline OP
Member

Joined: Apr 2009
Posts: 141
all this does is sinks the 'p' entity into the ground and when i click it starts running (no movement)


One day there will be an unfixable bug,
That day is not today.

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