The Daily Click ::. Forums ::. Klik Coding Help ::. Help needed for sketchy's rts engine
 

Post Reply  Post Oekaki 
 

Posted By Message

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
21st October, 2013 at 21/10/2013 00:15:08 -

Hi there
I downloaded the rts engine by sketchy and i need it for an ai, but i tried to analyze the code and i just saw that the RClickLenght variable is for the selection and the scrolling (to NOT deselect the ships when scrolling)
and that's pretty much it, i on't know what the flags are corresponding to

If you can help me/have the time, i would definitely be thankful
Oh and by the way, the RTSEngine is here: https://skydrive.live.com/?cid=b1e7ee094271bbda&id=B1E7EE094271BBDA!375&sc=documents#
(Search for RtsEngine and download)

Thanks for your help, this will make my day !

 
Working on some engines, working for the fun !

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st October, 2013 at 21/10/2013 15:04:54 -

What's the problem exactly?

Flag 0 = Indicates whether unit is selected
XPos / YPos = Unit position (required because coordinates are not otherwise stored as floats)
XTar / YTar = Unit target destination
Turn = Unit's maximum rate of turn (degrees per frame)
MoveSpeed = Unit's maximum speed (pixels per frame)
TarDist = Unit's distance from its target destination
Alt Val I (forgot to rename it) = Direction to rotate (either -1 or 1, for clockwise or anticlockwise, or 0 to go straight)
Alt Val J (forgot to rename it) = Closest the unit has been to its target destination so far

Essentially, it works like this:

* When the player clicks a destination, it looks at how many units are selected, and picks an appropriate grid size.
eg. If 4 units are selected, they will be assigned to a 2x2 grid. If 9 units are selected a 3x3 grid would be used.
This grid is centered over the position where the player clicked, and determines the target destinations of individual units (by setting XTar and YTar). The idea is just to spread out the units when they stop moving, since there is no collision detection between units, and otherwise they would all just end up on top of each other.

* The units move using a standard 360 degree movement. Collisions are detected using embedded collision detectors ( http://www.create-games.com/article.asp?id=1639 ) to check for obstacles to the left or right, causing the unit to turn either right or left.

* When the units get close to their destination, they check to see if they are getting further away from it (instead of getting closer), and if so they stop moving - this just stops them going round in circles if they overshoot or can't reach their destination (eg. if it's directly underneath an obstacle).


To be honest, it's not a particularly good example, as it doesn't handle unit collisions or include any actual pathfinding. It will fail miserably on even slightly maze-like maps (I made if for someone whose game was only going to have the odd tree or boulder to avoid).

Edited by Sketchy

 
n/a

Riptide



Registered
  26/07/2013 21:07:20
Points
  101
21st October, 2013 at 21/10/2013 17:06:00 -

Hi sketchy, thanks a lot for your explanations, it's much clearer right now
In fact i wanted a pathfinding example (i'm working on a game that the enemy can "track" you) and i didn't find a good one so i wanted to use this one, if you have a better way to do it tell me ^^
So thanks sketchy i'm gonna work on this one

 
Working on some engines, working for the fun !
   

Post Reply



 



Advertisement

Worth A Click