0 Favourites

Can I embed some sort of mouse movement log in my game?

  • Hello,

    I'm a new user here at the Consctruct 2 forums. I'm building a 2D scrolling collector game for a scientific experiment on decision making on induced states of flow. I work with a post doc and am in charge of designing the game with him. One of the things we look to achieve with this game is mapping the movements made by the players (using mouse or fingers on mobile) to cross-reference them with timestamps from the game (it's a timed level based game) and also save other things on this log file like the score of the player.

    We know this can be made in unity, but we are enjoying Construct 2 a lot and are wondering if this is possible to accomplish on this engine (provided we get permission from each player to record this data, of course).

    Ask away if you have any questions. If needed I can pm with more details on the study so you know I'm legit.

    Thank you very much,

    Quendera

  • Yes, this is possible.

    How much accuracy do you need in your timestamp?

    If you just want to use local time, Rex Date plugin will give you timestamps from the system clock that the JavaScript is running on presently. If you need to access a more accurate time source (like a timing server), you can do an AJAX call and parse the time using a modified version of the Rex Date plugin that I can send you.

    Rex Date: http://c2rexplugins.weebly.com/rex_date.html

    Then you could just store the timestamp, mouse.X, mouse.Y in Arrays, Hashmaps, etc. every tick (per ~1/60 sec), or once per second.

  • Wouldn't it be as easy as setting mouse.x and mouse.y or touch.x and touch.y to an array at times specified by you?

    Every tick would also be possible ofcourse, or every tick during a certain period..

  • Yes, this is possible.

    How much accuracy do you need in your timestamp?

    Hello, and thank you for the reply.

    Sorry if I didn't explain myself correctly but the timestamp I meant is the in game time. Imagine level 1 at 30 seconds into the level the mouse (i'm using the touch object command) was on XY coordinates. Other then that, and ruling out mobile for now, do you know if there will be a limit to the number of measures I make (vs I can record 1 million playthroughs if I have enough space to store output files), and (assuming they will output to a txt file) could the engine create a different file for each player (perhaps based on ip, or whatever other criteria there is)?

    Thank you!

  • Yea, you can do the same thing with the Rex Date plugin too (the Timer functionality at the very bottom of his documentation page). Or you can track the in-game time yourself using a 'currentTime' variable (or whatever) and just update every second or so.

    As far as storing in-game time/x/y, it sounds like you will want to ship them back to some server and write them to a text file.

    As far as I know no one has ever implemented a text-file-writing plugin, so you would have to either use a server side program or implement something like this: http://stackoverflow.com/questions/1605 ... javascript in a Construct plugin.

    The problem with using in-game storage for storing data is that it will be wiped everytime you start the game over (and it will be exclusively local to the running client).

  • The problem with using in-game storage for storing data is that it will be wiped everytime you start the game over (and it will be exclusively local to the running client).

    This is exactly what I thought and thus my question...

    Ok thank you for now guys, let me know if someone happens to know of a solution to this. Hopefully I can do it and we can all make some science together in the near future!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • The problem with using in-game storage for storing data is that it will be wiped everytime you start the game over (and it will be exclusively local to the running client).

    Fisrt part not completely true, for you can store anything in localstorage, which will return that info when requested, second part true, but there is the Ajax-plugin for that, how would something go anywhere else than the original device without sending it over the net?

    Also using a third party plugin like

    you could send a mail through Mandrill, setting the text to the desired info..

  • Fisrt part not completely true, for you can store anything in localstorage, which will return that info when requested.

    Yea, I was referring to the C2 arrays/hashes. If you use browser webstorage, then you are correct.

    The Mandrill solution is clever too.

  • >

    > Fisrt part not completely true, for you can store anything in localstorage, which will return that info when requested.

    >

    Yea, I was referring to the C2 arrays/hashes. If you use browser webstorage, then you are correct.

    The Mandrill solution is clever too.

    Guys, thank you so much. I'm off for the day now (I'm european) but I'll check on your comments and update you tomorrow on what I end up doing.

    Thank you,

    Quendera

  • I found this too just now:

    https://www.scirra.com/manual/126/system-expressions

    Under "Time" near the bottom.

    [quote:3bnrkml6]time

    The number of seconds since the game started, taking in to account the time scale.

    timescale

    The current time scale.

    wallclocktime

    The number of seconds since the game started, not taking in to account the time scale (i.e. the real-world time).

  • gumshoe2029

    I saw your message but unfortunatelly scirra only allows me to reply with a certain level of Reputation Points. Please feel free to contact me at if you want to know more about the project. Disclaimer, we're in really early stages so there's not much I can give away.

    On another note, the data I want to output specifically is X,Y coordinates every, let's say 100milliseconds (or 1/10 of a second), and player score variations across time (just whenever score changes). These are the ones on top of my head, but my team might come up with more later.

    Anyway, I'll come back to you guys as soon as I get more in depth into this. Please feel free to contact me on the above email with suggestions on how to solve this.

  • Hello guys!

    So my game has come a long way.

    I managed to get everything that I wanted working and even Mandrill. My one issue now is, how can I save an array to a file that is not downloaded and that can be called with the mandrill plugin?

    This is purely for convenience as I can send the data in the email body, but that is messy because then I have to copy paste every single email into a .json file. (that's a pain if I hit thousands of players).

    Thanks a lot for your initial boost, gumshoe2029 and LittleStain. You guys helped make it possible.

  • If you hit thousands of players I guess you could either hire someone to do it for you, or have someone make an update allowing to use an online database..

    I guess the succes would warrant that..

    I was thinking this would be small-scale research orientated when thinking of the mandril solution..

    In that case doing it by hand wouldn't be too much of a hassle..

  • Yeah, mandrill is good for now, but i'll look into having my workplace server set up to allow this. I figure I could use a system similar to the high score one and that is pretty easy to implement. Anyway, thanks again for everything!

  • Hello guys!

    So my game has come a long way.

    I managed to get everything that I wanted working and even Mandrill. My one issue now is, how can I save an array to a file that is not downloaded and that can be called with the mandrill plugin?

    This is purely for convenience as I can send the data in the email body, but that is messy because then I have to copy paste every single email into a .json file. (that's a pain if I hit thousands of players).

    Thanks a lot for your initial boost, gumshoe2029 and LittleStain. You guys helped make it possible.

    np. Glad to help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)