Page 1 of 2

Test this RTS style movement!

PostPosted: Sun Dec 04, 2011 11:31 pm
by jimmynewguy
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

Re: Test this RTS style movement!

PostPosted: Mon Dec 05, 2011 9:06 am
by lcl
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:

Re: Test this RTS style movement!

PostPosted: Mon Dec 05, 2011 5:01 pm
by jimmynewguy
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...

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 12:12 am
by SuperSonic
Very nice jimmy :wink:

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

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 1:31 am
by jimmynewguy
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.

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:20 am
by lcl
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

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:38 am
by skydereign
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
    }
}

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:46 am
by lcl
Thanks for explaining that skydereign! :)

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 4:57 pm
by jimmynewguy
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

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 6:09 pm
by lcl
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 :)

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:11 pm
by jimmynewguy
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..

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:30 pm
by SuperSonic
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

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:47 pm
by jimmynewguy
Going for the classic cheesy looking everything :wink:

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:56 pm
by lcl
Yeah, great, thanks! :)
And that castle look cool!

Re: Test this RTS style movement!

PostPosted: Tue Dec 06, 2011 8:57 pm
by Jagmaster
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?