Discuss Scratch
- Discussion Forums
- » Show and Tell
- » Detailed explanation of my project "100% pen Gameboy Tetris"
- MartinBraendli2
-
100+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"
I promised to do a detailed explanation if there is enough interest in the project. It looks like there is. If you havent seen the project, this post doesnt make sense to you. It might also be a bit chaotic, since i try to answer als questions i recieved in this single post (will update it)
Composition Editor
Click outside of the “Gameboy screen” while pressing “c” to access the hidden composition editor. This lets you edit all the backgrounds that are used in the game.
- On the left you have the palette with all the sprites you can use. Click on the buttons above and below the palette to scroll. On the bottom right you see the spright that you have currently selected.
- The “NEW” button lets you create a new composition. Everything red will be transparent.
- “LOA” lets you load any composition. If you want to edit for example the copyright splash, click on “LOA” and then enter 1.
- “SAV” lets you save a composition. Unlike load, you cant just type the index number of a filename to overwrite it. To overwrite the copyright splash, you have to save it as “copyright”, not “1”.
- “TXT” lets you write stuff. You can also include non-text sprites. Just use backslash followed by the 5-letter name of the sprite. For example click on “TXT”, then somewhere on the canvas and enter “i \heart tetris”
- “CPY” lets you select a sprite you already used on the canvas.
- “FIL” works like the bucket tool in ms paint, but it doesnt check for continuous filling. click on a sprite, then on “FIL” and then on the part of the canvas (for example the red background) that you want to replace.
- “TRN” lets you make parts of the canvas transparent.
- Click on the “Sprite”-Tab on the top to get to the sprite editor.
Sprite Editor
First few words about sprites. Every sprite is 8x8 pixels and consists only of a background and a number or horizontal or vertical lines in one of 4 colors. The Sprite is stored in a code of digits 0-7:
The first one codes the backgound color (0=white, 1= light gray, 2= dark gray, 3= black). The following digits code the lines.
Every line needs 4 digits. The modulo-4 of the first digit tells you the color of a line. So if the first digit of a “line code” is 6, it means that the line is darkgray (6%4 = 2). If the line is horizontal, then the first digit is < 4, for a vertical line >= 4. 2nd and 3rd digit are the x and y coordinates of the starting point of the line (lower left point). The 4th digit tells you, how long the line is.
“NEW” creates a new sprite with the currently selected color as background. “DEL” lets you delete a sprite (careful!). “PRV” and “NXT” let you scroll through the saved sprites. “XXX” removes the last line of a sprite. You can use it like “undo” in other editors.
Screenshot
While in game, you can press s and click to make a screenshot. You can then go to the composition manager to load the screenshot (and use the tools to make your score look more impressive
)
With r+click you can record a gameplay. This will overwrite the “idle-sequence” that appears when you idle on the title screen for 45sec. You can also play it with p+click.
Tetris
Please comment if you want an explanation of the tetris code. I dont think that it differs much from other tetris implementations (except that my rotation-algorithm really rotates the tetrominoes and doesnt just look up the rotation in a table/matrix)
Rendering
Pen: To fill single pixels (without “Anti-Aliasing others”) use pen size 1, but dont go to x/y coordinates with integer values. I found +0.6/+0.4 to work best (example x=14.6, y=23.4).
The renderer uses 2 “arrays”. One stores the sprites that should be drawn, the other one the sprites that already have been drawn. When a function calls “renderAll”, the renderer checks what the difference between those two arrays are and only draws the sprites that have changed since the last rendering. Then it updates the array with the already rendered sprites and clears the array with the sprites to render.
Composition Editor
Click outside of the “Gameboy screen” while pressing “c” to access the hidden composition editor. This lets you edit all the backgrounds that are used in the game.
- On the left you have the palette with all the sprites you can use. Click on the buttons above and below the palette to scroll. On the bottom right you see the spright that you have currently selected.
- The “NEW” button lets you create a new composition. Everything red will be transparent.
- “LOA” lets you load any composition. If you want to edit for example the copyright splash, click on “LOA” and then enter 1.
- “SAV” lets you save a composition. Unlike load, you cant just type the index number of a filename to overwrite it. To overwrite the copyright splash, you have to save it as “copyright”, not “1”.
- “TXT” lets you write stuff. You can also include non-text sprites. Just use backslash followed by the 5-letter name of the sprite. For example click on “TXT”, then somewhere on the canvas and enter “i \heart tetris”
- “CPY” lets you select a sprite you already used on the canvas.
- “FIL” works like the bucket tool in ms paint, but it doesnt check for continuous filling. click on a sprite, then on “FIL” and then on the part of the canvas (for example the red background) that you want to replace.
- “TRN” lets you make parts of the canvas transparent.
- Click on the “Sprite”-Tab on the top to get to the sprite editor.
Sprite Editor
First few words about sprites. Every sprite is 8x8 pixels and consists only of a background and a number or horizontal or vertical lines in one of 4 colors. The Sprite is stored in a code of digits 0-7:
The first one codes the backgound color (0=white, 1= light gray, 2= dark gray, 3= black). The following digits code the lines.
Every line needs 4 digits. The modulo-4 of the first digit tells you the color of a line. So if the first digit of a “line code” is 6, it means that the line is darkgray (6%4 = 2). If the line is horizontal, then the first digit is < 4, for a vertical line >= 4. 2nd and 3rd digit are the x and y coordinates of the starting point of the line (lower left point). The 4th digit tells you, how long the line is.
1 3007 4061This would be a light gray sprite, with a horizontal black line at the bottom and a 2pixel vertical white line in the top left corner.
“NEW” creates a new sprite with the currently selected color as background. “DEL” lets you delete a sprite (careful!). “PRV” and “NXT” let you scroll through the saved sprites. “XXX” removes the last line of a sprite. You can use it like “undo” in other editors.
Screenshot
While in game, you can press s and click to make a screenshot. You can then go to the composition manager to load the screenshot (and use the tools to make your score look more impressive

With r+click you can record a gameplay. This will overwrite the “idle-sequence” that appears when you idle on the title screen for 45sec. You can also play it with p+click.
Tetris
Please comment if you want an explanation of the tetris code. I dont think that it differs much from other tetris implementations (except that my rotation-algorithm really rotates the tetrominoes and doesnt just look up the rotation in a table/matrix)
Rendering
Pen: To fill single pixels (without “Anti-Aliasing others”) use pen size 1, but dont go to x/y coordinates with integer values. I found +0.6/+0.4 to work best (example x=14.6, y=23.4).
The renderer uses 2 “arrays”. One stores the sprites that should be drawn, the other one the sprites that already have been drawn. When a function calls “renderAll”, the renderer checks what the difference between those two arrays are and only draws the sprites that have changed since the last rendering. Then it updates the array with the already rendered sprites and clears the array with the sprites to render.
- MartinBraendli2
-
100+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"

Can't new scratchers edit posts or am i just blind?
- xOnic
-
3 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
Very cool and impressive. For all of that to be pen I am astounded.
Also, you should be able to edit your post as a new scratcher
Also, you should be able to edit your post as a new scratcher
Last edited by xOnic (June 24, 2015 16:55:17)
- mario91100
-
500+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"
You mentioned adding a “secret heart mode” in an earlier version of the “Notes and Credits”. Is that still in production, or will it ever be added?
Also, this project is absolutely mind-blowing, practically an emulator of the original GameBoy Tetris, in fact, it could probably pass as one. You deserve a cookie.
Also, this project is absolutely mind-blowing, practically an emulator of the original GameBoy Tetris, in fact, it could probably pass as one. You deserve a cookie.

- MartinBraendli
-
86 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
The scecret heart mode is a original Tetris feature. If you press select while on the copyright-splash, the game gets harder. Level x is then as fast as level x+10 on normal mode. The level is displayed with a heart. I cant link to external stuff (http://i.ytimg.com/vi/t85AcLwTpDE/hqdefault.jpg), but this shows the heart mode. Chances, that i will implement it, are about 80%, same for “select” key, which hides the upcoming tetromino.
Chances that i will add the rocket (shown when you get more than 100k points in A-mode or beat lvl 9 height 5 in B-mode) are about 2%, since it would need a compleatly new rendering engine, since the rocket moves 1pixel at a time. With my engine i can only draw 8x8 sprites, but not move ‘em.
Chances for the dancers (shown when beating lvl 9 on any height in B-mode) are about 10%. There are 6 different dance routines (for each height), and in each routine the dancers move asynchronously (for example the guitar player doesnt move at the same frame as the drummer). So implementing the dancers would be a lot of work.
Chances for global highscores are about 90%, i will do ’em as soon as i get access cloud variables.
I probably wont change the randomizer. The original one uses a lot of binary AND and OR operations, which is anoying to do in scratch. On the original version, not all tetrominos have the same frequency, and the only thing that is guaranteed, is that you wont get 3 times the same tetromino in a row. In my version, i use the algorythm that is used in modern tetris games (http://tetris.wikia.com/wiki/Tetris_Guideline).
At the moment I'm busy with another project, so i wont do much on Tetris. I'm creating a operating system in Scratch. Other “Operating Systems” here are done with Scratch-Blocks and are therefore not flexible at all. Mine will be stored compleatly in a variable/list. Only machinecode interpretation and input-output will be done by scratch-blocks. Currently i im working on a compiler (in Java), that can translate my own programming language into “machine code”.
Chances that i will add the rocket (shown when you get more than 100k points in A-mode or beat lvl 9 height 5 in B-mode) are about 2%, since it would need a compleatly new rendering engine, since the rocket moves 1pixel at a time. With my engine i can only draw 8x8 sprites, but not move ‘em.
Chances for the dancers (shown when beating lvl 9 on any height in B-mode) are about 10%. There are 6 different dance routines (for each height), and in each routine the dancers move asynchronously (for example the guitar player doesnt move at the same frame as the drummer). So implementing the dancers would be a lot of work.
Chances for global highscores are about 90%, i will do ’em as soon as i get access cloud variables.
I probably wont change the randomizer. The original one uses a lot of binary AND and OR operations, which is anoying to do in scratch. On the original version, not all tetrominos have the same frequency, and the only thing that is guaranteed, is that you wont get 3 times the same tetromino in a row. In my version, i use the algorythm that is used in modern tetris games (http://tetris.wikia.com/wiki/Tetris_Guideline).
At the moment I'm busy with another project, so i wont do much on Tetris. I'm creating a operating system in Scratch. Other “Operating Systems” here are done with Scratch-Blocks and are therefore not flexible at all. Mine will be stored compleatly in a variable/list. Only machinecode interpretation and input-output will be done by scratch-blocks. Currently i im working on a compiler (in Java), that can translate my own programming language into “machine code”.
- MartinBraendli
-
86 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
I added global high scores.
- Ezlambry
-
100+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"
This is the BEST PROJECT EVER (excluding your pen videos)
- kelvin312
-
1 post
Detailed explanation of my project "100% pen Gameboy Tetris"
why does rendering stop at 1000 frames?
- DexFire
-
100+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"
I think they can. If I had a tartis I'd go backto my accounts new scratcher level to test.
Can't new scratchers edit posts or am i just blind?
- Jacob-Hall
-
3 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
You'd think at first glance that this would be a 2-player game, but nothing happens when you select the 2 player label. Is it supposed to work? Or is it just for display?
- meyouandscratch
-
28 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
How do i change the colors in the pallete
- MartinBraendli2
-
100+ posts
Detailed explanation of my project "100% pen Gameboy Tetris"
Its hardcoded, so you'll have to change the project (remix it). The blocks you want to change are in the sprite “render” in a function called “set color ( )”. The first 4 colors are the ones actually used in the game.
- HarleyTheGorilla
-
2 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
What Is Your Favorite Music Genre
- hoihoihoikaas
-
1 post
Detailed explanation of my project "100% pen Gameboy Tetris"
You know you need a licence for it to publish it?
- blu_ice
-
1 post
Detailed explanation of my project "100% pen Gameboy Tetris"
Highs core didn't save. I have photo evidence. Game type-a level three start, got 45676 and should've saved as x.
- wizerdspell
-
1 post
Detailed explanation of my project "100% pen Gameboy Tetris"
Great game by the way, I hold the top two scores currently :3
- SuperFlatPankake2
-
4 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
Could you speed up the higher levels more? On the original Gameboy level nine was so chaotic.
- RoyalBracelet5645
-
2 posts
Detailed explanation of my project "100% pen Gameboy Tetris"
so I've been doing runs on this game, and I have gotten on the leaderboard several times. I even got the top score in the game ON LEVEL 9 (if your curious the score was 174367)
but when I closed the tab and came back, my name and score was gone. is this a glitch? can someone explain? this kinda means a lot to me.
but when I closed the tab and came back, my name and score was gone. is this a glitch? can someone explain? this kinda means a lot to me.
- Discussion Forums
- » Show and Tell
-
» Detailed explanation of my project "100% pen Gameboy Tetris"