|
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
OP
Serious User
|
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: bart_the_13th]
#382842
09/13/11 10:29
09/13/11 10:29
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
Alternatively, use two HNFs...
|
|
|
Re: Pick weapon by moving the mouse on a panel
[Re: PadMalcom]
#382847
09/13/11 11:35
09/13/11 11:35
|
chris_oat
Unregistered
|
chris_oat
Unregistered
|
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...
Last edited by chris_oat; 09/13/11 11:36.
|
|
|
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
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
#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);
}
}
|
|
|
|