Hello there! Welcome to Programming Shenanigans! This is a blog documenting the trials and tribulations of two novice programmers as we try to navigate the weird and wondrous world of game coding.

Pages

Sunday, May 16, 2010

Tetris - ROTATIONS

So, the hardest thing about tetris, and by hard i mean tasking... Brute force checks. The game is simple enough that it doesn't require an abstract rotation routine, having brute force checks for each block is efficient enough (BUT NOT VERY FUN TO CODE :( !!! )

What i did was, to make a routine for each block that calculates where each of the 4 squares (all tetris blocks are made of 4 squares) would rotate to. I.E. what to add to x,y values. As you can probably guess, the worst case scenario has 3/4 blocks moving with 4 orientations for each block! Lots of horrendous brute forcing. The worst part was all the checking, in bounds and not over other blocks, that had to be done as well.

Initially, we had the idea of having a BlockKeeper (4x4 class of squares) that would fit al the blocks within it resulting in a common usable rotation between them all. However, deciding it would be better to have individual blocks, we scrapped that idea. Horrid.... Must have stuck to that plan. GENERALIZATION IS GOOD!


Need too make more general methods to override for later use!

1 comment:

  1. ... Y'ALL DISAPPOINT ME!

    Proshe = Pro she
    "Yay, feminist blog!" Ohh, it's a programming blog.

    BUT THEN!!!

    Proshe = PROSH

    From CuteOverload:
    You know how “Freshman” sometimes gets shortened into “Frosh?” Ergo, “Precious” –> “Prosh.” I’ve never seen “special” –> “sposh” though… anyhow, I like Lewis Carroll’s portmanteau method better; f’rinstance he invented “Chortle” by mashing “Chuckle” and “Snort” together in the Jabberwocky poem. The word “smog” = “smoke” + “fog”. Extra credit: “recidivindicated“.

    YAY!

    ReplyDelete

Followers