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 / Moving sprites independent from the loop

Author
Message
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 13th Apr 2020 21:40
Hi,
Here I am again asking for help and guidance, which you guys so selflessly provide all the time. I have learned so much already. So, here is the question:
I have one, two or many sprites moving around the window in their patterns (circles, figure 8s of s-curves, or random). No problem with figuring out routes or movement patterns, or enter the window from somewhere and then exit at some other point. What I am trying to do is this: After a sprite goes around in its pattern one or more times, I want it to stop somewhere in the screen and wait there until some command is given to start moving again, or a countdown timer, or some action while in the main loop. In a more general way, how do you do something while the loop is running and not be affected by the loop?
Is it doable?
I hope my question makes sense.
Cheers!
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Apr 2020 22:14 Edited at: 13th Apr 2020 22:15
I use a State Machine. It sounds like a very complex thing but it is really very simple.
Each sprite has a state value. The state value tells it what it should be doing.
So your loop might look like this

GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 14th Apr 2020 13:46
@blink0K. I am on it! Looks simple enough. Much appreciated! I am trying to learn AppGameKit while waiting for GG MAX to come out. Now, I am beginning to have fun with AppGameKit and perhaps GG maybe left alone for a spell, or at least the first round of bugs is resolved after the release, which is scheduled in September.
If I need some more help I will be sure to ask again.
Cheers!
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 14th Apr 2020 18:50 Edited at: 14th Apr 2020 18:52
If I'll give you an answer in Greek will I help you? I think blink0k's solution is the way you should follow. It depends on how experienced you are in programming
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 14th Apr 2020 20:39
@george Of course an answer in Greek will help me. Too bad we are not allowed anything but English here. Should you want to chime in with a bit of more detailed piece of code, I will not object. However, I think I can deal with what blin0k gave me. At least I will give it my best shot. Alekos
Cheers!
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Apr 2020 17:45 Edited at: 15th Apr 2020 17:57
Gia soy Aleko! (Hi Alekos)
Here is a more detailed approach (but still simple). I kept the code snippet as simple as possible.
Now you have the ability to execute code only once, when an entity enters into and exits from a state.
You can implement as much states as you want.



In order to check how it works simply remove the rem symbol from the Sleep(500) command
I hope it will be useful to you and other newcomer members
GreekToMe
14
Years of Service
User Offline
Joined: 27th Oct 2009
Location: Colorado
Posted: 15th Apr 2020 19:29
Yes, very useful! It will come handy many times over! I was just about finished with studying and adding my stuff in blink0k's code snippet. I will continue with that until I have a working piece of code. It will be to my benefit to develop mine. Then I will look at yours and make comparisons with what I made. I am sure more ideas will spring up once I compare mine to yours.
Are you guys in total lock down with the virus thing? Here it is mostly 90% lock down. 100% for me! But I get to work on AppGameKit and hopefully I will come out of the quarantine a better AppGameKit programmer
Cheers and Thanks!
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 15th Apr 2020 19:38 Edited at: 15th Apr 2020 19:38
Quote: "Are you guys in total lock down with the virus thing?"

In Greece the situation is good. If I can give a percentage it would be 80% approximately. I have a job, that I can do most of the work from my house.
george++
AGK Tool Maker
16
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 23rd Apr 2020 11:24 Edited at: 23rd Apr 2020 20:28
Here is a better implementation

Login to post a reply

Server time is: 2024-04-24 14:22:38
Your offset time is: 2024-04-24 14:22:38