Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Need help with increment movement going too fast.

Author
Message
RoadKill
User Offline
Joined: 22nd Apr 2022
Location:
Posted: 24th Apr 2022 19:07
Hi all, I'm new to using App Game Kit, I'm a regular user Clickteam Fusion 2.5 but I'm looking in to trying to learn a code based language.

Currently I've managed to make a script that allows multiple custom bitmap fonts displaying player scores and render it the the window which worked far better than I thought it would (It did take me way too long to figure out how subimages worked though.)

Anyway on to my issue, I'm currently trying to make my player sprite move in increments of 4 but it moves far to quickly, normally in Fusion I would use a condition of every so many milliseconds to do a action but I can't seem to figure out how to do it without the using the sleep command, this seems to slow the whole program though.

What is the best way of doing timer based events like I would do in Fusion?

I did try the timer based movement example included in the help system but that doesn't do what I want it to do and seems to make movement faster the longer the game would be playing.
Virtual Nomad
Moderator
16
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 24th Apr 2022 22:51 Edited at: 24th Apr 2022 23:56
Quote: "every so many milliseconds do a action"

something like:


but that isn't real timer-based movement which, in a nutshell, would move the player by some fraction of whatever move rate (ie, 40 px) per second every frame vs moving 4 px every 0.1 seconds in the example above.

otherwise, glancing at the timer-based example in help files and it's ugly.

here's a simple comparison:

note: i'm not carrying over any remaining time toward when the next (what i'm calling) "time limited" movement could occur (player2).

it's lost and just waiting 100ms before allowing potential movement to occur again.

to exaggerate the difference:

note SyncRate(1,0) and the last bit. ie, update 1 frame per second and player still moving ~40px per second (on avg).

meanwhile, welcome

Attachments

Login to view attachments
MadBit
Valued Member
Gold Codemaster
13
Years of Service
User Offline
Joined: 25th Jun 2009
Location: Germany
Posted: 25th Apr 2022 07:47
I also welcome you.
What you can also use is GetFrameTime()


Then you don't need to calculate the past time in every frame.

Here the 2nd listing of VN added with the GetFrameTime method.

Share your knowledge. It\'s a way to achieve immortality. (Tenzin Gyatso)

Login to post a reply

Server time is: 2022-08-09 08:54:36
Your offset time is: 2022-08-09 08:54:36