Click here to Skip to main content
15,909,589 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Array Size Pin
TeVc++29-Sep-08 19:45
TeVc++29-Sep-08 19:45 
GeneralYou are welcome. Pin
CPallini29-Sep-08 21:49
mveCPallini29-Sep-08 21:49 
Questiondynamic allocation of arrays [modified] Pin
Sauce!28-Sep-08 19:14
Sauce!28-Sep-08 19:14 
AnswerRe: dynamic allocation of arrays Pin
Saurabh.Garg28-Sep-08 19:23
Saurabh.Garg28-Sep-08 19:23 
GeneralRe: dynamic allocation of arrays Pin
Sauce!28-Sep-08 19:28
Sauce!28-Sep-08 19:28 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!29-Sep-08 21:01
Sauce!29-Sep-08 21:01 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:20
Iain Clarke, Warrior Programmer30-Sep-08 0:20 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 0:55
Sauce!30-Sep-08 0:55 
In Block.h

class Block
{
public:
	Block(void);
	Block(int itsShape, int itsColour);
	~Block(void);

	bool isGrounded(void);
	void MoveLeft();
	void MoveRight();
	void MoveDown();
	void Rotate();

	void Render();

private:
	int Shape;
	int Colour;
	bool Grounded;

	Tile* p_TileArray;
};


in Block.cpp
#include "Block.h"

Block::Block(void)
{
	Grounded = false;
	Shape = (rand() % 7);
	Colour = (rand() % 6);

	p_TileArray = NULL;
	p_TileArray = new Tile[4];

	p_TileArray[0].SetPos(498.0, 82.0);
	p_TileArray[1].SetPos(530.0, 82.0);
	p_TileArray[2].SetPos(498.0, 114.0);
	p_TileArray[3].SetPos(530.0, 114.0);
}

Block::~Block(void)
{
	if (p_TileArray)
	{
		delete [] p_TileArray; //Debug assertion failure / 'vector deleting destructor'
		p_TileArray = NULL;
	}
}

bool Block::isGrounded(void)
{
	return Grounded;
}
void Block::MoveLeft()
{
	if(Grounded == false)
	{
		for(int i = 0; i < (sizeof(p_TileArray) / sizeof(p_TileArray[0])); i++)
		{
			p_TileArray[i].MoveLeft();
		}
	}
}

void Block::MoveRight()
{
	if(Grounded == false)
	{
		for(int i = 0; i < (sizeof(p_TileArray) / sizeof(p_TileArray[0])); i++)
		{
			p_TileArray[i].MoveRight();
		}
	}
}

void Block::MoveDown()
{
	if(Grounded == false)
	{
		for(int i = 0; i < (sizeof(p_TileArray) / sizeof(p_TileArray[0])); i++)
		{
			p_TileArray[i].MoveDown();
		}
	}
}

void Block::Rotate()
{
}

void Block::Render()
{
	for(int i = 0; i < (sizeof(p_TileArray) / sizeof(p_TileArray[0])); i++)
	{
		p_TileArray[i].Render();
	}	
}

GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:25
Iain Clarke, Warrior Programmer30-Sep-08 1:25 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 1:34
Sauce!30-Sep-08 1:34 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:48
Iain Clarke, Warrior Programmer30-Sep-08 1:48 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 2:16
Sauce!30-Sep-08 2:16 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 3:21
Iain Clarke, Warrior Programmer30-Sep-08 3:21 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!30-Sep-08 5:01
Sauce!30-Sep-08 5:01 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 5:31
Iain Clarke, Warrior Programmer30-Sep-08 5:31 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 5:43
Sauce!30-Sep-08 5:43 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 6:02
Iain Clarke, Warrior Programmer30-Sep-08 6:02 
GeneralRe: dynamic allocation of arrays Pin
Sauce!2-Oct-08 5:05
Sauce!2-Oct-08 5:05 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 2:42
Sauce!4-Oct-08 2:42 
GeneralRe: dynamic allocation of arrays Pin
Sauce!4-Oct-08 5:19
Sauce!4-Oct-08 5:19 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 5:34
Sauce!4-Oct-08 5:34 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 12:53
Sauce!4-Oct-08 12:53 
GeneralRe: dynamic allocation of arrays Pin
Sauce!17-Oct-08 20:58
Sauce!17-Oct-08 20:58 
Questionno WM_MOUSEHOVER in an edit Pin
followait28-Sep-08 18:58
followait28-Sep-08 18:58 
AnswerRe: no WM_MOUSEHOVER in an edit Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:25
Iain Clarke, Warrior Programmer30-Sep-08 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.