Test this RTS style movement!

Talk about making games.

Test this RTS style movement!

Postby jimmynewguy » Sun Dec 04, 2011 11:31 pm

Mouse them to select and mouse the ground to move. (yes mouse is a verb && yea they have sixpacks)

Tell me if this seems right to you please, I wanted to get down the whole formation movement that RTS games have. Actually easier than I thought with some trial and error! Let me know what you think! :) (you can only select 30 people at a time. Just because I made the array size 30. Yea. Oh and I'll add that dragable select too.

If enough people want me to, I can post on how to do this also.

EDIT: Lazyness is gone. Source is here
Attachments
Example.zip
Source
(9.65 KiB) Downloaded 160 times
screen.PNG
Screenie
Last edited by jimmynewguy on Tue Dec 06, 2011 5:05 pm, edited 1 time in total.
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby lcl » Mon Dec 05, 2011 9:06 am

Wow, this is amazing!
Great, Jimmy! :D

Please send the source too, I'm very interested to see how you've done this. :wink:
And yeah, you should add the dragable select too!

JimmyNewGuyDudeFellow wrote:Mouse them to select and mouse the ground to move. (yes mouse is a verb && yea they have sixpacks)

xD :lol:
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Test this RTS style movement!

Postby jimmynewguy » Mon Dec 05, 2011 5:01 pm

lcl wrote:you should add the dragable select too!

I am! :)

And to spare you (and mostly me and my secrets) the whole source code I'll just explain it.
You can count the number of people selected, and put their clonenames into an array. Then when you move them do a loop through the array. Then floor (or round down) the square root of the number of selected people so you find how many columns in your square of troops. (then so it doesn't look dumb on weird numbers, do a check on the columns to see if it squared is more than the number of selected and make an extra row. Pretty weird, but trust me it helps.) Then just do the offset of x up to multiples of the number of columns (size in the code I will post) and with some magic math poof you've got a square of troops!
Code: Select all
if(nselected)// if people are ready  to go, actually this is kinda useless...
{
int size = floor(sqrt(nselected)), n;// number of columns
if(size * size < nselected)size ++;// fix weird numbers

for(n = 0; n < 30; n++)// loop-de-loop
{
if(selected[n] != NULL)// if there is an actor stored in the selected array (other wise GE crashes
//if you try to move NULL)
{
MoveTo(selected[n]->clonename, mouse.x + (n % size) * 17, mouse.y + floor(n/size) * 17, 2, "Game Center", "");
// move him around
selected[n]->select = -1;// just a thing for my people to know what array position they're stored in
// and so I know they're selected
}
selected[n] = NULL;// clear that array spot
}
nselected = 0;// no one is selected
}


Wow am I bad at explaining...
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby SuperSonic » Tue Dec 06, 2011 12:12 am

Very nice jimmy :wink:

You should add npc's and the ability to attack them haha :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Test this RTS style movement!

Postby jimmynewguy » Tue Dec 06, 2011 1:31 am

SuperSonic wrote:You should add npc's and the ability to attack them haha :P

Well obviously :D I have an idea in mind for what this will become, not a traditional RTS though. I just wanted to see if the movement of the troops seemed right and there was no glithces.
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby lcl » Tue Dec 06, 2011 8:20 am

jimmynewguy wrote:And to spare you (and mostly me and my secrets) the whole source code I'll just explain it.

Saving secrets? Why do you have to keep your code as secret? =D
Also, what you said yourself here:
jimmynewguy wrote:Let's say I really wanna to check this out, now let's also say I'm too lazy to implement it into something. Can you post a demo of it being used? ...

You're being illogical, you see? :D :D
With that code you've given it will still be a pain to try to build the whole thing around it.
You have variables that need to be declared and actors to be created.. :roll:

But of course I can't tell you what to do, you make your own decisions. :)
I understand that sometimes it's hard to share your work for everyone to use, but personally I eventually found it
nicer to share all the tricks and codes for everyone to see them and learn by them.

Hey, one question still.
How can you declare variables in the script like that?
I've always put them on the top because otherwise GE has given me errors. :P
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Test this RTS style movement!

Postby skydereign » Tue Dec 06, 2011 8:38 am

lcl wrote:Hey, one question still.
How can you declare variables in the script like that?
I've always put them on the top because otherwise GE has given me errors. :P

The reason is code blocks. Variables must be declared at the beginning of a code block, and as a simple rule, brackets {} are blocks of code. It has to do with scope, since if you declare a variable within the {}, it won't exist outside of the brackets. For example:
Code: Select all
// you already know you can declare variables here
int variable=0;

if(variable==0)
{
    int new_variable=1; // turns out you can declare them hear as well (but only exists within the if)

    switch(new_variable)
    {
        int new_new_variable=2; // this one can only be used within the switch statement

        case 0:
        break;
    }

    // last notable thing is this
    {
        int new_new_new_variable; // I wouldn't suggest randomly inserting code blocks like this just to get a variable
        // it is better to declare the variable with new_variable, since it isn't any more efficient to do so here
    }
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Test this RTS style movement!

Postby lcl » Tue Dec 06, 2011 8:46 am

Thanks for explaining that skydereign! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Test this RTS style movement!

Postby jimmynewguy » Tue Dec 06, 2011 4:57 pm

lcl wrote:Saving secrets? Why do you have to keep your code as secret? =D

Not really, the .ged has just expanded from there enough where it's becoming a game. I don't want to post the source of something that I'm currently making/isn't finished (and I don't have an old back up either so I can't just do that). So it's more or less me not being unlazy enough to make an example .ged....

EDIT: See edit of first post
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby lcl » Tue Dec 06, 2011 6:09 pm

jimmynewguy wrote:
lcl wrote:Saving secrets? Why do you have to keep your code as secret? =D

Not really, the .ged has just expanded from there enough where it's becoming a game. I don't want to post the source of something that I'm currently making/isn't finished (and I don't have an old back up either so I can't just do that). So it's more or less me not being unlazy enough to make an example .ged....

EDIT: See edit of first post

Oh, I understand you :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Test this RTS style movement!

Postby jimmynewguy » Tue Dec 06, 2011 8:11 pm

LCL, look at the edit of the first post like my last post told you to :P a source! Just not all of the player animations since, well idk. Takes to many mouse clicks to put the animations in :roll:

EDIT: Uh oh, I can't draw still. My pixeling isn't going to help this game too much. Buildings are hard..
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby SuperSonic » Tue Dec 06, 2011 8:30 pm

jimmynewguy wrote:EDIT: Uh oh, I can't draw still. My pixeling isn't going to help this game too much. Buildings are hard..

I'm sure that there are some tutorials online about building drawing :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Test this RTS style movement!

Postby jimmynewguy » Tue Dec 06, 2011 8:47 pm

Going for the classic cheesy looking everything :wink:
Attachments
castle.PNG
castle.PNG (497 Bytes) Viewed 4225 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Test this RTS style movement!

Postby lcl » Tue Dec 06, 2011 8:56 pm

Yeah, great, thanks! :)
And that castle look cool!
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Test this RTS style movement!

Postby Jagmaster » Tue Dec 06, 2011 8:57 pm

I'm really not good at pixel art at all. Anything organic I try to make looks messed up.
If I try people in pixel art, they end up looking like a feral cat without ears.

Btw, I'm genuinely curious. Are those muscles or gills on that guy? If they are gills, is this going to be a underwater warrior fish-man type game?
They do look cool though. :)

Edit:
Btw, I'm genuinely curious. Are those muscles or gills on that guy? If they are gills, is this going to be a underwater warrior fish-man type game?


Where is my head today?
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron