Click here to Skip to main content
15,886,815 members
Articles / Mobile Apps / Android

Diggers: cross-platform 2D game

Rate me:
Please Sign up or sign in to vote.
4.80/5 (17 votes)
5 Nov 2012CPOL4 min read 33.3K   43  
2D cross-platfrom game using SDL and Open GLES 2.0
#include "Gameplay/SpriteBlockType.h"



SpriteBlockType* SpriteBlockType::m_SpriteBlockTypes[NUM_TOTAL_SPRITES];



SpriteBlockType::SpriteBlockType(unsigned int _textureID, unsigned char _ID, std::wstring _name, std::wstring _desc, unsigned char _xSize, unsigned char _ySize, unsigned char _hardness, unsigned char _maxWaterLevel, unsigned char _rowsCount, unsigned char _columnsCount, unsigned char _FPS, float _offset, bool _halfAnimation,
		float _xTexLD, float _yTexLD, 
		float _xTexLU, float _yTexLU, 
		float _xTexRU, float _yTexRU, 
		float _xTexRD, float _yTexRD)
		: Animation(_textureID, _ID, _xSize, _ySize, _rowsCount, _columnsCount, _FPS, _offset, _halfAnimation, true, _name, _desc,
				_xTexLD, _yTexLD, 
				_xTexLU, _yTexLU, 
				_xTexRU, _yTexRU, 
				_xTexRD, _yTexRD)
{
	m_ID = _ID;
	m_Name = _name;
	m_Desc = _desc;
	m_TextureID = _textureID;
	m_Hardness = _hardness;
	m_MaxWaterLevel = _maxWaterLevel;
	m_CurrentWaterLevel = (int) (_ID / (float)MINERALS_COUNT);
};


SpriteBlockType::~SpriteBlockType(void)
{
};


unsigned int SpriteBlockType::TextureIDFromTypeID(unsigned int _typeID)
{
	unsigned int bRes = -1;
	for (unsigned int i = 0; i < NUM_TOTAL_SPRITES; i++)
	{
		if (NULL == m_SpriteBlockTypes[i])
			continue;
		if (_typeID == m_SpriteBlockTypes[i]->m_ID)
			bRes = m_SpriteBlockTypes[i]->m_TextureID;
	}
	return bRes;
};

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
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions