How do I work with Time in Construct

Get help using Construct 2

Post » Sun Dec 13, 2015 2:58 pm

Posting here because I do need a solution.

I got a racing type game that needs to run off milliseconds.
Floating point stuff is giving me a headache (0.1 = 0.099etc).
Can't use the, every x seconds because every 0.01 seconds doesn't play nice.
Time leaderboards present scores in hours / minutes / seconds / hundredths of a second format. You must submit scores as milliseconds, so 66032 would be interpreted as 1:06.03.

Quote from Google Play Games Services for Publishing Android Games.
If anyone has any experience with c2 to google play, handling hundredths of seconds, I'd love to hear about it.


Also working on another game where I want to accumulate revenue over time regardless of whether or not the app is running.
Correct me if I'm wrong but Construct 2 doesn't have native support for 'system time' ?
I was just going to search for a unix time addon but got cold feet wondering if it would work on the million different types of android phone. I want to be able to work with hundredths of seconds and days all in the same equation. Elapsed time.

e.g. this thingo will give revenue 3 times per second, and this thingo will give revenue about once every 3 hours and if the app is closed, it will check on startup, using last stored times, how much has been earned since last revenue gained and calculate/display the progress towards next revenue for each thingo.
B
7
S
1
Posts: 43
Reputation: 513

Post » Sun Dec 13, 2015 4:24 pm

The expression int(time * 1000) will give you the game time in milliseconds, rounded off. You can get hundredths of a second by dividing that by 10, or changing the expression to multiply time by 100.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Mon Dec 14, 2015 6:58 am

changed to wallclocktime insted over add to count ever x seconds, works well.

int(Scores.At(Scores.CurX)/60000) & "." & int(((Scores.At(Scores.CurX)/10) - ((int((Scores.At(Scores.CurX)/10)/6000))*6000))/100) & "." & (Scores.At(Scores.CurX)/10) - ((int(Scores.At(Scores.CurX)/1000))*100)

Set | Scores to | (int(Text_Timer_Min.Text)*60000) + (int(Text_Timer_Sec.Text)*1000) + (int(Text_Timer_Mil.Text)*10)

Set | Play_Time to | wallclocktime - Menu_Time

Still need a reliable unix addon that works in android for progress over time games
B
7
S
1
Posts: 43
Reputation: 513

Post » Tue Dec 15, 2015 9:52 pm

You will never have a reliable unix addon that works in android since all JavaScript time plugins rely on local system time which can be tinkered with/manipulated freely.

C2 doesn't even really use time, per se, anyway, it operates purely on the concept of frames and the time component comes in frames per second. C2 is designed to run at 60 frames per second, and has a 'dt' parameter to allow you to get frame-rate independent time measurement relative to the 0th time from app launch based exclusively on local system time clocks. Like: https://www.scirra.com/tutorials/67/del ... dependence

If you want un-manipulable time, then you have to use a server.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,349
Reputation: 4,692

Post » Thu Dec 17, 2015 1:06 am

well I suppose that's the trade off isn't it... If you want "real time" in C2 games that can run offline then your subject to cheating. Otherwise the game must be 100% online, as you said.
could always have some anti cheat e.g. "current time is more then a month greater then previous time = reset game". But no I don't actually think that would help.

As for unix plugins or just plugins in general, I'm having a hard time getting past the Intel XDK's create app button. Keeps telling me my plugins are wrong and I can't for the life of me figure out why... all I did was update the xdk, app hasn't changed. So based on those issues.. I feel even less confident to proceed with the "real time" app.
B
7
S
1
Posts: 43
Reputation: 513


Return to How do I....?

Who is online

Users browsing this forum: imhotep22, ItsAstro, Yahoo [Bot] and 2 guests