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)
[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)
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.
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.