Basic RTS Prototype

Show off your games, demos and other (playable) creations.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Basic RTS Prototype

Post 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
Attachments
rts-prototype.love
This is a bit outdated. The GitHub repository will have the latest version.
(359.01 KiB) Downloaded 341 times
Last edited by BlackBulletIV on Thu Aug 16, 2012 4:28 am, edited 3 times in total.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Basic RTS Prototype

Post by Roland_Yonaba »

Oh Hell! Canvas! Can't try it.
I was really really interested in, though.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Basic RTS Prototype

Post 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. :)
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Basic RTS Prototype

Post 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.
Attachments
shot.png
shot.png (180 KiB) Viewed 3412 times
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Basic RTS Prototype

Post 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)
Attachments
???
???
RTs.JPG (52.47 KiB) Viewed 3396 times
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Basic RTS Prototype

Post 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.
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Basic RTS Prototype

Post by Lap »

Doesn't work with luajit due to

lib/strong/strong.lua 67: invalid escape sequence near "[ _'
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Basic RTS Prototype

Post 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 ?
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Basic RTS Prototype

Post 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.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Basic RTS Prototype

Post 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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 63 guests