Help with designing a selection and move tool for a Real-Time Strategy (RTS)

Hi coders!

I am trying to do a remake of Warcraft just to scratch my brain with a few funky ideas.

Problem: I’m stuck on the first step though… I want to select a soldier, and then select the place for them to move and they go there, following the shortest path. Part of this problem is the way I’ve made the ‘selection box’ for the unit. Every time I select it, I’m just making a new box at the moment. There can only ever been one unit selected at a time.

What I’ve Tried : There is a path following extension which I’ve began using… I imagine you would use the selected sprite’s current tile, and then the chosen tile to fill in the variables and have it move…

Need help to… :-

  1. Create only one selection box, which snaps instantly to the selected unit
  2. The selected unit then uses the path following to move.

Move with arrows. A to select. I spread 4 soldiers over the map randomly.

There is a function for trees but ignore that… that’s for later.

1 Like

Here are some edits. I added comments next to the parts of the code I changed (might be easier to read it in the editor though)

Here’s a share link with the updated code:

2 Likes

Thanks, Richard! You’re the best :grinning:

1 Like

Lol, I made this warcraft for you. https://makecode.com/_HKjJEVK5E9CX

2 Likes

Amazing! I love it!

I really like how you used the Story Extension too. I’m going to have to get my head around that.

The custom art and sprites you’ve made work so, so well! And it feels similar to those turn-based RTS like XCOM.

Very cool!

I’m tinkering away at making my version a Warcraft 2 clone. Just something to scratch our brains, right? :slight_smile:

totally!