This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-05-02 23:30:11

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Making RTS game, need help with AI movement

So I'm working on a Real-Time Strategy game, and I'm stumped on how to design the movement for the AI units (both the enemy units and the player controlled) units, so that
A) The Friendly AI units will move to the player's designated location via a route that avoids the various map obstacles (mountains) and;
B) So the Enemy units will do the same, but obviously of their own accord

Thanks for any helpful tips in advance.




Also while I'm at it, it would be nice to have a map area larger than the Scratch screen, I know it's possible, but how can I do it?

Last edited by SD7 (2013-05-02 23:30:59)


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#2 2013-05-02 23:47:57

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Making RTS game, need help with AI movement

[removed by moderator], ok, also having trouble with movement, getting the units to activate when I click them, and the move to where I tell them to go.

Last edited by cheddargirl (2013-05-03 01:14:46)


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

#3 2013-05-05 11:53:33

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: Making RTS game, need help with AI movement

i've been looking into this myself. this is not the easiest thing in the world fyi. pathfinding will be even more involved i believe and i don't want to think about ai really. and without ai, you'll be left with trying to make a multiplayer game on one keyboard. Maybe with scratch 2.0 you can make a turn based strategy, or you could make a pass and play sort of multiplayer with 1.4, but you should be aware of potential limitations.

Still, i think it could be fun to make an incomplete game just for the experience of making it. everything that you've asked about so far is possible and within reach. i was working on making sort of a tutorial on making these game elements so i have a prototype that i've been experimenting on, which ill post for you to download and check out: http://scratch.mit.edu/projects/cauzality/3316505 (my tutorial doesn't exist yet).

the project allows for the selection of units, you can move the units, and it shows the state of the mouse. i made it mine minerals and put them into a treasury and stuff like that but i didn't save that version (i can't get save in 2.0 yet).

to get the selection to work, you have to realize that even though you click the mouse once, which works for all the other software that you're used to, your mouse is actually in the DOWN state for many frames before you lift it. To register that as only 1 click, things are set to be triggered not when the mouse is down, but when the mouse if either first pressed or just released. this is done by using a variable which remembers if the mouse was down in the last frame.

your mouse is "PRESSED" when it is down but was up; it's "RELEASED" when it is up but was down; and your mouse is "HELD" when it both was and is down. the project i posted is basically just a demo of triggering things with if-else blocks which test what state the mouse is in.

Offline

 

#4 2013-05-05 19:51:03

SD7
Scratcher
Registered: 2011-09-15
Posts: 100+

Re: Making RTS game, need help with AI movement

Thanks for the reply, that'll be really helpful for working with the unit selection. I don't plan on making it multiplayer, just PvC, so once I get the movements down for the computer player's units, the only difference will be in making the player's units only act when and where the players commands them.


http://img834.imageshack.us/img834/4411/signaturespacegame2.png

Offline

 

Board footer