0 registered members (),
806
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Catching Crosshairs
#310577
02/15/10 18:04
02/15/10 18:04
|
Joined: May 2009
Posts: 445 Peine, Germany
Razoron
OP
Senior Member
|
OP
Senior Member
Joined: May 2009
Posts: 445
Peine, Germany
|
Hey guys, I have no idea how I could make the crosshair in my dogfight game catching near other planes. Any idea how to code this?
Last edited by Razoron; 02/15/10 18:49.
|
|
|
Re: Catching Crosshairs
[Re: jane]
#310598
02/15/10 20:42
02/15/10 20:42
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
ich glaub, ehr meint das hier:
PANEL* pan_crosshair =
{
bmap = your_bmap;
}
ENTITY* nearest_plane;
function crosshair()
{
VECTOR temp;
while(1)
{
if(nearest_plane != NULL) // check if nearest plane exists
{
vec_set(temp,nearest_plane.x);
if (vec_to_screen(temp,camera) != NULL) // if visible on screen, convert to screen coordinates
{
pan_crosshair.pos_x = integer(temp.x - bmap_width(your_bmap) / 2); // place the crosshair
pan_crosshair.pos_y = integer(temp.y - bmap_height(your_bmap) / 2);;
set(pan_crosshair,SHOW);
}
else
{
reset(pan_crosshair,SHOW);
}
}
else
{
reset(pan_crosshair,SHOW);
}
wait(1);
}
}
action plane()
{
while(me)
{
if(vec_dist(my.x,camera.x) < vec_dist(nearest_plane.x,camera.x)) // Check if not the nearest plane
nearest_plane = me; // Set to the nearest plane
wait(1);
}
}
Replace your_bmap with the crosshair bmap. The nearest_plane is the entity which has the crosshair on it.
Last edited by Richi007; 02/15/10 20:45.
|
|
|
Re: Catching Crosshairs
[Re: MasterQ32]
#310604
02/15/10 21:20
02/15/10 21:20
|
Joined: May 2009
Posts: 445 Peine, Germany
Razoron
OP
Senior Member
|
OP
Senior Member
Joined: May 2009
Posts: 445
Peine, Germany
|
Nice ideas of you, but this doesn't make sense:
action plane()
{
while(me)
{
if(vec_dist(my.x,camera.x) < vec_dist(nearest_plane.x,camera.x)) // Check if not the nearest plane
nearest_plane = me; // Set to the nearest plane
wait(1);
}
}
nearest_plane might be the nearest plane of the camera, but not the nearest plane of the crosshair. The player can also Shoot planes, which aren't the neartest of the camera, just the nearest to the crosshair. Nochmal in deutsch: Der Spieler kann doch aber auch das Flugzeug, was am meisten weg ist abschiessen und darauf zielen. Wenn direkt hinter ihm ein anderer ist, ist nearest_plane zwar dieser Gegner, aber das, was er eigentlich abschiessen will ist vielleicht ein anderer. EDIT: Oder nochmal ein anders Beispiel: Das Crosshair ist in der Mitte des Bildschirms. Jetzt fliegt ein anderes, feindliches Flugzeug an ihm vorbei. Das Flugzeug befindet sich vielleicht mit vec_to_screen 30 pixel weiter auf der X-Achse vom Crosshair entfernt. Der Crosshair schlägt aus und bewegt sich 30 pixel nach rechts, sodass er auf das Flugzeug, den Gegner zeigt. Der Gegner muss aber nicht der nähste Gegner sein.
Last edited by Razoron; 02/15/10 21:25.
|
|
|
Re: Catching Crosshairs
[Re: MasterQ32]
#310615
02/15/10 22:43
02/15/10 22:43
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
also so:
action plane_nearto_screen()
{
VECTOR temp;
while(me)
{
vec_set(temp,my.x);
if (vec_to_screen(temp,camera) != NULL) // if visible on screen, convert to screen coordinates
{
if(vec_dist(temp,vector(screen_size.x / 2,screen_size.y / 2,0)) < 30) // Distanz zur Bildschirmmitte kleiner 30
{
nearest_plane = me; // Set to the nearest plane
}
}
wait(1);
}
}
|
|
|
|