Random gamedev thought: I wonder what the easiest way to do Tetris is.
-
Random gamedev thought: I wonder what the easiest way to do Tetris is. One could treat each figure as three hardcoded offset coordinates * four rotations (the rotation point always being the 0,0 non-offset, not needing to be stored.
Then when the block moves L/R or Down, a point/cell collision check is run for the future position of point 0,0 and the three offsets (which vary by figure type and rotation).
Trying to save memory by doing dynamic matrix rotation just seems like unnecessary work.
-
Random gamedev thought: I wonder what the easiest way to do Tetris is. One could treat each figure as three hardcoded offset coordinates * four rotations (the rotation point always being the 0,0 non-offset, not needing to be stored.
Then when the block moves L/R or Down, a point/cell collision check is run for the future position of point 0,0 and the three offsets (which vary by figure type and rotation).
Trying to save memory by doing dynamic matrix rotation just seems like unnecessary work.
Tetris versions does have some quirks like:
Wall kickback for rotations.
Some versions having different rotation mechanics for e.g. the l piece, which can rotate in a way which makes it flip to the left and right side depending on whether it's 90 degrees or 180 degrees.
I suppose... one could actually hardcode the collision functions for all blocks and rotations and save a lot of checks. Most blocks only need to check 2 points, not 3 or 4. A square obv. doesn't rotate and only need to check 2
-
Tetris versions does have some quirks like:
Wall kickback for rotations.
Some versions having different rotation mechanics for e.g. the l piece, which can rotate in a way which makes it flip to the left and right side depending on whether it's 90 degrees or 180 degrees.
I suppose... one could actually hardcode the collision functions for all blocks and rotations and save a lot of checks. Most blocks only need to check 2 points, not 3 or 4. A square obv. doesn't rotate and only need to check 2
But since one needs to render the block on screen, the position of all 4 points must be known (unless it's an image rotated by a GPU I suppose). I think it's easier to just have a generic dumb point collision check routine and not mind blocks wasting checks into their own overlaps.
An more important aspect of Tetris is probably to theme it well, kind of like PuyoPuyo did with all the fun characters and cutscenes. NES Tetris had the character screen with stuff happening too. And music.
-
But since one needs to render the block on screen, the position of all 4 points must be known (unless it's an image rotated by a GPU I suppose). I think it's easier to just have a generic dumb point collision check routine and not mind blocks wasting checks into their own overlaps.
An more important aspect of Tetris is probably to theme it well, kind of like PuyoPuyo did with all the fun characters and cutscenes. NES Tetris had the character screen with stuff happening too. And music.
wrote last edited by [email protected]Haha, oh well--I knew the long piece and square were special cases but here they were given no special treatment and look what happened.
Best to just ignore the unwanted frames.
Would be interesting to have a 4+ long "snake piece". Steer it into shape and let it sink.
The original AMOS IDE doesn't allow formatting aside from auto-indents and as usual all variables are all-caps and brief. When submitting for magazine listings, usually the code was compacted like this with lots of colons.
-
Haha, oh well--I knew the long piece and square were special cases but here they were given no special treatment and look what happened.
Best to just ignore the unwanted frames.
Would be interesting to have a 4+ long "snake piece". Steer it into shape and let it sink.
The original AMOS IDE doesn't allow formatting aside from auto-indents and as usual all variables are all-caps and brief. When submitting for magazine listings, usually the code was compacted like this with lots of colons.
wrote last edited by [email protected]Playfield array--a standard 10x20. Because some pieces might want to test for collisions outside of the array when rotating or out of view, I opted for border sentinels rather than bounds check clutter code. This will waste dozens and dozens of bytes (signed ints, actually). Using something like a compact bitfield for the playfield is overly stingy and outside of the easy-tetris framework.
The Amiga has the ability to do very fast screen-copy, useful for the row-lowerings.
-
Playfield array--a standard 10x20. Because some pieces might want to test for collisions outside of the array when rotating or out of view, I opted for border sentinels rather than bounds check clutter code. This will waste dozens and dozens of bytes (signed ints, actually). Using something like a compact bitfield for the playfield is overly stingy and outside of the easy-tetris framework.
The Amiga has the ability to do very fast screen-copy, useful for the row-lowerings.
wrote last edited by [email protected]I wrote some pretty strange controls code. It's not uncommon to poll using inkey$, but here I look at keyboard scan codes instead (physical switch ID basically). But holding down rotate shouldn't turbo rotate, so I need a timer. Don't want to write that for like 8 keys, and put 8 configurable keys in an array, each with a timer and delayed auto-press. But with a for-loop one needs to direct inputs to the right thing... easy-peasy with GOSUB in basic--just need to goto the button press! Hah!
-
I wrote some pretty strange controls code. It's not uncommon to poll using inkey$, but here I look at keyboard scan codes instead (physical switch ID basically). But holding down rotate shouldn't turbo rotate, so I need a timer. Don't want to write that for like 8 keys, and put 8 configurable keys in an array, each with a timer and delayed auto-press. But with a for-loop one needs to direct inputs to the right thing... easy-peasy with GOSUB in basic--just need to goto the button press! Hah!
wrote last edited by [email protected]Another way to do a switch of sorts is to use On X Goto LABEL1, LABEL2, ETC
It's actually faster than jumping to numbers, probably due to how AMOS keeps track of label lists.Anyways, I've sloppily implemented piece strafing, collision test against walls and cemented pieces, and cementation. Have to do auto gravity ticks and the (already supported) rotation and piece change.
Gotta look up NES scoring.
Blocks will later be 12px (fast) image blits. Or HW sprites! Level themed palette changes?
-
Another way to do a switch of sorts is to use On X Goto LABEL1, LABEL2, ETC
It's actually faster than jumping to numbers, probably due to how AMOS keeps track of label lists.Anyways, I've sloppily implemented piece strafing, collision test against walls and cemented pieces, and cementation. Have to do auto gravity ticks and the (already supported) rotation and piece change.
Gotta look up NES scoring.
Blocks will later be 12px (fast) image blits. Or HW sprites! Level themed palette changes?
wrote last edited by [email protected]Gravity in place, random pieces, rotation. Added individual key-repeat timers for "feel" reasons. Holding Down moves down piece pretty fast. I think Up is usually linked to instant drop, but that needs a bit of special time warp code.
This is the default AMOS palette. I haven't thought much about graphics, but I might do 32 colours, with 16 upper shared for blocks and falling block sprites, and lower 16 + upper 16 for some sort of Puzznic pinup or PuyoPuyo character.
Unsure about RNG/urn draw.
-
Gravity in place, random pieces, rotation. Added individual key-repeat timers for "feel" reasons. Holding Down moves down piece pretty fast. I think Up is usually linked to instant drop, but that needs a bit of special time warp code.
This is the default AMOS palette. I haven't thought much about graphics, but I might do 32 colours, with 16 upper shared for blocks and falling block sprites, and lower 16 + upper 16 for some sort of Puzznic pinup or PuyoPuyo character.
Unsure about RNG/urn draw.
wrote last edited by [email protected]Thoughts on Tetris scoring:
Aside from the normal line clearing scoring (with a consecutive bonus?), points can usually be awarded by soft (accelerate) and hard (insta) dropping the blocks. Here I think I might just count time soft dropped and not whether the block touches the ground. For hard dropping I could look at height only.T-spins could be evaluated by looking for a side overhang after placing a T piece in the T orientation.
I want to add a shop so the score can be used >_<
-
Thoughts on Tetris scoring:
Aside from the normal line clearing scoring (with a consecutive bonus?), points can usually be awarded by soft (accelerate) and hard (insta) dropping the blocks. Here I think I might just count time soft dropped and not whether the block touches the ground. For hard dropping I could look at height only.T-spins could be evaluated by looking for a side overhang after placing a T piece in the T orientation.
I want to add a shop so the score can be used >_<
@androidarts would the shop unlock extra colors/textures for the block ?
-
@androidarts would the shop unlock extra colors/textures for the block ?
@PypeBros I'm not quite sure... maybe score collects in a wealth pool to give a sense of permanence... and can then be used to unlock aesthetics (maybe side art).
Or, there's an ingame shop with abilities, like a bomb, laser, temp slowdown for panic situations. I don't want to be too orthodox and just do another tetris.... though I probably shouldn't feature creep.