switch for arrays

Game Editor comments and discussion.

switch for arrays

Postby Fojam » Mon Jan 09, 2012 11:48 pm

is there any way to do something like a switch, but for arrays? like check which value(s) in the array equal(s) one, and then do something different depending on which value(s) equal(s) one?
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: switch for arrays

Postby skydereign » Tue Jan 10, 2012 12:40 am

Do you mean to run a switch through a loop like this?
Code: Select all
int array[10] = {0,1,2,3,4,5,6,7,8};
int i;
for(i=0;i<10;i++)
{
    switch(array[i])
    {
        case 0:
        // do something
        break;

        // and the other cases
    }
}


Or perhaps you mean find the subs of the array that are 1, and execute code depending on the place of the array?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: switch for arrays

Postby Fojam » Tue Jan 10, 2012 12:51 am

yeah i was thinking about doing something through a loop but i was hoping for a simpler way. ok well ill just do that.
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score

Re: switch for arrays

Postby extremalyfresh » Tue Jan 24, 2012 7:14 pm

Do you need to use the code in draw event or can be collision or create event? I was looking for similar code but I will need it probably to loop once only and then stop.
Do you speak Polish? If yes here is a useful Game Editor website for you:
http://www.sgames.pl/
You can find some useful articles and examples there.
You can try and test a Quiz Game as well.
It has been made with use of Game Editor.
extremalyfresh
 
Posts: 13
Joined: Thu Dec 22, 2011 3:36 pm
Location: Poland
Score: 0 Give a positive score

Re: switch for arrays

Postby schnellboot » Tue Jan 24, 2012 8:27 pm

it can be everywhere
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest