Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Cursor location for crosshair
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
elDoRado




PostPosted: Sun Nov 13, 2011 7:37 pm   Post subject: Cursor location for crosshair

I'm trying to develop a simple fps, where the crosshair is your cursor, but i dont know how to
get cursor location to set the crosshair on..
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Sun Nov 13, 2011 7:55 pm   Post subject: RE:Cursor location for crosshair

You should bind the cursor to the corner or middle of the screen and then detect the amount of movements in any given direction.
Beastinonyou




PostPosted: Sun Nov 13, 2011 8:13 pm   Post subject: Re: RE:Cursor location for crosshair

ProgrammingFun @ Sun Nov 13, 2011 7:55 pm wrote:
You should bind the cursor to the corner or middle of the screen and then detect the amount of movements in any given direction.


Lol?

take a look at: Mouse.Where
ProgrammingFun




PostPosted: Sun Nov 13, 2011 8:31 pm   Post subject: Re: RE:Cursor location for crosshair

Beastinonyou @ Sun Nov 13, 2011 8:13 pm wrote:

Lol?

take a look at: Mouse.Where

I know mouse.where exists, I have used it before...but all FPS games have the mouse rooted to a certain area on the screen (including turing games on this site) because this is a more accurate (IMO) way to do it for a game that relies heavily on mouse precision.
Tony




PostPosted: Sun Nov 13, 2011 8:38 pm   Post subject: RE:Cursor location for crosshair

For that to work, you'd need to get the OS to not move the mouse cursor, and have it send mouse displacement events, rather than current location. As far as I remember, Turing is unable to do either.

The behaviour can sort of be emulated as long as the mouse doesn't leave the active window. Meaning no 360 degree turns (one could up the sensitivity, but that would only linearly increase the max turn amount)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ProgrammingFun




PostPosted: Sun Nov 13, 2011 8:52 pm   Post subject: RE:Cursor location for crosshair

I'm certain that I have seen it on a Turing app here somewhere...
Tony




PostPosted: Sun Nov 13, 2011 8:55 pm   Post subject: RE:Cursor location for crosshair

[citation needed]
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Aange10




PostPosted: Sun Nov 13, 2011 9:12 pm   Post subject: Re: RE:Cursor location for crosshair

Tony @ 13/11/2011, 7:55 pm wrote:
[citation needed]




*Facebook Like*
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Mon Nov 14, 2011 12:10 am   Post subject: RE:Cursor location for crosshair

Someone did do a 3D FPS game with 3D text, but he did not capture the mouse. He did do a pretty good job within his limits however.

I was more annoyed at the fact he did procs for each letter than trying to load a polygon file.
elDoRado




PostPosted: Mon Nov 14, 2011 7:07 am   Post subject: RE:Cursor location for crosshair

I appreciate it,
Like, what I had inmind was
cursor location, than 4 bars, 3x16 black,
and 2 verticals and 2 horizontals, and i would determine placing by mouse location

for ie: x, y <mouse locations

crosshair A- the top 1
xvalue = x
yvalue = y + 5 to move it 5 above.. see where i'm coming from? :/
I'm only a grade 11 student..
evildaddy911




PostPosted: Mon Nov 14, 2011 8:04 am   Post subject: Re: Cursor location for crosshair

if you want to make the crosshairs start at the center of the screen, then make a variable that stores the mouse's location when the game starts, then use mousewhere to detect where the mouse is in relation to the initial values:

Turing:
var initialx, nowy, nowx, relatedy, mx, my, mb : int
mouse.where(mx, my, mb)
initialx := mx
initialy := my

loop
mousewhere(mx, my, mb)
nowx:=initialx-mx
nowy:=initialy-my

drawcrosshairs(maxx div 2+nowx, maxy div 2+nowy)

end loop
Aange10




PostPosted: Mon Nov 14, 2011 12:39 pm   Post subject: Re: RE:Cursor location for crosshair

Zren @ 13/11/2011, 11:10 pm wrote:

I was more annoyed at the fact he did procs for each letter than trying to load a polygon file.



What is that?
Zren




PostPosted: Mon Nov 14, 2011 12:48 pm   Post subject: Re: RE:Cursor location for crosshair

Aange10 @ Mon Nov 14, 2011 12:39 pm wrote:
Zren @ 13/11/2011, 11:10 pm wrote:

I was more annoyed at the fact he did procs for each letter than trying to load a polygon file.



What is that?


Turing:

procedure letterV (d : real) % O
    tempsofie += 1
    Othello (tempsofie, d + 150, 150, 150, 100, 100, 100, 55)
    tempsofie += 1
    initializeslantyface (tempsofie, d + 120, 180, 80, d + 120, 170, 80, d + 150, 130, 80, d + 150, 120, 80, 39)
    tempsofie += 1
    initializeslantyface (tempsofie, d + 150, 130, 80, d + 150, 120, 80, d + 180, 180, 80, d + 180, 170, 80, 39)
end letterV

Like that... but for every character.

http://compsci.ca/v3/viewtopic.php?t=29073
Aange10




PostPosted: Mon Nov 14, 2011 2:11 pm   Post subject: RE:Cursor location for crosshair

I know what a procedure is, what's a polygon file?
evildaddy911




PostPosted: Mon Nov 14, 2011 2:30 pm   Post subject: Re: Cursor location for crosshair

i think a better idea than the initialx,nowx would be

Turing:
var x,y,b:int

proc crosshair (x, y : int)
    drawoval (x, y, 10, 10, black)
    drawline (x, y + 10, x, y - 10, black)
    drawline (x - 10, y, x + 10, y, black)
end crosshair
crosshair (maxx div 2, maxy div 2)
loop
mousewhere (x,y,b)
exit when x=maxx div 2 and y=maxy div 2 %stops program until the mouse is in the center of the play area
end loop

% main loop
loop
mousewhere(x,y,b)
crosshair(x,y)
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: