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
3 registered members (AndrewAMD, TipmyPip, OptimusPrime), 15,359 guests, and 7 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
Page 1 of 2 1 2
Adding a Crosshair #175557
12/31/07 19:21
12/31/07 19:21
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
I have been working with workshop 33 from AUM to create a weapon and moving bullets. I am curious if it is possible to add a crosshair to my weapon. I tried placing it in the middle of the screen like a permanent panel but its not acurate. Is there any other way to make it acurate? or perhaps there is a better way to create weapons.

Thanks.

Re: Adding a Crosshair [Re: NeoK] #175558
12/31/07 19:40
12/31/07 19:40
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
Or adding a laser sight might work too. Just have no idea how to accomplish that, Only been working with GameStudio for about 1 week.

Thanks

Re: Adding a Crosshair [Re: NeoK] #175559
12/31/07 19:43
12/31/07 19:43
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
//From one of the earlier AUMS...

bmap crosshair_map = <cross.tga>;//define the image file

panel crosshair_pan//create the window panel
{
bmap = crosshair_map;
layer = 20;
pos_x = 0;
pos_y = 0;
flags = transparent, overlay, refresh, d3d;
}


//then inside your player action
crosshair_pan.pos_x = screen_size.x / 2 - 32; // the crosshair has 16x16 pixels
crosshair_pan.pos_y = screen_size.y / 2 - 16;

//followed by the while loop
while (my.health > 0)
{
crosshair_pan.visible = on;

the rest of your code here...

Re: Adding a Crosshair [Re: Nems] #175560
01/01/08 12:55
01/01/08 12:55
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
Thank you for your reply.

Does not seem to be working, I am getting some errors on compile. Maybe I am forgetting something obvious. Only been working with programming/Gamestudio for about a week.

Re: Adding a Crosshair [Re: NeoK] #175561
01/01/08 16:14
01/01/08 16:14
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
hello

what says the error?


"empty"
Re: Adding a Crosshair [Re: flits] #175562
01/02/08 15:13
01/02/08 15:13
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
I get an error when it gets to the following lines.

crosshair_pan.pos_x = screen_size.x / 2 - 32; // the crosshair has 16x16 pixels
crosshair_pan.pos_y = screen_size.y / 2 - 16;

And

crosshair_pan.visible = on;

I am guessing I need to define crosshair_pan.pos and screen_size. Not exactly sure how to go about doing that.

Will this gode put my crosshair in line with bullets? In Workshop 33 bullets come out of a vertex that is the muzzle of the weapon itself, If I place crosshair in middle of the screen it will not work. I am guessing I would need bullet to originate at the crosshair in order for it to be accurate. Like I said I am new to game development and not sure what is the best way to do this.

Thanks for any good info / ideas.

Re: Adding a Crosshair [Re: NeoK] #175563
01/02/08 17:15
01/02/08 17:15
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
Alright, I figured it out. I set the bulet starting point at camera.x and now the bullet is created in the center, not at weapon barrel.

Re: Adding a Crosshair [Re: NeoK] #175564
01/02/08 17:20
01/02/08 17:20
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
you need a panel for that

panel crosshair_pan
{
bmp = "croshair.bmp";
my.visible = on;
}

Code:

function waepon
{
crosshair_pan.pos_x = (screen_size.x + crosshair_pan.size_x)/ 2;
// the crosshair has 16x16 pixels
crosshair_pan.pos_y = (screen_size.y + crosshair_pan.size_y)/ 2;
var mousel;
while(my != null)
{
vec_set(temp,vector(10000,0,0));//10000 ore longer
vec_rotate(temp,camera.pan);
vec_add(temp,camera.pan);
c_trace(camera.x,temp,ignore_me);// knows where the camera looks to

vec_set(temp,target.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);//turns the weapon to the target
// close to the wall turns the weapon much

if(mouse_left == on && mousel == 1)
{
you = ent_create("bullet.mdl",nullvector,bullet_func);
vec_for_vertex(temp,my,22);//vertex(22) on the end of the loop
vec_set(you.x,temp);
vec_set(you.pan,my.pan);
mousel ==0;
}
if(mouse_left == off)
{
mousel = 1;
}
wait(1);
}
}




"empty"
Re: Adding a Crosshair [Re: flits] #175565
01/03/08 08:11
01/03/08 08:11
Joined: Dec 2007
Posts: 13
N
NeoK Offline OP
Newbie
NeoK  Offline OP
Newbie
N

Joined: Dec 2007
Posts: 13
is this C-script or Lite-C? compiler does not understand the keyword panel.

Re: Adding a Crosshair [Re: NeoK] #175566
01/03/08 09:09
01/03/08 09:09
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
its

panel for csript and PANEL* for lite-c


3333333333
Page 1 of 2 1 2

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