array value setting

You must understand the Game Editor concepts, before post here.

array value setting

Postby Soullem » Sat Jan 19, 2013 4:27 pm

Is there anyway to write a switch statement for all parts of an array at once? like can I do something like
Code: Select all
switch (pMOVE1[any real number])
{
//set values of attack
}

instead of having to do each one separately like

Code: Select all
switch (pMOVE1[0])
{
//set values
}
switch (pMOVE1[1])
{
}
//......

that would be impossible for my current project.
Also since I have four different attacks per monster how would I setup a global two part array where the values correspond to pMOVE[monsternumber][attacknumber].
thanks.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: array value setting

Postby skydereign » Sat Jan 19, 2013 6:31 pm

A switch statement can only take one value at a time. But, you can put a switch statement in a loop.
Code: Select all
int i;
int array[10];

for(i=0;i<10;i++)
{
    switch(array[i])
    {
        default:
        break;
    }
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: array value setting

Postby Soullem » Sat Jan 19, 2013 6:53 pm

oh wow, that is actually pretty smart, and very simple. Thanks for the wonderfully easy genius idea. Also how would I make one array have two parts? So instead of pATK1[i], pATK2[i] i can do pATK[j][i]. But it has to be able to be accessed globally?

Thank you so much!
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: array value setting

Postby skydereign » Sat Jan 19, 2013 6:57 pm

You mean a multidimensional array? The idea is also simple, you write it as an array of arrays.
Code: Select all
int array[5][2];

Looping through an array like that is pretty simple as well. Just put a loop within a loop.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: array value setting

Postby Soullem » Sat Jan 19, 2013 7:33 pm

and then I can access the array from anywhere? wow, that would seem to be too easy.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: array value setting

Postby skydereign » Sat Jan 19, 2013 7:35 pm

Soullem wrote:and then I can access the array from anywhere? wow, that would seem to be too easy.

Do you understand scope? If you declared the integer within an event, it would only exist within the event. If you declared it within a function, it would only exist in that function. Now if you declare it in global code, then it will exist globally. That is pretty much all there is to it. It being an array doesn't change that it is a variable.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: array value setting

Postby Soullem » Sat Jan 19, 2013 11:22 pm

No I hadn't heard of that but it makes perfect sense. Thanks a lot for the new information, now I can continue to make progress on my game.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron