Tetris game help

Started by
17 comments, last by DarkAvenger 23 years, 6 months ago
I decided to start writing a Tetris style game using VC++ and DirectDraw, so I learnt some DirectX programming, and I can now load a bitmap(hooray ). But, now comes the tough part; actually writing the game. I've got just a couple of questions, which are hopelessly newbie. Okay, firstly, on loading the brick bitmap, its obviously gotta move.. now I'm getting a little worried. One, I've got to pause the compiler (I could give it some huge loop to chew on, but that doesn't seem classy) and I've also got to make sure the block moves down.. now, what is the best approach to solve this? Is it a) load the bitmap again, after deleting the other one, or is it b) moving the pixels through a loop? And, let's not forget, I need to pause the compiler. To recap, I need to know: 1. How to pause the game 2. How to move the bricks And, though I haven't already gotten there, I may as well ask the following 3. Is it best to load a brick type as a collection of images or as one single image?(I presume it's the latter, but just in case..) 4. For rotation, is it better to load a separate "rotated" image, or do I call a rotation function of my own? As always, thanks for any help. Edited by - DarkAvenger on 10/8/00 12:58:32 AM
Advertisement
i don''t think i''m understanding your questions correctly.. you need to pause the game? why? what are you rotating?
i''d just load one instance of each bitmap you need, and number each, so you know which one to show for a specific block.. i''d also keep track of the playing area as an array, with some code for it being empty, or if it''s not empty, some kind of reference to the bitmap that needs to be shown for it (i used a integer)..
for each screen update, just clear the screen, display the mass in the playing area via a loop, and display the current block. for moving the block, i just used coordinates of the playing area (i.e. 10x20 or whatever), and change the coordinates based on player movement and falling, and have your block drawing function map those coordinates to the screen...

it seems you''re going at it a totally different way than i did, though, so maybe i''m not being much help...

there''s nothing wrong with loops...

------------------------
IUnknown *pUnkOuter

"Just do your best and
don't worry"
--Morrissey

"Try the best you can
try the best you can
the best you can is good enough"
--Radiohead

"Are you looking for new ways
to do better than your worst"
--Nick Drake
------------------------IUnknown *pUnkOuter"Try the best you cantry the best you canthe best you can is good enough" --Radiohead
Sorry, that was pretty ambiguous.. anyway, what I meant by saying I had to pause the game was that I need to make the block move after a specified time frame eg. 1 sec. Maybe pause isn''t the right word, but I think you get the point.

I also need to rotate the blocks, if the user presses Space or whatever; but is that too complex?

I have nothing against loops, it''s just that using them as a "timer" doesn''t seem to be the best solution.. but hey, I''m just a newbie who barely knows any DirectX, so why listen to me ? Thanks for the reply anyway!
Sorry, that was pretty ambiguous.. anyway, what I meant by saying I had to pause the game was that I need to make the block move after a specified time frame eg. 1 sec. Maybe pause isn''t the right word, but I think you get the point.

I also need to rotate the blocks, if the user presses Space or whatever; but is that too complex?

I have nothing against loops, it''s just that using them as a "timer" doesn''t seem to be the best solution.. but hey, I''m just a newbie who barely knows any DirectX, so why listen to me ? Thanks for the reply anyway!
Oops, sorry for the double post!
keep teh same bitmap, and put in in a loop untill it hits bottum... what do u eman pasue?? do u mean teh user can pause the game or do u want a pause in the motion of hte brick coming down??
if u want te second one just put

sleep(length of pause);
keep teh same bitmap, and put in in a loop untill it hits bottum... what do u eman pasue?? do u mean teh user can pause the game or do u want a pause in the motion of hte brick coming down??
if u want te second one just put

sleep(length of pause);
to rotate the blocks, u should look into direct input and direct draw
I need to have a gap between the block being rendered, and it being moved down, not a game pause itself. So, I guess I need to use the sleep() function; thanks! And anon., I didn't quit follow.. do you mean there are functions in DDraw/DInput for rotation? Thanks for all the help!

Edited by - DarkAvenger on October 8, 2000 2:48:44 AM
If it''s not a bother, could someone please give an example of how to use the sleep() function?

This topic is closed to new replies.

Advertisement