Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Draco5869

Tetris Question

This topic is 5482 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, im working on my first game (no creative name yet, just tetris thus far : ). I have the code to create the bitmaps, have them be able to move left and right, fall, stop when they hit the ground, create a new one when hits the ground, and when it collides with another to stop on top of that one. (this has taken me awhile, but geez it sounds simple, hehe) My question is now what do i do? To create different blocks, do i make the odd shapes out of multiple blocks with similar velocities (like a couple odd shape classes?) or do i make them all square with transparences where there should be no block? Thanks a lot because im a tad stuck. ----------------------------------------------------------- Like a sponge!

Share this post


Link to post
Share on other sites
Advertisement
Looking on the forum, everyone seems to be loading their blocks from files and maps. But, these are all OpenGL/directdraw/etc and im just using the win api and don''t understand what they''re doing. Do i have to do it like that? Help please

-----------------------------------------------------------
Like a sponge!

Share this post


Link to post
Share on other sites
Here''s how I did it back when I wrote mine several years ago. I had a file that stored all of the shape data, for instance the L shape would look like this:

1 0 0 0 0 0 1 0
1 0 0 0 1 1 1 0
1 1 0 0 0 0 0 0 ...
0 0 0 0 0 0 0 0


Then I read all of this shape data into a multidimensional array. My bitmaps were just four, different colored blocks. I then dynamically drew the shapes based on the block data using a small loop (if (value == 1) drawBlock() ), etc.

Share this post


Link to post
Share on other sites
Pretty positive i could do that though. Just don''t know how to load these blocks.

-----------------------------------------------------------
Like a sponge!

Share this post


Link to post
Share on other sites
Check out ifstreams: This should send you in the right direction

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
I understand how you''re reading the files to get the pattern, but i don''t understand how i will do collision once i get those bitmaps. Like won''t they be treated as totally seperate bitmaps?

-----------------------------------------------------------
Like a sponge!

Share this post


Link to post
Share on other sites
quote:
Original post by Draco5869
To create different blocks, do i make the odd shapes out of multiple blocks with similar velocities (like a couple odd shape classes?)



I think your on the right track with this idea. The pieces in your tetris game could be treated as blocks that are just glued together.

One way you could do this is have a class or a structure that points to or contains each block that makes up the piece.
When the block moves left or right you would have to do some collision detection to make sure the piece won’t go through the wall and then move every block in the piece in that direction.

When the piece collides with the ground (or another piece on the ground) you could stop moving the piece and start dropping a new one from the top. You could also possibly treat the pieces that hit the ground as a big collection of blocks.

Hope that helps.


Share this post


Link to post
Share on other sites
Exactly what i was looking for, gracias. Sounds like it''s within my ability but it still Sounds hard, fun fun

-----------------------------------------------------------
Like a sponge!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!