Page 1 of 2

Basic RTS Prototype

Posted: Wed Aug 15, 2012 9:14 am
by BlackBulletIV
I thought I'd share my progress on the real-time strategy prototype I've been working the past few days. The main things completed thus far are unit grouping with a line formation; an overhead camera that can be moved, rotated, and zoomed; and a few interface things such as dragging to make a group take a formation and "ghost formations."

I'm making this using my Ammo (GitHub repo), so this is an example of how you can use it. There's also quite a fair bit of trigonometry in here (especially the formation calculation), which may be helpful to some. If you think there's a better way to do something, please let me know; I'm quite the novice when it comes to trigonometry.

Controls:
LMB to select a group. You can't click and drag to select at this point.
RMB to move a group. Click and drag to explicitly specify the formation the group should take.
WASD/Arrows to move the camera.
Q and E to rotate the camera.
Scroll to zoom.

GitHub Repository: https://github.com/BlackBulletIV/rts-prototype

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 10:56 am
by Roland_Yonaba
Oh Hell! Canvas! Can't try it.
I was really really interested in, though.

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 12:17 pm
by BlackBulletIV
I've updated it to use exported PNG versions of the images that were generated if canvases aren't supported. Hopefully that works. :)

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 7:06 pm
by Roland_Yonaba
Wut! Awesome! Wut!

Okay, jibjab!
I started working my self on a RTS based game 3 years ago. Originally, I started it on PSP, using Homemister's LuaPlayer as a framework.
The latest public release can be found on PSP-Hacks.
When I discovered Löve, more recently,I rewrote it, but I wasn't that much satisfied of the results and the overall looking. Not because of Löve, but because of my code. I kind of "turned-off" the project, and i'll hopefully be back on it someday.

Features I couldn't implement as well as I wanted to was:
  • A clean, nice and responsive pathfinding for a single unit moves.
  • Group unit with and coordinated-moves.
  • Workout avoiding collisions between units, crossing overs through a fast algorithm
And many other things... But that didn't turned out that well, most of all due to my lack of experience in terms of RTS game logic.
But well, you may now understand for what reason I was highly interested in your work.

I tried it, and I liked it. Group move feature is awesome.
Yet, it doesn't feature any of the things I mentionned previously.
But, anyway.
Have you plans using it in a next project ?
Did you used any papers, reading before implementing this ?
Are you willing to work on some improvements, new features ?

Keep up the awesome work.

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 9:54 pm
by Nsmurf
Amazing engine!

I don't quite understand how the units shift when moving around. If i made something similar to this i would have you select each unit, and move those to where you click. It would work like this:

1.) you select units and click where you want them to go.
2.) each unit moves to where you clicked.
3.) if any units collide during the moving, they go in a random direction until they are not touching.

Your way looks nicer, but with one drawback: you need to move in groups.

If i were to make a RTS game, i would use a combination of the methods, to make it look nice, and allow for moving single units or smaller units. If you feel like taking this further, you could have it so you double click a unit to move it individually, and when it's done moving if it's close to a group, it becomes part of that group, but if it's not close to a group, it starts it's own group.

Anyways, amazing engine, it would be awesome to see it with movement of individual units, but that might be horribly complex, so i'm not complaining.

once again, great job with this.

EDIT:

Was playing around with this. Is this supposed to happen? (attached file)

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 10:52 pm
by BlackBulletIV
@Roland_Yonaba:

Thanks for the feedback.

What exactly do you mean by "Group unit with and coordinated-moves?" Did you mean selecting multiple groups at a time or something?
Roland_Yonaba wrote:Have you plans using it in a next project ?
This kind of is the project; I've got the idea for a game, but for right now, I'm implementing the basic RTS stuff.
Roland_Yonaba wrote:Did you used any papers, reading before implementing this ?
Apart from the Lua manual and LOVE's documentation, no.
Roland_Yonaba wrote:Are you willing to work on some improvements, new features ?
Definitely. This is by no means finished.

@Nsmurf:

Thank you for your feedback.

The group concept I'm using comes from the Total War series. You could do the same with individual units, but for my purposes I think having set groups is a better idea. And yeah, at present there is nothing to prevent collision between units. It'll be a bit complicated to tackle that efficiently; I may have to resort to using love.physics for its efficient collision detection. :(

As for your image attachment, it depends what you did to get there. They just look like formations with a short drag length.

Re: Basic RTS Prototype

Posted: Wed Aug 15, 2012 11:48 pm
by Lap
Doesn't work with luajit due to

lib/strong/strong.lua 67: invalid escape sequence near "[ _'

Re: Basic RTS Prototype

Posted: Thu Aug 16, 2012 12:06 am
by Roland_Yonaba
BlackBulletIV wrote:@Roland_Yonaba:

Thanks for the feedback.
Ya welcome.
BlackBulletIV wrote: What exactly do you mean by "Group unit with and coordinated-moves?"
Nah, my bad, I mistyped. Just wanted to say "Coordinated units movements". Collidance avoiding stuff, you know. So that when units moves into groups, they try to prevent to collide each other. Like a flock of birds, sheeps, etc.

I remember, back in days, when working on my stuff, I did something similar to waht Nsmurf was stating...Loop into the collection of units, and for every unit, make a collision test with all the others, and move in in opposite direction on purpose. It worked, but was really really ugly. :x
Good memories... :3

Can this be easily mixed with pathfinding, right now ?
I am keeping an eye on this. Have you pushed it on Github yet ?

Re: Basic RTS Prototype

Posted: Thu Aug 16, 2012 12:13 am
by Roland_Yonaba
Lap wrote:Doesn't work with luajit due to

lib/strong/strong.lua 67: invalid escape sequence near "[ _'
Well, open 'lib/strong/strong.lua' in your favorite source code editor.

Scroll to line 66, and replace string.camelize function with this:

Code: Select all

function string:camelize(upper)
  self = self:lower():gsub('[ \t_%-](.)', string.upper)
  return upper and self:gsub('^%l', string.upper) or self 
end
Scroll to line 230, and replace string.underscore function with this:

Code: Select all

 function string:underscore()
  return self:gsub('([A-Z]+)([A-Z][a-z])', '%1_%2'):
              gsub('([a-z%d])([A-Z])', '%1_%2'):
              gsub('[ \t]', '_'):
              lower()
end 
Hope it might work.

Re: Basic RTS Prototype

Posted: Thu Aug 16, 2012 4:27 am
by BlackBulletIV
Thanks for catching that problem guys. I've updated the library and credited you, Roland. By the way, your website in your signature should use HTTP not HTTPS, since the latter doesn't go anywhere.

As for path finding, or, collision avoidance, that's a tricky thing. The only way I can see it being done in Lua is by checking everything unit with every other unit, which is obviously a very inefficient thing to do when you get larger numbers of units. You might be able to use a quad tree or something, but I've no idea how they work. I might have to resort to love.physics to resolve the collision between units. We'll see what happens.

I've created a new repository which you can find here: https://github.com/BlackBulletIV/rts-prototype