You are reading a single comment by @Owen and its replies. Click here to read the full conversation.
  • Thanks for the advice guys I've been rewriting all the code and it's much faster now. For the 'fallen' blocks that need to get rendered and checked for collisions I think I can copy and use the Graphics.buffer Array. I can renderer it using Graphics.drawImage() and easily check pixels for collisions by looking in the array (if it's colour is zero, it's empty).
    This method seems to work perfect, except one little issue. I have a 16x8 matrix which I've turned sideways and used Graphics.setRotation(1); . Sadly this breaks Graphics.drawImage(myCopyGraphicsBuffer)­;
    Is there a way to fix this?

    // Example code
    var m = Graphics.createArrayBuffer(16,8,24,{zigz­ag:true});
    m.flip = function(){ SPI2.send4bit(m.buffer, 0b0001, 0b0011); };
    m.setRotation(1);
    
    m.setColor(1,1,1);
    m.setPixel(0,0); // Top-left
    m.flip();
    
    // Copy buffer and clear matrix
    var a = new Uint8Array(m.buffer);
    var myBuffer = new Uint8Array(a);
    m.clear();
    
    var boardImg = {
      width: 16,
      height: 8,
      bpp: 24,
      buffer: myBuffer
    };
    m.drawImage(boardImg, 0, 0);
    m.flip();
    

    If you run this code the top-left pixel will flash white very quickly and disapear. If you comment out line 4 (m.setRotation(1);) the code work but obviously the bottom-left pixel lights up.

About

Avatar for Owen @Owen started