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

Started by
18 comments, last by ZadrraS 20 years ago
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...
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.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

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.
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..
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]
FTA, my 2D futuristic action MMORPG
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.

The tests in school are almost gone and ill be able to work on my tetris almost all day.. Thanks for everyones help!
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?
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;
}
}
FTA, my 2D futuristic action MMORPG
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

This topic is closed to new replies.

Advertisement