Sprint #2 - Daily Scrum #02
Product: Tetris2P AI
Sprint Summary
Daily Objectives
- Figure out the data structures
- Start fleshing out the game logic and game loops in pseudo code
- Start implementation and coding
Notes
So to start off, we’re creating a 10x25(?) grid
I need to take note of initial orientations of each piece
- Each piece starts in their ‘flattest’ orientation
- Only appears on the 20th row initially
Each piece rotates in a 4x4 square
Each piece will have a ‘reference’ point at the bottom left most square of the 4x4 square
The orientations of each piece will be described in reference to that reference point
- Ex: Orientation 1 of the orange L piece will use up (2,3), (2,2), (2,1) and (3,1) spaces
The ‘reference’ point doesn’t have to be confined within the 10x25 since the orientation of a piece doesn’t always fill the (1,1) square
KICKS: when a tetris piece tries to rotate, but a square(s) would overlap with where it would rotate into, a kick occurs
- The piece is just shifted either upwards or sideways until its in a legal position
- However need to figure out how to prevent abuse
- OH the game can transition between using drop speed and lock delay
- Once there’s is a static piece underneath the piece, switch to the lock delay, instead of drop speed (make sense since shouldn’t be able to drop anymore). After each rotation check if there’s still a static piece underneath the piece, if not then reset to the lock delay and switch back to drop speed
Lock Delay: time before a piece touching the ground waits before locking in its position
-
I don’t think this is something I need to implement cause it just needs to move downward again to lock? - Nvm just realized this is necessary since the drop speed is different from the lock delay
- Are there any situations where a piece can no longer rotate?
- Floor and Wall Kicks can only move max 2 spaces in any direction; if every kick is invalid, then the piece won’t be able to rotate
Things I need to figure out, for implementation:
- How to have multiple loops running?
- I’m concerned about code optimizations and efficiency
- I made an html5 game a long time ago when i started learning javascript
- Ran into major optimization issues cause I did some makeshift collision detection between every single bullet and every single enemy :)
Side note we’re assuming Object Oriented Programming
Things to consider for optimization:
- Sprite sheet? Probably unnecessary for initial tetris game, but might do add ons later for aesthetic purposes
- Actually at one point sprites are more optimized than canvas ctx objects apparently
- Use integers apparently
- OOP or ECS
- I took notes on this but for unity instead
- I can look at other examples, but tbh I shouldn’t over engineer this lmao
- This is still a bit down the road but should look up lobby making and stuff
- I think i have reference image for that from yesterday’s thing though so its fine for now
I think for now I should look at coding examples first? And then figure out the OOP Objects based off that and this tetris game.
I think it’d actually just be better to build a standalone single player gamer first to get down all the mechanics, so I will do just that
Should I consider incorporating React into this game?
- React is a framework for updating content on a web page when new information is updated. We have socket.io though and an actual game loop so I think it’s unnecessary. I want make the entire game without using a template probably?
- I can go back and using my old html5 game canvas code, BUT I need to learn how to implement timers and periodic events and fps sort of stuff
- requestAnimationFrame()
- This website is BERRY useful Need to think more about controls, move on key down, but not again until key up
- Later want to do fast moving left and right Notes from this link: website
- ‘Lockstep’ ensures all players are playing at the same pace
- Drop a player if there’s lagging too much
- Velocity and other time based variable need to be scaled based off of the ‘delta’ variable, which represents the amount of time that has passed between rendering frames
- delta = timestamp - lastFrameTimeMs where lastFrameTimeMs is the timestamp for the last
- Only run update() when delta > timestep
- Timestep is a fixed value
- Reduce value of delta by timestep after update()
- var timestep = 1000 / 60;
- After a certain number of update loop steps:
- Discard un-rendered frames, and hard update to server state
- Increase timestep if update loop takes too long
Objectives Completed
-
Figured out and detailed most of the Tetris mechanics
-
Gained a better understanding of javascript game loops and maintaining consistent fps and timing