PDA

View Full Version : Great mouse aiming engine.


arty-fishL
03-08-2012, 05:41 PM
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, 07: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, 08:48 AM
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.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, 09:03 AM
I am working on an update.

Known bugs:
- window size increases each time the world is played and setupWindow is called. > FIXED
- sensitivity is useless > FIXED, 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 > WORKING ON IT
- enabling restart button and using it causes errors > WORKING ON IT
- cursor is not properly centred > FIXED
- the INFORMATION method had some incorrect information > FIXED, plus I added an update log comment and a todo comment.

Feature improvements:
- repeatable calibration > WORKING ON IT
- automatically repeated calibration > WORKING ON IT
- add a mouse smoothing option (like when you press F8 in Minecraft). > WILL WORK ON IT

x2495iiii
03-11-2012, 12: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, 04:38 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.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, 04: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, 05:06 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.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, 01:45 AM
Nice mouse game you made. lt sure does run smooth. :)

arty-fishL
03-12-2012, 08:28 AM
Nice mouse game you made. lt sure does run smooth. :)Thanks. Its not a game, its just an engine, but you can make it into a game if you want.

lolgast
03-15-2012, 05:08 AM
Whoah, this is really amazing. Wouldn't have thought something like this was possible in Alice. Very useful for a lot of things. Thank you for making/posting this :D

arty-fishL
03-15-2012, 01:27 PM
Whoah, this is really amazing. Wouldn't have thought something like this was possible in Alice. Very useful for a lot of things. Thank you for making/posting this :DThanks. I will update it, but I am working on a different project right now. :)

room14
03-15-2012, 10:13 PM
I am not sure about this since I haven't downloaded it yet but you should make it as an object.

arty-fishL
03-16-2012, 04:02 AM
I am not sure about this since I haven't downloaded it yet but you should make it as an object.
good idea

lolgast
03-16-2012, 06:40 AM
But what I'm wondering, how do those scripts work? I don't think I've enough knowledge to actually program those scripts, but can anyone tell me where I can find some information about scripts?

Mr Kidnapper
03-16-2012, 06:18 PM
Making it as an object is not possible the moment he included scripting. Script code beyond the level of "world", as in any script inside of a class, does not work and produces an error.
In the Alice world, there is no documentation about scripts other than how to turn it on and that the language in use is Jython.
You're looking at the innovators of script code here.
But let me simplify the process: Script is used to increase the capabilities of Alice past what it can actually do on its own. For example, mouselock code, which has been the main innovation in the past few months.
You may also change certain basic properties of Alice if you happen to know the correct variables. By this I mean window size, colors, and whatnot. Usually the way to retrieve these variables is through scanning the source code (We don't have this.)
Decompiling the alice.jar to produce source code has been known to fail, unfortunately. Arty happens to have created an add-on to retrieve the full hierarchy names of certain objects in Alice, such as the scenegraph editor, though it doesn't really work outside the main Alice window.

tl;dr
You have access to all of Java instead of just Alice. Be creative. Come up with something useful.

arty-fishL
03-17-2012, 11:20 AM
Making it as an object is not possible the moment he included scripting. Script code beyond the level of "world", as in any script inside of a class, does not work and produces an error.It does work. How do you think my World Loader Tool or Save Tool work?

What you do is drag the object from the object tree to the events and create a world start event for it. Then stick in a script tile. Say the object was called "boy", then you would use this script:
exec(boy.script)You can't have any scripts outside of the object reference scripts from the object until after that event has ran though, so wait a millisecond or so before using its scripts elsewhere.

I always give kudos to Zonedabone when asked about the origin of scripting in Alice, he was the true pioneer. We (me and Mr K) are the ones carrying on his legacy now.

Mr Kidnapper
03-20-2012, 05:51 PM
Maybe I should reverse all of your programs and see if I'm still missing something.

arty-fishL
03-20-2012, 07:33 PM
Maybe I should reverse all of your programs and see if I'm still missing something.You could just ask me, but that would be a cop out and reversing them is more fun, so I see where you are coming from with this. But still, if you want to know anything then just ask and I can help, just as you have helped me in the past. :)

PikachuCLS
03-21-2012, 07:59 PM
I have a fairly good suggestion for this engine's improvement. How do you apply limits to the up and down looking axis. It seems the camera is able to do a 360 flip while looking. Could the engine be more realistic?

I also have a really easy question. How do you merge the engine to the game, and how do you merge two engines together. Your method of merging worlds, arty-fishL, makes the worlds into groups and the objects into something i don't know, but it can't be dragged outside of their worlds. I also don't think scripts can be transferred because you get an error. Can anyone please clarify this?

jediaction
03-22-2012, 09:26 PM
This is good. Change the field of view and this is something even better. A bit sensitive but that can all be fixed. The vertical aiming limit should be there also to prevent spinning upside down a million times. I should implemeant this into Hero's and see if that will work. If it does, it will make it 10 times better.

meeatpizza
03-29-2012, 10:34 PM
This is the best mouse aiming thingy I have ever seen on Alice

arty-fishL
03-30-2012, 02:34 AM
This is the best mouse aiming thingy I have ever seen on AliceThanks, feel free to use it. There is an updated version (as a tool object) that I will release in a week (I'm not working on it, I just don't have time right now).

blakecj
03-30-2012, 10:38 PM
Guys, this is absolutely amazing!!! I had no idea this was possible. However, I notice that because arrow keys don't move the camera, there is no pre-programmed collision detection. Even still, great job!! will probably try this out for my fps. THANKS SO MUCH!!

jediaction
03-31-2012, 10:06 AM
It seems that a lot of members here have not seen any of my FPS games because to state that this is the first mouse aiming system ever to be seen means that no one has looked at past projects to see if they already existed. Many members have attempted to do these kind of aiming systems and I modified someone elses to get to the one I use in all my games now.

sfunk
03-31-2012, 11:20 AM
It seems that a lot of members here have not seen any of my FPS games because to state that this is the first mouse aiming system ever to be seen means that no one has looked at past projects to see if they already existed. Many members have attempted to do these kind of aiming systems and I modified someone elses to get to the one I use in all my games now.

If you are referring to the people who posted on this thread, you might want to consider that all the ones who have said that they never saw something like this before only have a few post(normally meaning new users, so if you have an older project with similar systems, they will be over looked by the newer and obviously titled projects) and this thread really isn't about older aiming systems or about your projects, it is about Arty's contribution for a very precise aiming system which really hasn't been done to this extent until now.

x2495iiii
03-31-2012, 11:31 AM
The reason for this system is to enable people to use mouse aiming AND under-the-cursor bullet collision (uses the mouse instead of objects). Mouse aiming is nice, but coupling it with object proximity based collision detection is both inaccurate and inefficient (for Alice, at least).

jediaction
04-01-2012, 02:43 PM
If you are referring to the people who posted on this thread, you might want to consider that all the ones who have said that they never saw something like this before only have a few post(normally meaning new users, so if you have an older project with similar systems.

I am aware. It just shows that they didn't search for it already. That's my point. That's all./

beachbum111111
04-01-2012, 05:05 PM
It seems that a lot of members here have not seen any of my FPS games because to state that this is the first mouse aiming system ever to be seen means that no one has looked at past projects to see if they already existed. Many members have attempted to do these kind of aiming systems and I modified someone elses to get to the one I use in all my games now.

Umadbro?

arty-fishL
04-06-2012, 07:28 AM
This is not an FPS engine, just an aiming engine I built for X. If you coupled this with one of the several good collision engines on the forums then you could have a good FPS engine.

Braeden162
01-16-2013, 10:47 PM
there are some issues with this cause when you am up the camera just flys upwards and if you aim down you go straight through the ground. How would you make it so that the gus/obects w/e aim smoothly but at the time have the camera move above the ground and not fly.

bob3584
01-22-2013, 02:42 PM
Arty, I have a problem with the compatability between my program and yours. When I shoot the gun, if I hold The mouse down for long enough, it gliches and the gun moves to the left side of the screen. What am I doing wrong? :confused:

CurtisJohn
01-26-2013, 12:17 AM
The game will run, but when I press the start aiming, it says error during simulation. I click more information and this is what it says:
Any ideas?

---
Error during simulation.


Alice version: 2.3.2
os.name: Mac OS X
os.version: 10.7.4
os.arch: x86_64
java.vm.name: Java HotSpot(TM) 64-Bit Server VM
java.vm.version: 20.8-b03-424
user.dir: /Applications/Alice.app/Contents/Required

Throwable that caused the error:
Traceback (innermost last):
File "edu.cmu.cs.stage3.alice.core.property.ScriptProper ty[name=script,owner=edu.cmu.cs.stage3.alice.core.res ponse.ScriptResponse[world.setupWindow.__Unnamed3__.__Unnamed0__]]", line 1, in ?
File "edu.cmu.cs.stage3.alice.core.property.ScriptProper ty[name=script,owner=edu.cmu.cs.stage3.alice.core.Wor ld[world]]", line 17, in everything
OverflowError: float too large to convert
---