Jump to content
  • Advertisement

Archived

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

ZadrraS

[SDL] Multiple objects of the same type on the screen...

This topic is 5227 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

it took me a while to realize that im stuck, i started my tetris clone, but i can''t make that when the brick lands, it would restart at the top while a new one is created at the place where the old one lands (if thats even the right way to do it...). How do i do that that (my english sucks too ) a brick that landed would be redrawn every frame, the same if there would be 5 bricks at the bottom, all of them should be redrawn every frame. So, how do i do that? Or, maybe there is a "more right" way to do it than mines...

Share this post


Link to post
Share on other sites
Advertisement
Distinguish the play field and the falling bricks.
Once a brick is landed add it to the play field (consider the play field ONE big object if you want) and destroy it.
Create a new brick on top.

Share this post


Link to post
Share on other sites
you could also consider the playing field as a 2D array of tiles. When a falling "tetrad" object falls and contacts the bottom, it becomes 4 blocks, each block inhabiting a tile on the array. the array or "field" object would have calls like:

bool IsBlocked( int x, int y ); // check to see if inhabited.

Share this post


Link to post
Share on other sites
I only have 1 block falling, i didn''t make "tetrads" yet. Should i make an array that would store whats in that place? My tetris is 400x and 800z. All the bricks are 40x40 size, making my game 20x10 tiles.
Sory for sounding/being stupid, but im only a beginner and my english skills suck too..

Share this post


Link to post
Share on other sites
you know, i actually wanted to make a tetris clone, but i couldnt figure out (in my head) how the hell to rotate the blocks. so i decided to make pacman instead, thinking it would be easier. well i could personally say to stick to testris. this wasnt easier . i had a lot of fun though and i learned a lot, i even made a map editor for it. i still couldnt tell you how the hell to rotate a tetris block tho

[edited by - graveyard filla on March 23, 2004 1:04:23 PM]

Share this post


Link to post
Share on other sites
well, with tetris, there must be a thousand and one ways to do it, i''m sure. I''m just suggesting the route i might take.

i would create the "Well" class. It''s the 10x20 array of "Block" classes. Blocks can be either filled or not filled, and a variety of colors:


class Block {
SDL_Color color;
bool filled
}

class Well {
Block blocks[10][20];
bool IsFilled( int x, int y ) { return blocks[x][y].filled; }
bool SetFill( int x, int y, bool f ) { blocks[x][y].filled = f; }
}


A tetrad then, would just be a collection of 4 X/Y pixel coords on the well. When the pixel coords reach an "even number" (that is, divisible by 20 if you have 20x20 tiles), you check for collisions. If no collisions, keep going. If collision: take each of the 4 "blocks" and make them "become one with the well" by calling SetFill() for each of the 4 positions in the tetrad; Then check for cleared lines, etc.

... or something like that.

Share this post


Link to post
Share on other sites
The tests in school are almost gone and ill be able to work on my tetris almost all day.. Thanks for everyones help!

Share this post


Link to post
Share on other sites
Ok.... im still having tons of problems... How do i check and change each tiles in the screen status? It would take 200 if and elses to do that( or even more):

if (y==760) {
if (x==0) {
map[20][1]=1;
else if (x==1) {
map[20][2]=1;
}
}

and etc...
So, whats the right way to do it?

Share this post


Link to post
Share on other sites
i dont understand your questoin... could you describe what your trying to accomplish better? more english and less code also, what about for loops? something like

for(int x = 0; x < MAX_WIDTH; x++)
{
for(int y = 0; y < MAX_HEIGHT; y++)
{
if(map[x][y] == whatever)
do stuff;
}
}

Share this post


Link to post
Share on other sites
im just damn confused .. my screen is made of 10x20 blocks, every block is 40x40 pixels... i have an array called map[10][20] and i need to check every block, is it occupied.. And when/if i do that, i have no idea how to continue

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!