[Game]Pokittris

@jonne - Nope, the easing is only used on the title screen.

1 Like

Ok then. The blocks rotate nicely, they drop nicely, but sideways movement and the “normal fall” is very slow.

what can be done about that?

1 Like

@jonne - It’s the frame counting in the playgame() funtion…

void playGame(){

    if (_Left[NEW]) {
      if (check(px - 1, py, pr) == 0) {
        px--;
        slideTime = 0;
      }
    }
    if (_Right[NEW]) {
      if (check(px + 1, py, pr) == 0) {
        px++;
        slideTime = 0;
      }
    }
    if (_Left[HELD] && slideTime++ > 6) {
      if (check(px - 1, py, pr) == 0) {
        px--;
        slideTime = 12;
      }
    }
    if (_Right[HELD] && slideTime++ > 6) {
      if (check(px + 1, py, pr) == 0) {
        px++;
        slideTime = 12;
      }
    }

    if ((_Down[HELD]) || (dropTime++ > 20 - (level * 2))) {
      dropTime = 0;
      if (check(px, py+1, pr) == 0) {
        py++;
      } else {
        // place shape and create new one
        stamp(px, py, ps, pr);
        checkLine();
        py = 0; px = 6; ps = nextTile; nextTile = random(6); pr = 0;
      }
    }
slideTime++ > 6

and

(dropTime++ > 20 - (level * 2))

will need changed to match the real frame rate on hardware.

1 Like

My guess is that the framerate on hardware is a bit different from the simulator?

[edit] change line 225 to this for a better representation of the red palette -

int greyPal[] = {0xF800,0xF8000,0xF800,0xF800}; // it's actually RED for danger!

perhaps this is better for the timing? -


if (_Left[HELD] && slideTime++ > 3) {
  if (check(px - 1, py, pr) == 0) {
    px--;
    slideTime = 12;
  }
}
if (_Right[HELD] && slideTime++ > 3) {
  if (check(px + 1, py, pr) == 0) {
    px++;
    slideTime = 12;
  }
}

if ((_Down[HELD]) || (dropTime++ > 10 -(level)) {
  dropTime = 0;
  if (check(px, py+1, pr) == 0) {
    py++;
  } else {
    // place shape and create new one
    stamp(px, py, ps, pr);
    checkLine();
    py = 0; px = 6; ps = nextTile; nextTile = random(6); pr = 0;
  }
}
1 Like

The retro look is great but I can see myself playing in color mode, it looks wild.

1 Like

we need to see that frame rates are regulated, but heres a temp fix

void playGame(){
    #ifdef POK_SIM
    #define SLIDECOUNT 6
    #define DROPCOUNT 20
    #else
    #define SLIDECOUNT 1
    #define DROPCOUNT 2
    #endif
    if (_Left[NEW]) {
      if (check(px - 1, py, pr) == 0) {
        px--;
        slideTime = 0;
      }
    }
    if (_Right[NEW]) {
      if (check(px + 1, py, pr) == 0) {
        px++;
        slideTime = 0;
      }
    }
    if (_Left[HELD] && slideTime++ > SLIDECOUNT) {
      if (check(px - 1, py, pr) == 0) {
        px--;
        slideTime = 12;
      }
    }
    if (_Right[HELD] && slideTime++ > SLIDECOUNT) {
      if (check(px + 1, py, pr) == 0) {
        px++;
        slideTime = 12;
      }
    }

    if ((_Down[HELD]) || (dropTime++ > DROPCOUNT - (level * 2))) {
      dropTime = 0;
      if (check(px, py+1, pr) == 0) {
        py++;
      } else {
        // place shape and create new one
        stamp(px, py, ps, pr);
        checkLine();
        py = 0; px = 6; ps = nextTile; nextTile = random(6); pr = 0;
      }
    }

And for the title screen

 int y=48;
    if(frameNumber<=64){
                        // time, start, distance, duration
        #ifdef POK_SIM
        y = easeOutBounce(frameNumber, -48, 48+48, 64);
        #else
        y = easeOutBounce(frameNumber*4, -48, 48+48, 64);
        if (y>48) y=48;
        #endif
    }
    drawMyBitmap(16, y, title_bitmap, title_mask);
4 Likes

Dang that looks really good.

Update - download in first post…

Added Jonnes changes to work around the current the current timing issues.
Added line removal animation.
Added palette change between title screen and main game.

3 Likes

Double post, I apologize if we don’t like that here.

Updated (download in first post) Added ‘destroy tile’ feature, which can only be used once a ‘tetris’ (4 lines at once) is scored. Even then you only get one until you score another. Once your 4 lines have completed, pressing ‘Up’ will destroy the current piece.

2 Likes

Looks so nice its really a killer! TBH i don’t like the one or two pixel border between the shapes in the field, don’t tetris shapes normally touch each other?

Depends on the version, in mine they don’t :slight_smile:

so i tried to compile this on hardware and it works pretty well, (the logo animation is a bit slow)
i handed it over to my local Tetris expert (my grandma) she kept playing :wink:
the only complaint i got from her is that you cant see the columns
(recommend a gird background pattern in a light grey)

2 Likes

I’m finding it a little unresponsive, I can’t quite find a way to increase the speed, changing the POK_FPS define doesn’t seem to be doing anything. I’d certainly prefer it to run the same speed as in the simulator.

You are redrawing the entire screen all the time including the static background. Slows it down.

Welcome to the world of real hw limitations :slight_smile:

1 Like

I was starting to think in that direction, I’ve been looking at sensitive, got it almost playable speed by only drawing the area around the ball. Direct Pixel is still slow though.

use directBitmap
only draw the tile that has to move and the baground tiles that have to be refreshed

or dont use direct at all

check out pokittohw folder. roll your own graphics mode!

directBitmap used directPixel, it wouldn’t be any faster. What I think I’d need would be a directRow, something like that, so I could draw a line of 10 or so pixels at a time.

Wonderful! Tell us when its ready to use! Check out lcdRefreshMode2 or any of those functions and you’ll see its <1hr job to make it

hmm i see, thats defiantly needs optimisation
directBitmap should work similar to lcdRectangle