Click here to Skip to main content
15,891,204 members
Articles / Multimedia / DirectX

Falling Blocks

Rate me:
Please Sign up or sign in to vote.
4.95/5 (11 votes)
17 Apr 2008CPOL 271K   9.2K   72  
A game written using Visual C++ and DirectX.
// BlockList.h: interface for the CBlockList class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BLOCKLIST_H__5C19BD1E_B253_42C6_95D0_E2D86D84FA80__INCLUDED_)
#define AFX_BLOCKLIST_H__5C19BD1E_B253_42C6_95D0_E2D86D84FA80__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

////////////////////////////
// Block definitation
////////////////////////////
struct SBlock {
	short nX,nY,nColor;
};

///////////////////////////////////////////////////////////////////////
// CBlockList will be the parent class for the CShape class and the 
// CFlooredBlocks class. It contains the methods to maintain the lists.
///////////////////////////////////////////////////////////////////////

class CBlockList  
{
public:
	struct SNODE {
		SBlock Block;
		SNODE* pNext;
		inline SNODE();
	} *m_pListHead;

public:
	void Destroy(); // Empties the linked list.
	bool IsOccupied(short nX, short nY); // Returns true if the given location is already occupied
	void Display(short nX=0, short nY=0); // Displays the block on the screen offsetting it by nX and nY.
	bool Add(const SBlock Block);  // Adds the block to the end of the list.
	void dbgDisplay(); // Dumps the list to the debugger.
	bool Insert(const SBlock Block); //Inserts the block based on the value in linked list.
	CBlockList();
	virtual ~CBlockList();

};

#endif // !defined(AFX_BLOCKLIST_H__5C19BD1E_B253_42C6_95D0_E2D86D84FA80__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions