|
Post by hartnell on May 3, 2007 0:45:00 GMT -5
I understand that mouse.y is offset by the title bar of the window in windowed mode, but, why?
--hartnell
|
|
|
Post by Guilect on May 3, 2007 6:47:45 GMT -5
Clipped would actually be a better word than offset.
Why... Let us say that you create a 640 x 480 window. This includes a titlebar (it is windowed mode and this is what you get; don\'t want a titlebar use fullscreen). Therefore, the client area has to be less than the 480 in height. How much less, the height of the titlebar.
Why not make the client area the 640 x 480 you ask... because then you could not get to the titlebar to minimize or maximize or use the \"x\" or see text in the title in the case that the desktop resolution = the window size.
In the purest sense, when you create a 640 x 480 size window you get a 640 x 480 sized window and all the characteristics that go along with that.
|
|
|
Post by hartnell on May 3, 2007 21:56:09 GMT -5
ok, i don't get why the window "resolution" matters. What matters is that pixel zero match up for both setting images and the mouse.
Some (read: all I'm aware of) game programming languages do it this way :
mouse.x = mouse x in relation to screen mouse.WorldX = mouse x in relation to game level
-hartnell
|
|
|
Post by u9 on May 4, 2007 6:09:54 GMT -5
Jamagic had something like
mouse.getx() - X position of mouse relative to window where pixel 0,0 was the upper left corner mouse.getscreenx() - X position of mouse relative to the desktop, i.e. the entire screen
In both commands the pixels returned had the same resolution (or size) as the window so if i got 639 from mouse.getx() and my window was 640 pixels wide then the mouse was positioned to the right edge of the window (not including the borders)
In my opinion the border has nothing to do with the application. It is just "eye-candy" applied by the operating system which provides the window.
|
|
|
Post by Guilect on May 4, 2007 6:25:20 GMT -5
I can add a Global (screen or world) mouse position command.
|
|
|
Post by u9 on May 4, 2007 10:05:42 GMT -5
I don't know if global mouse coordinates can be used for anything in Brutus2D as it is currently. You really would need translation between global coordinates and your window's coordinate system also.
|
|
|
Post by hartnell on May 4, 2007 13:08:48 GMT -5
I get lost using the mouse.... need compass.... -- hartnell
|
|
|
Post by u9 on May 5, 2007 5:44:13 GMT -5
Here's a question. How do you make a drawing program using the mouse? Here's my attempt, but the mouse isn't positioned where i draw.
graphics.initialize graphics.display key.initialize mouse.initialize
running = True Do While running If key.pressed( 0 ) Or key.pressed( 1 ) Then running = False
If mouse.leftButton And (mouse.dx <> 0 Or mouse.dy <> 0) Then graphics.setpoint mouse.x, mouse.y, argb(180, 255, 255, 255) graphics.display End If system.processMessages Loop
mouse.terminate key.terminate graphics.terminate
|
|
|
Post by Guilect on May 5, 2007 8:35:06 GMT -5
good demonstration to illustrate the issue. I have implemented a change that makes the graphics match the mouse position. The side effect is that, in windowed mode, the mouse.x and mouse.y now only update when the mouse is in that window. This is a request some users had anyways. So perhaps this takes care of 2 things at once. This version also has all of the v1.8 additions/changes mentioned in official post thread. Let me know what you think after trying it out. (unzip both files to your B2D install directory) brutus.pewtersoftware.com/upload/files/Brutus2Dv18Beta.zip
|
|
|
Post by u9 on May 6, 2007 7:55:58 GMT -5
Well, the executable is not fixed at all, and now when running from the editor the coordinates still get updated when the mouse is outside the window and a mouse button is pressed.
I don't care if the coordinates get updated outside the window. I have made a work-around for that. The biggest problem is that the coordinates don't match the window's coordinates, but that seems to be fixed now when running from the editor.
|
|
|
Post by u9 on May 6, 2007 8:44:58 GMT -5
Why don't the two texts in this code start at the same position any more? It seems like the pink text starts depending on where the program exited last run, or where the mouse is positioned when i press f5, i'm not sure.
|
|
|
Post by u9 on May 6, 2007 8:53:16 GMT -5
Mouse.SetPosXY is F**ked... I set the position at e.g. the middle of the screen and if i read it i get something else back. I modified this code to use my mouse class but the results show a small problem. include "GameMouse.b2d"
Call main
Sub main() graphics.initialize 800, 600 key.initialize Dim mouse Set mouse = New GameMouse Dim x, y x = mouse.x y = mouse.y Dim font font = graphics.createFont( "system", 10 ) Dim bRunning bRunning = True Do While Not( key.pressed( 0 ) Or key.pressed( 1 ) ) mouse.update ' I subtract here due to small error in v1.7.1 x = x - mouse.dx y = y - mouse.dy graphics.clear graphics.settext "mouse.x and y", mouse.x - 20, mouse.y - 8, font, &h99ffff00 graphics.settext "mouse.Dx and Dy", x - 20, y - 8, font, &h99ff0066 graphics.display system.pause 10 Loop Set mouse = nothing key.terminate graphics.terminate End Sub
|
|
|
Post by Guilect on May 6, 2007 12:08:07 GMT -5
Not on my system. The mouse.x and mouse.y do not update when the mouse cursor is outside of the B2D window.
The change in the exe was only to the window co-ordinate system for mouse.x and mouse.y. Are you asking to have this behavior changed as well?
It is still off by borders and titlebars and such. It will be re-examined.
|
|
|
Post by Guilect on May 6, 2007 20:36:56 GMT -5
OK. The only way to fix the mouse.setposXY was to make the Client Area = the requested resolution (e.g. 640 x 480). That means that the overall window in bigger by the borders and titlebar in windowed mode. Please evaluate the fix for mouse.setposXY. brutus.pewtersoftware.com/upload/files/Brutus2Dv18Beta.zip
|
|
|
Post by u9 on May 8, 2007 4:08:35 GMT -5
This is one sentence. There are not two statements here that need a reply. One sentence and one issue. It only happens if a mouse button is pressed. Probably becuase update gets called inside these functions. [...] Not on my system. The mouse.x and mouse.y do not update when the mouse cursor is outside of the B2D window. The change in the exe was only to the window co-ordinate system for mouse.x and mouse.y. Are you asking to have this behavior changed as well? I don't understand this. The only think I have ever asked for is that the coordinates of the mouse be usable, i.e. correspond to the pixel underneath the mouse. OK. The only way to fix the mouse.setposXY was to make the Client Area = the requested resolution (e.g. 640 x 480). That means that the overall window in bigger by the borders and titlebar in windowed mode. Hartnell, when you create a window, do you expect you drawing canvas to be the size you requested, or the entire window including borders? I.e. you request a window 640x480 and your get a drawable area of 634x448? or would you expect a drawable area of 640x480? Personally I would expect a drawable area of 640x480. Now I actually am beginning to understand the problems i get when drawing my filled circle. All my drawing command's coordinates have to be scaled. Scaling everything is a really bad idea in my opinion. It makes "game area" different size on each computer that has a different theme. Some themes actually have quite a large title bar. In a small window these variations can get quite signifficant. I haven't had time to try the now version.
|
|