Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 806 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Catching Crosshairs #310577
02/15/10 18:04
02/15/10 18:04
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline OP
Senior Member
Razoron  Offline 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: Razoron] #310589
02/15/10 19:44
02/15/10 19:44
Joined: Nov 2008
Posts: 216
J
jane Offline
Member
jane  Offline
Member
J

Joined: Nov 2008
Posts: 216
Hallo,
wie wäre es hiermit:

PANEL* Visier =
{
layer = 1;
bmap = "dein sprite"
flags = OVERLAY;
scale_x = deine grösse;
scale_y = deine grösse;
}

function show_visier()
{
set(visier, SHOW);
visier.pos_x = screen_size.x/2 -(16*visier.scale_x);
visier.pos_y = screen_size.y/2 -(16*visier.scale_y);
}

function hide_visier()
{
reset(visier, SHOW);
}

Mit der 16 rumspielen bis die Größe gefällt.

Gruß Jane

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 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
ich glaub, ehr meint das hier:
Code:
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.

Visit my site: www.masterq32.de
Re: Catching Crosshairs [Re: MasterQ32] #310604
02/15/10 21:20
02/15/10 21:20
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline OP
Senior Member
Razoron  Offline OP
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
Nice ideas of you, but this doesn't make sense:
Code:
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: Razoron] #310605
02/15/10 21:24
02/15/10 21:24
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Du must einfach einen Code in die Art machen.
Wenn die Distanz vom Flugzeug zu bezielten Flugzeug kleiner als ist, als die Distanz zum nächstnähesten Flugzeug, selektiere dieses Flugzeug.
Iwie so


Visit my site: www.masterq32.de
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 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
also so:
Code:
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);
	}
}




Visit my site: www.masterq32.de
Re: Catching Crosshairs [Re: MasterQ32] #310693
02/16/10 15:37
02/16/10 15:37
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline OP
Senior Member
Razoron  Offline OP
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
Gut, gut ich probiers aus. laugh

Re: Catching Crosshairs [Re: Razoron] #310963
02/17/10 22:02
02/17/10 22:02
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
kleine frage:
gehts?


Visit my site: www.masterq32.de

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