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 Classic Chat / How I can make the AI appear from outside screen at one at a time

Author
Message
leo877
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 1st Jan 2013 23:45
Hi. I trying to get my code to work but having problems and got stuck on it. In my code i got a tank which is the AI were it start from the outside of the screen and move to the opposite of the screen.

For example if tanks start on top of screen, the tank will move towards the bottom.

here the function part of the code i got so far:


okay i tried using the timer command, the sleep command but nothing works.

would CASE/SELECT command will work is the IF/THEN/ELSE better use.

i was trying to use SLEEP() to put on top of the case statement but is just slow the fps.
i then put the command inside the case statement at the end but there was no differences.

for example



now i got some ideas how it should work but can't get it in to code right.

my logic is that there should be some kind of timer use but don't know were to put it and what kind of timer to use.

i also don't understand what is the flag is use for.

any help of getting the code work and explanation what i am doing wrong would help me understand coding with AGK.

thank you.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Jan 2013 00:03
What exactly is the problem? I have looked through your code and it seems ok. Is it running too fast? Remember to set your sync rate at the start of the program or use a timer for syncing in the main loop.

leo877
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 2nd Jan 2013 00:11 Edited at: 3rd Jan 2013 04:18
@ dvader

not sure how to explain the problem i post the full code and image so you can see the result. i also using version 1.7



the problem is dont have a timer use. i trying to figure out were and what kind of timer to use. ..
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Jan 2013 00:37
Okay I have tied your code and have some random dots wiggling about. I assume that is what you are getting and do not want. How do you want them to move?

leo877
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 2nd Jan 2013 01:34 Edited at: 2nd Jan 2013 01:37
Dvader

What I want is the dots(enemy) appear from the top,left,bottom,and right at the screen but one at a time. First they appear on top, then wait for 1 or 2 minutes the random appear from another side of the screen and wait again. The process will repeat until a certain number is hit. i haven't code that part but that's how is should work.

Heres one video of the were the tanks appear from the bottom towards the top... It start from the bottom then 1 or 2 minutes it random appear from another side or same side.

[/youtube]http://youtu.be/JZa_zfd8izA[/youtube]
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Jan 2013 17:15
I watched the video, it looks like they move from bottom to the top all the time, but I must admit to skipping it a little after 3 mins to try to find a change of direction.
I would have thought it fairly simple if all you want is random tanks travelling from the edges of the screen? I'll see if I can knock up something to help.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Jan 2013 18:17
Okay here is what I have come up with. It is not quite what you want by the sounds, but it could easily be altered as you see fit and may help you out.


leo877
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 3rd Jan 2013 02:20
@ Dvaader

Thanks for your help. Your code does get all the dots on the screen at the same time and moving in one directions which is a good result. I will looked over your code and see were I messed up.

The video you saw is just showing only one directions but what i want is were the tanks will appear random form the side but a pause in between them... or example tanks appear from top, pause for 2 or 3 minutes then tank will from another side pause for a couple minutes and the process repeats.

The part that got me think is the setup function with the global parts.

I guess using case select was not the best choices. I see you use the else if statements.

Hopefully this weekend I can spend more time on the code.


Thanks for your help.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 3rd Jan 2013 02:55
If you want to increase the delay set tanktime#=timer()+.2, to a higher number. You could set it to a random one if you want different pauses.

Login to post a reply

Server time is: 2024-05-06 11:53:04
Your offset time is: 2024-05-06 11:53:04