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.

Newcomers AppGameKit Corner / Best Programming Practices in AGK2

Author
Message
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 26th Nov 2016 17:45 Edited at: 26th Nov 2016 18:10
Hello friends,
I have a modest question
I am trying to make a shooter. But that's beside the point. I'd like to try for the best code. I would like to learn 'best practices' in AGK2.

E.g. the movement of the ship.

This is output:


And this is my source code. (I do not believe this is the right way in AGK2, it should go better...) Please, could be anyone advise me a better solution?

I am sorry for poor English
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 28th Nov 2016 10:37
OK, I bought The Official App Game Kit Tutorial Guide, so I will study
I am sorry for poor English
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 28th Nov 2016 10:38 Edited at: 28th Nov 2016 10:42
Hello Some of you comments are not in english, it makes it harder to read :-P

It seems like you don't use a timer to restrict your movement. Depending on what computer it runs on, the FPS might change and then it might change how fast or slow your ship moves.

Try changing SetSyncRate(60,0) to SetSyncRate(30,0), if that changes how fast or slow your ship moves, then you have a problem.

Here is a very small example of timer restricted movement.

EDIT: Using timer restricted movement ties how often movement can update to the internal timer instead of the framerate. The framerate can change depending on the computer, the timer can not. As long as the computer can update the frame faster than what you set the timer restriction to, it should run the same on different computers that reach this minimum.

13/0
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 28th Nov 2016 11:05 Edited at: 28th Nov 2016 11:06
I'm very sorry for my terrible English, I will try to improve

Yes, if I set SetSyncRate(30,0), then ship is slower (cca 50%).
Thank you very much, I try it!
I am sorry for poor English
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 28th Nov 2016 13:24
Your English is good enough to understand clearly what you are saying No problem there It is stuff like this -> "deklarace" and "řízení naklápění lodi" that I do not understand
13/0
damothegreat
User Banned
Posted: 28th Nov 2016 13:29 Edited at: 28th Nov 2016 13:34
Your code looks good to me.

I would in all honesty in your main DO LOOP, is have functions only in order.
i.e



Something along those lines,

This to me is personal choice, much cleaner and easier to find and read code

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 29th Nov 2016 07:21
@Cybermind
Oh I see! I forgot my Czech comments there I am sorry

@damothegreat
Yes, thank you! This is exactly what I needed to hear. It's clearer, anyway!

I continue on. Thanks!
I am sorry for poor English

Login to post a reply

Server time is: 2024-11-24 15:36:33
Your offset time is: 2024-11-24 15:36:33