Page 1 of 1

Alchemy game

PostPosted: Thu 7 Feb 2019, 15:33
by Sinha
Hi everyone,
I'm trying to make an alchemy game, but I'm having doubts about how to do some things. So I have two questions.
first: in gdevelop is it possible to continue counting time even leaving the game? Example: a certain object takes a few minutes to get ready, but the person does not want to stay in the game waiting, is there a way to make the time pass even without being in the game?
And,
I would like to know if it is possible to do a scene scroll with the touch.
example: when I touch the screen and move it, the camera move too. I already tried to do something similar in gdevelop, but it did not work very well. If anyone knows how, please help me <3

Thanks, sinha :lol:

Re: Alchemy game

PostPosted: Thu 7 Feb 2019, 18:50
by ddabrahim
I don't think it is possible to count time after quit the game. But what you can do is check the current time (actual date and time) when the player quit the game and check it again when the player starts the game and take in to account the difference. For example, if something takes 10 minutes to complete and the player quit and then start again 8 minutes later, take the time into account and reduce the remaining time to complete accordingly.

To drag the screen, take a look at the drag camera with mouse example.

Re: Alchemy game

PostPosted: Fri 8 Feb 2019, 22:19
by xisco
hi
it is not possible to continie doing things when the app is closed unless you have a server app which is always running o the cloud and players use a client.
You can simulates as said, you can store time and when the game opens again calculate the elapsed time and update your game

Re: Alchemy game

PostPosted: Fri 8 Feb 2019, 22:49
by Sinha
is a nice solucion, but i have no idea how to do this :(

Re: Alchemy game

PostPosted: Fri 8 Feb 2019, 23:48
by xisco
hi
I'm new to Gdevelop so I don't know much but think you can execute javascript, maybe you can get date and time with it, then you have the code to save data here
http://wiki.compilgames.net/doku.php/gd ... -explained
then you read it and get time again and get how much time elapsed maybe in javascript too.

Re: Alchemy game

PostPosted: Sat 9 Feb 2019, 11:01
by ddabrahim
is a nice solucion, but i have no idea how to do this

In case you don't know JS, search for a tutorial:
https://alison.com/courses?query=javascript

In JS you can use the Date object to get the current date and time:
https://www.w3schools.com/jsref/jsref_obj_date.asp

And then read the official docs about how to access and read and write scene variables in JS to pass the value from JS to a scene variable in GD to be able to access it from events too:
http://wiki.compilgames.net/doku.php/gd ... =help-link

And then look in to how to store this value permanently using the storage events
http://wiki.compilgames.net/doku.php/gd ... -explained
Or the new File system events:
http://wiki.compilgames.net/doku.php/gd ... filesystem

Finally come up with a formula to calculate elapsed time in seconds. It need to be something like:

elapsedTime = currentTime - lastTime

Then use the "elapsedTime" to calculate how much time left to complete a task.

If Timer "TaskTimer" is greater than 600 - elapsedTime seconds : Task complete

Re: Alchemy game

PostPosted: Sat 9 Feb 2019, 19:32
by Sinha
Thank you guys! I Will try! ^^

Re: Alchemy game

PostPosted: Sat 9 Feb 2019, 20:59
by Lizard-13
Or wait for the next version, 4ian has added a way to get a timestamp:
Code: Select allTime("timestamp")

Save this value on exiting game, when the game is open again, read the saved timestamp and get the seconds elapsed since exit with:
Code: Select all(Time("timestamp") - Variable(saved_timestamp)) / 1000

:)