randomize_field vs randomize_buffer in example Life program

Support and discussion for the Video Game Shield.

Got a cool game you wrote? Need help getting it to work?

randomize_field vs randomize_buffer in example Life program

Postby jetit » Tue Jan 03, 2012 12:08 pm

Had to change the one randomize call to buffer in order to get that version working. We also added a check for nun_chuck_plugged_in in the init routine around delay_frame_or_break:
   if (nunchuck_plugged_in)
    {
      delay_frame_or_break_for_z(&nunchuck, 60*15);
    }
  TV.clear_screen();


as we've no nunchucks to work with yet. Changed the choices then to use a random selection for the first screen and a random pattern (rather than just #1):

void loop()
{
   int which = random(0,3);
   int pat = random(1,NUM_OF_PATTERNS + 1);
        switch (which)
          {
            case 0:
              randomize_buffer();           //uncomment this, and comment the other two lines here to get the field to begin randomly
              break;
            case 1:
               load_pattern_into_buffer(patterns[pat]);   //uncomment this, and comment the other two lines here to start with a pattern
               break;
            case 2:
                make_glider(32,32);          //uncomment this, and comment the other two lines here to start with a simple glider
                break;
          }
  



Learned you can't create a var inside the case stmt. body too!

Thanks!
jetit
 
Posts: 1
Joined: Tue Jan 03, 2012 11:52 am

Re: randomize_field vs randomize_buffer in example Life prog

Postby wayne » Wed Jan 04, 2012 9:33 am

Thanks! These changes let you use the Video Game Shield Game of Life game without a nunchuck, correct?
Adam Wolf, "Wayne" of Wayne and Layne, LLC
wayne
Wayne and Layne staff
 
Posts: 41
Joined: Thu Aug 19, 2010 10:06 am


Return to Video Game Shield

Who is online

Users browsing this forum: No registered users and 1 guest

cron