Archived

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

cryo75

Newbie Tetris question!!

Recommended Posts

Hi everybody, I''m new to game programming and DirectX so I decided to go the safe way by starting from the simple stuff.... and that''s doing a tetris-type game in vc++ and GDI, then I convert from GDI to DD7 and then to DX9... Ok, so my question is really basic. How should I define my blocks? As arrays of 4x4 or what?? Thanks, Ivan

Share this post


Link to post
Share on other sites
I would draw them out first using some art program. It is going to be super hard with GDI. If you want to learn DirectX 9, do it in DirectX 9. There really is no point in doing it in DirectX 7. Your way will work, though.

Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis

Share this post


Link to post
Share on other sites
What about using the new geometry creation functions in DX8 and just creating a couple of cubes, stuff them into a vertex buffer and then just use simple arrays and look up tables to decide how many blocks to put together and in what order.

Beauty of this is u don''t need one item for every shape, u just need small amount of info and then create them on the fly in code, plus u can change colours, textures etc on the fly to all from a small amount of data.

This is exactly the same method i used in my game ''The Kep-Zar Mystery Puzzle''

Share this post


Link to post
Share on other sites
I seriously don''t think it would be hard to do in GDI. You could make some decent looking blocks in GDI if you use your imagination. For games like GDI, where blazing speed isn''t a concern, I think it''d be fine. It also lets you concentrate more on the game, and less time learning DirectX (until you have more experience). I think the OP is smart in writing it first in GDI, though I''d probably port right to DX9. All you''d really have to change would be initilization routine, and then the drawing routines.

That''s just my opinion

Share this post


Link to post
Share on other sites
I would go straight to doing it in DX9 but I wouldn''t, because I want to understand the game-loop properly and work on that too. It won''t be a fancy game... just does its job!!

Ivan

Share this post


Link to post
Share on other sites
The game loop is nothing special really, it''s usually based around the windows message pump loop, however one thing iv''e found time and time again that trips newbies up is the ''GetMessage()'' API function.

In all the MS code samples iv''e seen they Always use GetMessage, unless they are wrapping it up in the MFC classes (But thats a whole different ball game..)

What most people don''t realize is you need to use ''PeekMessage()'' ( I Think the function nams correct.. i don''t have my MSDN reference in front of me)

The top and bottom of it is, peek message examines the message cue and return straight away, get message waits until there''s a message ready, basicly your code goes somthing like this...

WinMain....

Setup Main Window...

Set Up Direct X...

Set Up Direct Sound...

Other setups etc...

QuitFlag=0

While QuitFlag <> 1 Do The Following
(
PeekMessage(Same Params as get message)....

If message ready
(
If Message.Msg=WM_QUIT
Set QuitFlag = to 1
Else
Handle the message, or just let your window proc do it
End If
)
Else
(
Do your main render loop
)
)End of while condition

Do your clean up and deinitialisation...

Don''t try to type the above in as is, iv''e only done it in psudo code to highlight the steps needed, look up getmessage and peekmessage in the MSDN reference or Platform SDK if you have it, if not you can find the online version at http://msdn.microsoft.com/


Share this post


Link to post
Share on other sites