Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
96 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 Stepping to the
 plate...

 Mr. Structure
 The New Shape
 Maker

 Update takes a few
 practice swings

 Let's Get Moving!
 Time to Clear the
 Bases?

 The Final Batters
 The Loop and His
 Team

 Until Next Time...

 Printable version

 


  The Series

 Part 1
 Part 2
 Part 3
 Part 4
 Part 5
 Part 6

 

The Final Batters

Our two final hitters are the publicity hounds Draw_Shape() and Draw_Grid(). Below is their code.

Popup : Source Listing 7

If you have been able to keep up with this article series so far then this code should be a breeze to understand. Both of them do the same basic thing. The only difference between the two is that one operates on the current shape, and the other draws everything currently in the grid.

The basic idea is to loop through every bit in the frame for the shape, or every byte for the grid ( You should be very used to this looping concept by now ). Then, either we use the current shape color, or the number stored in the grid, to access the proper block texture to use. The rest involves a call to draw the surface on the back buffer.

The one thing that you need to make sure that you don't forget however is that you need to convert from grid to screen coordinates. If you do not then everything will be drawn at the left-hand side with A LOT of overlap.

Also, keep in mind that since we use the DX blitting function the back buffer must NOT be locked prior to the call. Make sure that if you did lock it that you unlocked it before you make the call, otherwise you will crash.

That is all that our functions do, and more importantly, all that we need to have on our team for the time being. Now, it is the manager's job to get the game running for us. So, let's go investigate "the loop."



Next : The Loop and His Team