Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Quad, EternallyCurious, 1 invisible), 726 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pick weapon by moving the mouse on a panel #382832
09/13/11 08:44
09/13/11 08:44
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hi, topic sounds simpler than it is.

When I click right and hold the mouse pressed a panel opens:


Now, depending on the mouse position, an area on this panel should be selected. Even if the mouse is not on the panel but in the top cone, the left cone, the bottom cone or the right cone.

When I release the right mouse button the appropriate weapon should be selected.

Does anybody know a nice algorithm to map the mouse position to a panel area?

Thanks!


Last edited by PadMalcom; 09/13/11 08:45.
Re: Pick weapon by moving the mouse on a panel [Re: PadMalcom] #382841
09/13/11 10:20
09/13/11 10:20
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
Just calculate the angle from the center of the screen to the mouse position.

Re: Pick weapon by moving the mouse on a panel [Re: bart_the_13th] #382842
09/13/11 10:29
09/13/11 10:29
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Alternatively, use two HNFs...

Re: Pick weapon by moving the mouse on a panel [Re: Slin] #382843
09/13/11 10:55
09/13/11 10:55
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
2 nice ideas, thanks a lot! laugh

Re: Pick weapon by moving the mouse on a panel [Re: PadMalcom] #382847
09/13/11 11:35
09/13/11 11:35

C
chris_oat
Unregistered
chris_oat
Unregistered
C



maybe, but dont hate me if its total bullshit just writting my thoughts, maybe you lay a invisible image over the whole screen and fill them with 4 diffent colors as cones.
Then maybe its possible to detect over which of the colors the mouse is moving?!
Similar to colormap for terrains...but different.
Again, maybe its total crap what i say... laugh

Last edited by chris_oat; 09/13/11 11:36.
Re: Pick weapon by moving the mouse on a panel [Re: ] #382851
09/13/11 12:15
09/13/11 12:15
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline OP
Serious User
PadMalcom  Offline OP
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
The idea is good, but I think the performance is not wink The way you propose needs memory for 4 more images instead of a 2 line vector calculation as proposed by bart. But thank you for thinking laugh

Re: Pick weapon by moving the mouse on a panel [Re: PadMalcom] #382854
09/13/11 12:26
09/13/11 12:26
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Code:
#include <acknex.h>
#include <default.c>

void main(){
	
	wait(1);
	
	mouse_mode = 4;
	
	PANEL* pnl = pan_create("", 1);
	pnl.bmap = bmap_createblack(128, 128, 32);
	bmap_fill(pnl.bmap, COLOR_GREEN, 100);
	pnl.pos_x = 128; pnl.pos_y = 128;
	pnl.center_x = 64; pnl.center_y = 64;
	set(pnl, SHOW);
	
	var x, y, at, dx, dy;
	while(1){
		
		x = mouse_pos.x - 64 - pnl.pos_x;
		y = mouse_pos.y - 64 - pnl.pos_y;
		at = atan2v(x, y);
		
		if(mouse_panel){
			
			//determines the distance
			dx = mouse_pos.x - (pnl.pos_x + 64);
			dy = mouse_pos.y - (pnl.pos_y + 64);
			if(sqrt(dx*dx + dy*dy) <= 64){
				
				//determines the angle
				if((at > -135) && (at <= -45)){
					DEBUG_VAR(4, 20);
				}else if((at > -45) && (at <= 45)){
					DEBUG_VAR(3, 20);
				}else if((at > 45) && (at <= 135)){
					DEBUG_VAR(2, 20);
				}else{
					DEBUG_VAR(1, 20);
				}
				
			}
		}
		wait(1);
	}
}




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