Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Share Worlds (http://www.alice.org/community/forumdisplay.php?f=6)
-   -   Great mouse aiming engine. (http://www.alice.org/community/showthread.php?t=8190)

arty-fishL 03-08-2012 06:41 PM

Great mouse aiming engine.
 
1 Attachment(s)
X asked me to make this, so I did :).
I have made a very promising mouse aiming engine. I'm sure you will like it.

This one is a culmination of previous methods and new methods, to make an all-in-one super engine.
This one:
- Centres the cursor, this is much better than the silly method of capturing it every time it hits an edge.
- Automatically calibrates, so none of that clicking dots rubbish.
- Hides the cursor, so the unnecessary thing isn't whizzing across the screen distorting your view.
- Can be toggled on/off (the cursor can be unlocked/locked with F1 by default), so you don't have to use extreme measures to exit the game.
- Is quite smooth and doesn't jump, unlike some other engines.

Other features:
- Can make window non-resizable (necessary as calibration only happens once)
- Can make window stationary, so it cannot be moved (again necessary, but both these features are only activated after calibration, so time can be given beforehand to make the window perfect).
- Has a method for resizing the window. This is useful if you are rubbish with calibration or need to force certain dimensions.
- Can disable speed bar (not yet optional, variable is just placeholder)
- Can disable restart button (necessary as it causes errors, stop then play to restart).

HELP CAN BE FOUND UNDER INFORMATION METHOD
PRESS F1 TO UNLOCK/RE-LOCK THE MOUSE

Mr Kidnapper 03-08-2012 08:26 PM

The camera turn is very smooth, especially compared to mine. Yeaah. Found out why. Now to reverse-engineer it.
I don't really see the point in making calibration happen only once if you can have it re-calibrate every ten or so seconds.
Don't quite understand what basicThread is supposed to do. Seems to be unfinished.

arty-fishL 03-09-2012 09:48 AM

[QUOTE=Mr Kidnapper;47232]The camera turn is very smooth, especially compared to mine. Yeaah. Found out why. Now to reverse-engineer it.
I don't really see the point in making calibration happen only once if you can have it re-calibrate every ten or so seconds.
Don't quite understand what basicThread is supposed to do. Seems to be unfinished.[/QUOTE]Calibration happens only once because I couldn't be bothered moving it to a separate function and messing up the code after I realised I should probably make it calibrate more. I am working on an update where it calibrates again when you press F1 though, every 10 seconds is a waste of resources if the window isn't going to be changed or moved unless the mouse is visible, so it will calibrate upon locking/unlocking the mouse (F1).

Its not unfinished. basicThread uses threading (alas "from threading import Thread"). I called it basicThread as it is a class within a method, so I didn't know what to name it and since it is a basic threading class (using default initialiser) I called it "basicThread". I would expect you to know what threading is, as you seem so advanced, but nevertheless I will explain:
Only one line can be performed at a time in python. While a script is being run the Alice world actually freezes until it finishes. This is OK for most short functions, but for a looping function with a time.sleep in it, it would cause either extreme lag or a complete lockup. By running it in a thread the code runs simultaneously in a separate thread, making it efficient.

By all means just use my code, reverse engineer it if you want, but the script can just by copied and pasted and the Alice code is fairly concise (as scripting does the majority of the work), plus it is documented in the INFORMATION method.

arty-fishL 03-09-2012 10:03 AM

I am working on an update.

[U]Known bugs:[/U]
[B]- [/B]window size increases each time the world is played and setupWindow is called.[B] > [COLOR=DarkGreen]FIXED[/COLOR][/B]
[B]- [/B]sensitivity is useless[B] > [COLOR=DarkGreen]FIXED[/COLOR][/B], plus I increased the max sensitivity to 100, 100 being max speed and 0 being min. FYI - invalid values perform like so: 101 = no movement, > 101 = inverted turning, < 0 = even slower than min speed (pointless).
- enableSpeedBar var does nothing [B]> [COLOR=DarkOrange]WORKING ON IT
[/COLOR][/B]- enabling restart button and using it causes errors [B]> [COLOR=DarkOrange]WORKING ON IT[/COLOR][/B]
- cursor is not properly centred[B] > [COLOR=DarkGreen]FIXED[/COLOR][/B]
- the INFORMATION method had some incorrect information[B] > [COLOR=DarkGreen]FIXED[/COLOR][/B], plus I added an update log comment and a todo comment.

[U]Feature improvements:[/U]
- repeatable calibration [B]> [COLOR=DarkOrange]WORKING ON IT[/COLOR][/B]
- automatically repeated calibration [B]> [COLOR=DarkOrange]WORKING ON IT[/COLOR][/B]
- add a mouse smoothing option (like when you press F8 in Minecraft).[COLOR=Red][B][COLOR=black] > [/COLOR]WILL WORK ON IT
[/B][/COLOR]

x2495iiii 03-11-2012 01:04 PM

Is the mouse in the very center of the screen while the engine is running? I tried testing with a makeshift crosshair and it seemed to be a little bit under the center, but since it's invisible, it's hard to tell.

arty-fishL 03-11-2012 05:38 PM

[QUOTE=x2495iiii;47303]Is the mouse in the very center of the screen while the engine is running? I tried testing with a makeshift crosshair and it seemed to be a little bit under the center, but since it's invisible, it's hard to tell.[/QUOTE]You are correct, in the version that is posted the mouse is off-centre. I have fixed it, but not released the update yet (see my post above yours).

The problem was I accidentally used half the width for the Y value, rather than half the height, so it was below the middle. It isn't a big issue, since you can't actually see the cursor and it doesn't really need to be dead-centre, but I fixed it anyway.

x2495iiii 03-11-2012 05:54 PM

The reason I asked you to make the engine was to enable cursor-locked FPS type games, and those have the cursor locked dead center, so for that purpose it does matter.

Thank you for for fixing it, arty. Your wizardry knows no bounds.

arty-fishL 03-11-2012 06:06 PM

1 Attachment(s)
[QUOTE=x2495iiii;47313]The reason I asked you to make the engine was to enable cursor-locked FPS type games, and those have the cursor locked dead center, so for that purpose it does matter.

Thank you for for fixing it, arty. Your wizardry knows no bounds.[/QUOTE]Here is the partially finished update if you want it.
It has the window size, wrong INFORMATION, sensitivity and centring glitches fixed.

I forgot to mention the play window goes transparent upon losing focus, because that's cool. There is also an (unrelated) glitch that happens upon losing focus; if the window is clicked again the cursor disappears, but is not locked, so F1 needs double tapped, there is sometimes an error too.

zeekthegamer 03-12-2012 02:45 AM

Nice mouse game you made. lt sure does run smooth. :)

arty-fishL 03-12-2012 09:28 AM

[QUOTE=zeekthegamer;47331]Nice mouse game you made. lt sure does run smooth. :)[/QUOTE]Thanks. Its not a game, its just an engine, but you can make it into a game if you want.


All times are GMT -5. The time now is 08:53 AM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.