Arduino

ColorSmash on Pixelbox

{newstitle-3

2016-04-26 18:19:48

Geschreven door: Jakob

Begincode voor een remake van het spel 2048. Dit is slechts het begin!

/* * Naam: ColorSmash
 * FileNaam:ColorSmash
 * Versie: V0.1
 * Maker: Jakob Robijns
 * 6H07
 * Damiaaninstituut Aarschot *

TODO:

0   1   2   3   4   5   6   7   8   9   10  11
23  22  21  20  19  18  17  16  15  14  13  12
24  25  26  27  28  29  30  31  32  33  34  35
47  46  45  44  43  42  41  40  39  38  37  36
48  49  50  51  52  53  54  55  56  57  58  59
71  70  69  68  67  66  65  64  63  62  61  60
72  73  74  75  76  77  78  79  80  81  82  83
95  94  93  92  91  90  89  88  87  86  85  84
96  97  98  99  100 101 102 103 104 105 106 107
119 118 117 116 115 114 113 112 111 110 109 108
120 121 122 123 124 125 126 127 128 129 130 131
143 142 141 140 139 138 137 136 135 134 133 132
 */
//INSTELBARE VARIABELEN
byte numberLeds = 144; //Aantal Leds aan de LEDstrip
byte dataPin  = 2;  //Datapin aan de Arduino
byte clockPin = 3;  // Clockpin aan de Arduino
boolean wallDeath = 0;  //Als het de muur aanraakt, ben je dood
int delayMovingSnake = 200; //De tijd tussen de moveSnakeingen, hoe kleiner, hoe sneller.
byte matrixColors[16] = {
  0, 1, 2, 0,
  1, 0, 1, 0,
  2, 1, 1, 0,
  0, 0, 0, 1
};
#include "LPD8806.h"
#include "SPI.h"
LPD8806 strip = LPD8806(numberLeds, dataPin, clockPin);
void setup()
{
  pinMode(A4,INPUT);
   pinMode(A5,INPUT);
  Serial.begin(9600);
  strip.begin();
  strip.show();
  Serial.println("===begin===");
  for (byte i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, 0, 0, 0); // Set new pixel 'on'
    //          pinnummer,R,G,B
  }
  strip.show();
  placeMatrix();
  delay(5000);
}


void loop()
{
  placeMatrix();
  joystick();
}

void placeMatrix()  //Toont(update) de Matrix
{
  byte ledNumber = 0;
  byte tellermatrixColors = 0;
  int RGBcolorRed;
  int RGBcolorGreen;
  int RGBcolorBlue;
  boolean tijdelijkevarRichting = 0;
  byte nogneteller = 0;
  for (byte stripCounter = 0; stripCounter < 12; stripCounter ++) {
    for (byte i = 0; i < 4; i++) { //0 -> 11
      if (matrixColors[tellermatrixColors] == 0) { //in geval van geen kleur (zwart)
        RGBcolorRed = 255;
        RGBcolorGreen = 0;
        RGBcolorBlue = 0;
      } else if (matrixColors[tellermatrixColors] == 1) {
        RGBcolorRed = 0;
        RGBcolorGreen = 255;
        RGBcolorBlue = 0;
      } else if (matrixColors[tellermatrixColors] == 2) {
        RGBcolorRed = 0;
        RGBcolorGreen = 0;
        RGBcolorBlue = 255;
      } else if (matrixColors[tellermatrixColors] == 3) {
        RGBcolorRed = 0;
        RGBcolorGreen = 255;
        RGBcolorBlue = 255;
      } else if (matrixColors[tellermatrixColors] == 4) {
        RGBcolorRed = 255;
        RGBcolorGreen = 255;
        RGBcolorBlue = 0;
      } else if (matrixColors[tellermatrixColors] == 5) {
        RGBcolorRed = 255;
        RGBcolorGreen = 255;
        RGBcolorBlue = 255;
      }

    /*  Serial.print(tellermatrixColors);      Serial.print('\t');      Serial.print(matrixColors[tellermatrixColors]);      Serial.print('\t');      Serial.print(RGBcolorRed); Serial.print(","); Serial.print(RGBcolorGreen); Serial.print(","); Serial.print(RGBcolorBlue);      Serial.print('\t');      Serial.print(ledNumber);      Serial.print("-->");*/
      strip.setPixelColor(ledNumber,  RGBcolorRed,  RGBcolorGreen,  RGBcolorBlue);
      ledNumber++;
      strip.setPixelColor(ledNumber,  RGBcolorRed,  RGBcolorGreen,  RGBcolorBlue);
      ledNumber++;
      strip.setPixelColor(ledNumber,  RGBcolorRed,  RGBcolorGreen,  RGBcolorBlue);
      ledNumber++;
      if (tijdelijkevarRichting == 0) { //Eerste rij richting ===>
        tellermatrixColors++;
      } else {
        tellermatrixColors--;
      }
    //  Serial.println(ledNumber);
    }

    if (tijdelijkevarRichting == 0) {
      tellermatrixColors--;
      tijdelijkevarRichting = 1;
      //  ledNumber += 12;
    } else {
      tellermatrixColors++;
      tijdelijkevarRichting = 0;
    }
    if (stripCounter == 2 || stripCounter == 5 || stripCounter == 8 || stripCounter == 11) {
      tellermatrixColors += 4;
    //  Serial.println(tellermatrixColors);
    }
  //  Serial.println("Nieuwe lijn");
  }
  strip.show();
}

void joystick() { //Bekijkt de bewegingen van de joystick      !!!NOG VERBETEREN!!!
   Serial.println(analogRead(A0));
  if (analogRead(A0) < 1020) {  //Als de Yjoystick boven is (zo goed als).
    updateMatrix(1);
    Serial.println("boven");
  }
  if (analogRead(A0) > 1020) {  //Als de Yjoystick onder is (zo goed als).
    updateMatrix(2);
    Serial.println("onder");
  }
  if (analogRead(A1) > 1020) {  //Als de Xjoystick rechts is (zo goed als).
    updateMatrix(3);
    Serial.println("rechts");
  }
  if (analogRead(A1) < 1020) {  //Als de Xjoystick links is (zo goed als).
    updateMatrix(4);
    Serial.println("links");
  }
}



void updateMatrix( byte direction1) {
  byte y;
  byte i;
  switch (direction1) {
    case 1: //Boven
      y = 0;
      i = 0;
      for (byte repeat = 0; repeat < 4; repeat++) {
        for (i = 0; i < 16; i++) {
          y = i - 4;
          if ((matrixColors[i] == matrixColors[y]) && matrixColors[i] != 0) {
            Serial.print("Samenvoegen");
            Serial.print('\t');
            Serial.print(i);
            Serial.print('\t');
            Serial.println(matrixColors[i]);
            matrixColors[y]++;
          }
        }
      }
      for (i = 0; i < 16; i++) {
        y = i - 4;
        if (matrixColors[y] == 0 && matrixColors[i] != 0 &&  y < 17 ) {
          Serial.print(matrixColors[y]);
          Serial.print(",");
          Serial.print(y);
          Serial.print("  ");
          Serial.print(matrixColors[i]);
          Serial.print(",");
          Serial.print(i);
          Serial.print("-->");
          matrixColors[y] = matrixColors[i];
          matrixColors[i] = 0;
          Serial.print(matrixColors[y]);
          Serial.print(",");
          Serial.print(matrixColors[i]);
          Serial.print('\t');
          Serial.println("boven gaan");
        }
      }
      break;
    case 2: //Beneden
      for (byte repeat = 0; repeat < 4; repeat++) {
        for (i = 0; i < 12; i++) {
          y = i + 4;
          if ((matrixColors[i] == matrixColors[y]) && matrixColors[i] != 0) {
            Serial.print("Samenvoegen");
            Serial.print('\t');
            Serial.print(i);
            Serial.print('\t');
            Serial.println(matrixColors[i]);
            matrixColors[y]++;
          }
        }
      }
      for (i = 0; i < 12; i++) {
        y = i + 4;
        if (matrixColors[y] == 0 && matrixColors[i] != 0 &&  y < 16 ) {
          Serial.print(matrixColors[y]);
          Serial.print(",");
          Serial.print(y);
          Serial.print("  ");
          Serial.print(matrixColors[i]);
          Serial.print(",");
          Serial.print(i);
          Serial.print("-->");
          matrixColors[y] = matrixColors[i];
          matrixColors[i] = 0;
          Serial.print(matrixColors[y]);
          Serial.print(",");
          Serial.print(matrixColors[i]);
          Serial.print('\t');
          Serial.println("boven gaan");
        }
      }


      break;
    case 3: //Links
      byte y = 0;
      byte i = 0;
      for (byte repeat = 0; repeat < 4; repeat++) {
        for (i = 0; i < 16; i++) {
          y = i - 1;
          if ((matrixColors[i] == matrixColors[y]) && matrixColors[i] != 0) {
            Serial.print("Samenvoegen");
            Serial.print('\t');
            Serial.print(i);
            Serial.print('\t');
            Serial.println(matrixColors[i]);
            matrixColors[y]++;
          }
        }
      }
      for (i = 0; i < 16; i++) {
        y = i - 1;
        if (matrixColors[y] == 0 && matrixColors[i] != 0 &&  y != 3 && y != 7 && y != 11 ) {
          /*      Serial.print(matrixColors[y]);                Serial.print(",");                Serial.print(y);                Serial.print("  ");                Serial.print(matrixColors[i]);                Serial.print(",");                Serial.print(i);                Serial.print("-->");*/
          matrixColors[y] = matrixColors[i];
          matrixColors[i] = 0;
          /*      Serial.print(matrixColors[y]);                Serial.print(",");                Serial.print(matrixColors[i]);                Serial.print('\t');*/
          Serial.println("Links gaan");
        }
      }
  }
  delay(200);
}




// Jakob 6H07  2015-2016





Aantal likes:33

Reacties:

My spouse and i have been now glad that Michael could finish off his analysis using the ideas he had in your site. It is now and again perplexing just to always be giving out guidelines which often many people may have been trying to sell. And now we recognize we have got the website owner to give thanks to for that. All of the illustrations you made, the straightforward blog navigation, the friendships you aid to promote - it's mostly spectacular, and it's facilitating our son in addi
I simply desired to say thanks once again. I am not sure what I might have carried out without the actual secrets shown by you regarding such a situation. It actually was an absolute daunting case in my circumstances, however , viewing the skilled technique you dealt with it made me to jump over contentment. I will be grateful for the service as well as trust you realize what a powerful job your are putting in training the others through the use of your web site. Probably you haven't met al
I simply had to appreciate you yet again. I'm not certain the things I would have followed without the actual techniques revealed by you regarding such situation. Completely was the frustrating situation in my opinion, nevertheless taking note of the very professional technique you resolved that took me to jump with fulfillment. Now i am happier for the support and in addition expect you know what an amazing job you are carrying out training people today through the use of your blog post. I
I want to show some thanks to this writer for bailing me out of this incident. Just after looking out throughout the online world and finding principles that were not helpful, I thought my life was gone. Existing minus the strategies to the difficulties you have sorted out by way of your entire site is a serious case, as well as the kind that might have adversely affected my entire career if I had not come across your web site. Your competence and kindness in dealing with every aspect was import
Thank you so much for providing individuals with an extremely terrific possiblity to discover important secrets from this web site. It is often so enjoyable and jam-packed with a lot of fun for me personally and my office fellow workers to visit your site at a minimum 3 times a week to study the fresh stuff you have got. And definitely, I am at all times contented for the mind-blowing solutions served by you. Certain 4 tips in this post are easily the most suitable we've ever had.
I as well as my guys were taking note of the best secrets located on your web page and so before long got an awful feeling I had not expressed respect to the site owner for those secrets. All of the men appeared to be absolutely joyful to see all of them and have in effect quite simply been tapping into those things. Many thanks for truly being well thoughtful and then for using certain high-quality ideas millions of individuals are really wanting to learn about. Our honest regret for not expres
I wish to show thanks to this writer for bailing me out of this particular scenario. After researching throughout the world-wide-web and seeing suggestions that were not powerful, I thought my entire life was gone. Existing minus the approaches to the problems you have sorted out all through your entire review is a serious case, as well as ones that would have adversely affected my entire career if I had not come across the website. Your mastery and kindness in controlling a lot of things was i
Needed to send you the very little note to say thanks again for your lovely tips you have discussed in this case. This is incredibly generous with you to give freely what exactly a few individuals might have advertised for an e-book to earn some profit for their own end, especially considering that you might well have tried it in case you desired. These solutions likewise acted to be a great way to fully grasp other individuals have similar keenness the same as my very own to grasp good deal mo
I have to express appreciation to this writer just for rescuing me from this predicament. Right after looking through the online world and coming across techniques which were not pleasant, I thought my entire life was over. Living minus the approaches to the problems you have solved by way of the guideline is a critical case, and the ones which might have negatively affected my entire career if I hadn't encountered your website. The skills and kindness in controlling the whole thing was va
Thank you so much for giving everyone an exceptionally special possiblity to read critical reviews from this web site. It is always very superb plus packed with a great time for me and my office friends to search your blog nearly thrice in 7 days to read through the latest guides you have. And of course, I am just at all times pleased with the excellent techniques served by you. Some 1 ideas in this post are indeed the most effective we've ever had.
1. Аренда помещений под склад или производство.Цена от 30 рублей за 1 м.кв.Охраняемая территория с большим пространством для техники.Удобный подьезд, сразу при въезде в город.
2. Парковка места под грузовой транспорт от 150 рублей за ночь.
3. Общежитие. Отель эконом. Возможност
I precisely wished to say thanks all over again. I'm not certain what I could possibly have sorted out in the absence of those tactics documented by you directly on such a problem. It previously was an absolute intimidating concern in my opinion, nevertheless viewing your expert avenue you dealt with it forced me to leap with contentment. Now i am thankful for this service and as well , wish you are aware of an amazing job that you're providing teaching most people with the aid of your
Jordan 12 Gym Red 2018 http://www.jordan12gymred.us.com/
nike factory outlet store online http://www.nikefactoryoutletstoreonline.com/
nike factory outlet store online http://www.nikefactoryoutletstoreonline.us/
Nike Store http://www.nikestores.us.com/
jordan 33 http://www.jordan33.us/
cheapjerseysfromchina http://www.cheapjerseysfromchina.us/
cheap custom nfl jerseys http://www.customnfljerseys.us/
jordan 11 concord http://www.jordan11concord.us.com/
Air Jordan 12 Gym Red http:/
I simply wanted to compose a remark to be able to say thanks to you for all the awesome tips you are placing on this site. My time-consuming internet investigation has now been paid with useful suggestions to go over with my colleagues. I would tell you that many of us site visitors actually are really fortunate to dwell in a really good community with very many outstanding people with very helpful tips. I feel somewhat blessed to have encountered your entire webpages and look forward to plenty
I actually wanted to write down a brief word to appreciate you for some of the nice facts you are placing here. My prolonged internet search has at the end been recognized with really good knowledge to write about with my pals. I 'd assert that most of us readers are very much lucky to live in a useful site with so many lovely people with great tips and hints. I feel pretty fortunate to have encountered your entire weblog and look forward to plenty of more enjoyable times reading here. Than
I enjoy you because of your entire efforts on this site. My niece takes pleasure in doing investigations and it is simple to grasp why. A lot of people learn all of the powerful mode you provide functional guidance through this web site and strongly encourage contribution from website visitors on that theme while our favorite simple princess is now studying a whole lot. Have fun with the remaining portion of the year. You are always performing a first class job.
My spouse and i felt really excited Albert managed to finish off his web research because of the precious recommendations he grabbed from your site. It's not at all simplistic just to happen to be giving away strategies that many some other people could have been trying to sell. And we also grasp we now have you to be grateful to for this. Those illustrations you made, the straightforward site navigation, the relationships you aid to promote - it's got mostly terrific, and it is letti
My husband and i ended up being now relieved when Ervin could finish off his research through the precious recommendations he got from your very own blog. It's not at all simplistic to just happen to be giving for free secrets and techniques that many men and women may have been making money from. And we all discover we now have you to give thanks to for this. The specific illustrations you've made, the simple website navigation, the friendships your site aid to promote - it's got
Купить Кокаин
Купить Кокаин
Generic cialis generic cialis tadalafil fast cialisvi.com
cialis 20mg prix en pharmacie http://cialisvi.com/
tadalafil 5mg generic http://cialisvi.com/
Cialis generic
http://puzzlego.com/__media__/js/netsoltrademark.php?d=cialisvi.com
https://www.youtube.com/watch?v=-7-X0-w_rFs
https://www.youtube.com/watch?v=oFr_XacoKIc
https://www.youtube.com/watch?v=vnyt6sbp-dk
https://www.youtube.com/watch?v=SyUqKAVGrKo
https://www.youtube.com/watch?v=gvbyo8q-YMQ
https://www.youtube.com/watch?v=vnyt6sbp-dk
cod online viagra cz
drugstore online buy viagrow canadianpharmacyonli.com
canadian government approved pharmacies http://canadianpharmacyonli.com/
canada online pharmacies medication http://canadianpharmacyonli.com/
online pharmacies canada
http://trading
cialis purchase online without prescription purchasing cialis on the internet cialisonl.com
tadalafil 20mg india http://cialisonl.com/
buy cheap cialis in canada http://cialisonl.com/
cialis without a doctors prescription
http://ggvcapital.info/__media__/js/netsoltrademark.php?d
Young Heaven - Naked Teens & Young Porn Pictures
http://download.porn.hotblognetwork.com/?zoe

u videos porn teen gets gang banged free porn amateur porn community camilla jayne porn videos dw read porn

generisches online is
I simply desired to say thanks once more. I do not know the things I would've followed without the entire tips and hints shared by you relating to such a question. Certainly was a very alarming concern in my position, but noticing the very expert way you handled the issue made me to weep with contentment. Extremely happier for this work and in addition trust you realize what a powerful job you happen to be providing instructing most people by way of your site. Most likely you've never
Cialis canada cialis purchase online without prescription cialisb.com
cialis prices mexico http://cialisb.com/
cialis without a doctor's prescription in usa http://cialisb.com/
Best buy canada online
http://kilometrico.biz/__media__/js/netsoltrademark.php?d=cialisb.com
is come cura

0d1c venta is en mano madrid
viagra without prescription Generic viagra viagravipsale.com
Viagra or viagra http://viagravipsale.com/
generic viagra available http://viagravipsale.com/
viagra prices
http://harvestapartmentstracy.com/__media__/js/netsoltrademark.php?d=viagravipsale.com
drugstore online canada online pharmacies for men canadianpharmacytousa.com
canadian drug store http://canadianpharmacytousa.com/
canadian rx world pharmacy http://canadianpharmacytousa.com/
online pharmacies canada
http://touriosi
achat is en ligne france

0d1c achat is en ligne france
tadalafil without a doctor's prescription cialis tablets cialisonl.com
tadalafil 5mg troche http://cialisonl.com/
cialis from usa pharmacy http://cialisonl.com/
cialis without a doctors prescription
http://internet-magazin-shiny-i-diski.ru/bitrix/rk.php?goto=http://cialison
Купить Кокаин
Купить Кокаин
Cialis prices cialis 20mg usage cialisiv.com
cialis 20 mg directions http://cialisiv.com/
cialis 5 mg price at walmart http://cialisiv.com/
Cialis pills
http://embryoidbody.com/__media__/js/netsoltrademark.php?d=cialisiv.com
is before surgery

0d1c is 10mg in the usa
canadian pharmaceuticals online canadian online pharmacies legal canadianpharmacyonli.com
online pharmacies tech school http://canadianpharmacyonli.com/
canadian drug http://canadianpharmacyonli.com/
online canadian pharmacies
http://t
viagra for sale online ireland generic viagra from canada reviews http://lizlarssen.com
tadalafil without a doctors prescription cialis 20mg prix en pharmacie cialisonl.com
cialis comanda http://cialisonl.com/
forum cialis uk http://cialisonl.com/
tadalafil without a doctor's prescription
http://gemalert.com/__media__/js/netsoltrademark.php?d=cialisonl.com
&
cheap viagra viagra 25mg dosing viagraiy.com
viagra tablets india http://viagraiy.com/
viagra 20mg directions http://viagraiy.com/
online viagra
http://artisan-veranda.com/__media__/js/netsoltrademark.php?d=viagraiy.com
Tadalafil tablets cialis 5 mg cialisiv.com
cialis online usa http://cialisiv.com/
cialis generico http://cialisiv.com/
Generic for cialis
http://lapetussolutionsinc.com/__media__/js/netsoltrademark.php?d=cialisiv.com
order is soft online dhl

0d1c is kamagra availabl
is 20 mg prezzo

0d1c wow look it is be cheap