This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-13 07:57:08

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Need tetris help

I have made a tetris project here but I need some help fixing the bug where if you make a line, it will not clear. It should make it white. Note I haven't got round to making the pieces drop when you make a line yet, I just want it to turn white.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#2 2012-05-13 14:25:13

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: Need tetris help

Detecting a full line and making it turn white is easy but pointless. You have stamped all of the pieces into place so there is no way to move them down. You will ether need a sprite for every grid location or the ability to restamp the whole grid from a list in turbo mode.

Offline

 

#3 2012-05-13 15:27:16

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Need tetris help

No what I plan to do is have a sprite which reads the colours on the line , replaces them with white and stamping a copy one space below. Right now I need help simply turning the full line white.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4 2012-05-13 15:43:23

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Need tetris help

There's probably an easier way, but:

Make a list.
Every time a block lands, based on the x/y position and the type of block, replace the corresponding "empty" of the list with "not empty".  To see if it is full, just use the "<[list] contain (empty)> block.  Then just have a white rectangular sprite stamp itself at the bottom row and replace all items of the list with "empty".

Last edited by MoreGamesNow (2012-05-13 15:43:42)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2012-05-13 17:20:15

SOScratch
Scratcher
Registered: 2010-02-01
Posts: 100+

Re: Need tetris help

Yeah.
Making the whole thing white is easy.

But you will probably need a block for every grid piece or something because otherwise the blocks will not come down and it will not work properly.


-SOScratch
Scratch On!

Offline

 

#6 2012-05-14 08:55:13

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: Need tetris help

(1) Make a sprite where the first costume is one full row of white squares.
(2) Make a second costume replacing each square with a centered dot.
(3) Make a script that moves the sprite down one grid row at a time.
(4) When the second costume is not touching white stamp the first costume.

Offline

 

#7 2012-05-14 10:20:19

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Need tetris help

Thanks! I'll try that.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#8 2012-05-14 14:55:26

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Need tetris help

Thank you! it works now! Now I need help dropping the peices down when you make a line.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#9 2012-05-15 08:37:56

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: Need tetris help

joefarebrother wrote:

No what I plan to do is have a sprite which reads the colours on the line , replaces them with white and stamping a copy one space below.

This will result in a domino affect as the falling will propagate one block at a time until it reaches the highest block from each column. Even if you use a separate sprite to handled each column and run in turbo mode this will be painfully slow. The idea of animating the falling motion becomes ludicrous.

As I said before, one sprite for each grid cell is the best. There are some tricky scripting techniques that let you make one sprite and then just copy it as many times as as you need. The sprites will figure out where to go and what to do on there own. It is far to complex to explain here so I would have to code it for you. But I'm a busy man with a job and a wife and daughter.

Offline

 

#10 2012-05-15 09:28:37

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: Need tetris help

Then again it might work in turbo mode. It will be good scripting practice even if it doesn't. Like I said, use one sprite for each column and work your way up from the botton. Torbo mode will often cause problems so be ready for some random glitches once you post.

Offline

 

#11 2012-05-15 19:01:01

axorion
Scratcher
Registered: 2010-01-05
Posts: 28

Re: Need tetris help

I did some testing and I was wrong. Your idea will work just fine without resorting to turbo mode. Here is the test I did. Let me know when you have a copy so I can remove the project. Just customize it a bit then make a copy for each column. Change the x: coordinate for each copy. Make sure you don't use any color found in your background because the flash player will detect it even after it has been stamped over.

Offline

 

Board footer