void TransitionObject::Initialize()
{
	color = WHITE;
	state = NO_TRANSITION;

	for( int i = 0; i < numOfOverlays; i++ )
	{
		
		transitionSprite[i].setUWidth( 480 );
		transitionSprite[i].setUHeight( 320 );
		transitionSprite[i].setSize( 480, 320 );

		switch( i )
		{
		case 0:
			transitionImage[i] = Iw2DCreateImage( "white.png" );
			break;
		case 1:
			transitionImage[i] = Iw2DCreateImage( "black.png" );
			break;
		case 2:
			break;
		}
		
		transitionSprite[i].setImage( transitionImage[i] );
		transitionSprite[i].setDelayTime( 1 );
		transitionSprite[i].setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );
	}

}
示例#2
0
void Game::Initialize()
{
	IMAGE_CACHE.push_back(Iw2DCreateImage("question.png"));
	IMAGE_CACHE.push_back(Iw2DCreateImage("one.png"));
	IMAGE_CACHE.push_back(Iw2DCreateImage("moon.png"));
	IMAGE_CACHE.push_back(Iw2DCreateImage("begin.png"));
}
示例#3
0
Resources::Resources()
{
	MenuBG = Iw2DCreateImage("textures/menu_bkg.jpg");
	PlayButton		=		Iw2DCreateImage("textures/play.png");
	// Load fonts
	settingsButtonImage = Iw2DCreateImage("textures/settings-button.png");
	Font			=		Iw2DCreateFont("fonts/arial8.gxfont");
}
示例#4
0
bool CIwGameImage::Init(void* memory_file, int memory_file_size)
{
	CIwGameFile file;
	if (file.Open(memory_file, memory_file_size))
	{
		// Load the image
		CIwImage image;
		image.ReadFile((s3eFile*)file.getFileHandle());

		// if required format is different then convert it
		if (FormatSet && image.GetFormat() != Format)
		{
			CIwImage* new_image = ConvertToFormat(image, Format);
			Image2D = Iw2DCreateImage(*new_image);
			delete new_image;
		}
		else
			Image2D = Iw2DCreateImage(image);

		if (FilterSet)
			setFilter(Filter);

		if (Image2D == NULL || image.GetFormat() == CIwImage::FORMAT_UNDEFINED)
		{
#if defined(_DEBUG)
			CIwGameError::LogError("Error: CIwGameImage::Init() - Could not create image!");
#endif	// _DEBUG
			return false;
		}
		else
		{
			Width = Image2D->GetWidth();
			Height = Image2D->GetHeight();
#if defined(_DEBUG)
			CIwGameError::LogError("Info: CIwGameImage::Init() - Size = ", CIwGameString(memory_file_size).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Width = ", CIwGameString(Width).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Height = ", CIwGameString(Height).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Bit depth = ", CIwGameString(image.GetBitDepth()).c_str());
			CIwGameError::LogError("Info: CIwGameImage::Init() - Format = ", CIwGameString(image.GetFormat()).c_str());
#endif	// _DEBUG
		}
	}

	// Sanity check
	if (Width <= 0 || Height <= 0 || Width > 16384 || Height > 16384)
		return false;

	State = State_Loaded;

	return true;
}
示例#5
0
int main()
{
	Iw2DInit();
	CIw2DImage* g_AirplayLogo = Iw2DCreateImage("largeAirplayLogo.bmp");
	while (1)
	{
		int64 start = s3eTimerGetMs();
		if	(s3eDeviceCheckQuitRequest())
			break;
		// Clear the screen
		Iw2DSurfaceClear(0xffffffff);
		CIwSVec2 topLeft = CIwSVec2((int16)(Iw2DGetSurfaceWidth() / 2 - g_AirplayLogo->GetWidth() / 2), 
			(int16)(Iw2DGetSurfaceHeight() / 2 - g_AirplayLogo->GetHeight() / 2));
		CIwSVec2 size = CIwSVec2((int16)g_AirplayLogo->GetWidth(), (int16)g_AirplayLogo->GetHeight());
		Iw2DDrawImage(g_AirplayLogo, topLeft, size);
		Iw2DSurfaceShow();

		// Attempt frame rate
		while ((s3eTimerGetMs() - start) < MS_PER_FRAME)
		{
			int32 yield = (int32) (MS_PER_FRAME - (s3eTimerGetMs() - start));
			if (yield<0)
				break;
			s3eDeviceYield(yield);
		}
	}
	delete g_AirplayLogo;
	Iw2DTerminate();
	return 0;
}
示例#6
0
文件: Ground.cpp 项目: brizee/honours
Ground::Ground()
{
	Background = Iw2DCreateImage("_ground/grass.jpg");	// Load background
	mWidth = Iw2DGetSurfaceWidth();		// Fetch screen dimensions
	mHeight = Iw2DGetSurfaceHeight();
	Nullify();

}
示例#7
0
void N2F::Iw3D::Image::setFile(const char *file)
{
	this->file = file;
	this->img = Iw2DCreateImage(file);
	this->img->GetMaterial()->SetFiltering(false);
	this->size = CIwFVec2(this->img->GetWidth(), this->img->GetHeight());

	return;
}
示例#8
0
void GameInit()
{
	Iw2DInit();
	grass = Iw2DCreateImage("0.png");
	three = Iw2DCreateImage("1.png");
	man = Iw2DCreateImage("2.png");
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			Map[i][j]=0;
		}
	}
	Map[0][0]=2;
	Map[3][0]=1;
	Map[3][2]=1;
	Map[5][1]=1;
}
示例#9
0
void MapViewInit()
{
	Player* player = getGameState()->getPlayer();
	lastLoses = player->getLoseCount();
	lastWins = player->getWinCount();

	playerTexture = Iw2DCreateImage("textures/map_player.png");
	healthTexture = Iw2DCreateImage("textures/map_health.png");
	healthLostTexture = Iw2DCreateImage("textures/map_health_lost.png");
	xpBarTexture  = Iw2DCreateImage("textures/map_xp_bar.png");
	
	mapTexture = new CIwTexture;
	mapTexture->LoadFromFile ("textures/map_template.png");
	mapTexture->Upload();
	
	mapInit(mapTexture->GetWidth(), mapTexture->GetHeight());

	ghostInit();
}
示例#10
0
CameraDefend::CameraDefend() {
	IwRandSeed((int32)s3eTimerGetMs());

	for (int i = 0; i < DEFEND_TOUCHES_MAX; i++) {
		touch[i] = new DefendTouch;
		touch[i]->drawing = false;
	}

	dotTextureGreen = Iw2DCreateImage("textures/defending_dot/defending_dot.png");
	dotTextureRed   = Iw2DCreateImage("textures/defending_dot/defending_dot_red.png");
	dotTexture = dotTextureGreen;
	dotAngle = 0;

	animTexturePress = new CIwTexture;
	animTexturePress->LoadFromFile("textures/defending_dot/defending_anim.png");
	animTexturePress->Upload();

	animMat = new CIwMaterial;
	animMat->SetTexture(animTexturePress);

	animMat->CreateAnim();
	animMat->SetAnimCelW((double)animTexturePress->GetWidth()/cells);
	animMat->SetAnimCelH((double)animTexturePress->GetHeight()/rows);
    animMat->SetAnimCelPeriod(2);

	animTextureSuccess = new CIwTexture;
	animTextureSuccess->LoadFromFile("textures/defending_dot/defending_success.png");
	animTextureSuccess->Upload();

	animMatSuccess = new CIwMaterial;
	animMatSuccess->SetTexture(animTextureSuccess);

	animMatSuccess->CreateAnim();
	animMatSuccess->SetAnimCelW((double)animTexturePress->GetWidth()/cellsSuccess);
	animMatSuccess->SetAnimCelH((double)animTexturePress->GetHeight()/rowsSuccess);
    animMatSuccess->SetAnimCelPeriod(2);
	
	reinit();
	active = false;
	defended = false;
}
SimpleResourceManager::SimpleResourceManager()
{
	images[RESOURCE_CHARACTER] = Iw2DCreateImage("character.png");
	images[RESOURCE_DIRT] = Iw2DCreateImage("dirt.png");
	images[RESOURCE_GRASS] = Iw2DCreateImage("grass.png");
	images[RESOURCE_STONE] = Iw2DCreateImage("stone.png");
	images[RESOURCE_STONE_TALL] = Iw2DCreateImage("stone_tall.png");
	images[RESOURCE_STAR] = Iw2DCreateImage("star.png");
	images[RESOURCE_WATER] = Iw2DCreateImage("water.png");
}
示例#12
0
/**
* Constructor
* @param pPos the position of the door
* @param pFrames number of frames in the animation
* @param pImageName the image to use for the animation
* @param pScale the render scale
*/
Effect::Effect(CIwSVec2 pPos, int pFrames, const char* pImageName, float pScale):
	mPos(pPos),
	mFrameCount(pFrames),
	mCurFrame(0),
	mFrameDelay(0),
	mMaxFrameDelay(3),
	mFinished(false),
	mScale(pScale) {

		CIwImage img;
		img.LoadFromFile(pImageName);
		mImage = Iw2DCreateImage(img);
}
示例#13
0
文件: main.cpp 项目: tmowyang/words
int main()
{
	// Initialise the 2D graphics system
	Iw2DInit();

	// Set up input systems
	g_pInput = new Input();

	// Create an image from a PNG file
	CIw2DImage* image = Iw2DCreateImage("textures/letter_A.png");
	CIwFVec2    image_position = CIwFVec2::g_Zero;

	// Loop forever, until the user or the OS performs some action to quit the app
	while (!s3eDeviceCheckQuitRequest())
	{
		// Update input system
		g_pInput->Update();

		// Clear the drawing surface
		Iw2DSurfaceClear(0xff000000);

		// Draw an image
		CIwFVec2 sz = CIwFVec2(50, 50);
		Iw2DDrawImage(image, image_position, sz);

		// Check for user tapping screen
		if (!g_pInput->m_Touched && g_pInput->m_PrevTouched)
		{
			// Move image to touched position
			image_position.x = (float)g_pInput->m_X - 25;
			image_position.y = (float)g_pInput->m_Y - 25;

			// Reset input
			g_pInput->Reset();
		}

		// Show the drawing surface
		Iw2DSurfaceShow();

		// Yield to the OS
		s3eDeviceYield(0);
	}

	// Clean-up
	delete image;
	delete g_pInput;
	Iw2DTerminate();

	return 0;
}
示例#14
0
CIwGameImage* CIwGameImage::getCopy()
{
	if (Image2D == NULL)
		return NULL;

	CIwGameImage* image = new CIwGameImage();
	image->NameHash = NameHash;
	image->State = State;
	image->ResourceGroup = ResourceGroup;
	image->Width = Width;
	image->Height = Height;
	image->Image2D = Iw2DCreateImage(Image2D->GetMaterial()->GetTexture()->GetImage());

	return image;
}
示例#15
0
//-----------------------------------------------------------------------------
void ExampleInit()
{
    Iw2DInit();
	Iw2DSetColour(0xffffffff);
	g_Image = Iw2DCreateImage("Image.png");

	//
	g_accumulator = 0.0f;
	g_prevTime = s3eTimerGetMs();

	// create a box2d world
	if( !(g_world = new b2World(g_gravity)) )		{ /*error*/	}

	// add a boundary at the edge of the screen
	b2BodyDef bodyDef;
	bodyDef.type = b2_staticBody;
	bodyDef.position.Set(0, 0);
	b2Body* boundaryBody = g_world->CreateBody(&bodyDef);

	const float hw = (float)Iw2DGetSurfaceWidth() * 0.5f / 8;
	const float hh = (float)Iw2DGetSurfaceHeight() * 0.5f / 8;
	b2Vec2 list[] = { b2Vec2(-hw, -hh), b2Vec2(hw, -hh), b2Vec2(hw, hh), b2Vec2(-hw, hh) };

	const int numVerts = sizeof(list) / sizeof(b2Vec2);
	b2ChainShape loopShape;
	loopShape.CreateLoop(list, numVerts);
	boundaryBody->CreateFixture(&loopShape, 0.0f);

	// add a dynamic body
//	b2BodyDef bodyDef;
	bodyDef.type = b2_dynamicBody;
	bodyDef.position.Set(0, 0);
	g_body = g_world->CreateBody(&bodyDef);
	g_body->SetLinearDamping(0.1f);

	b2PolygonShape polygonShape;
	polygonShape.SetAsBox(0.5f * (8/2), 0.5f * (8/2));

	b2FixtureDef fd;
	fd.shape = &polygonShape;
	fd.friction = 0.5f;
	fd.density = 10.0f;
	fd.restitution = 0.5f;

	g_body->CreateFixture(&fd);

	g_body->SetAngularVelocity(2.15f);		// set the dynamic object initially spinning, so that it bounces more interestingly on the 'ground'
}
示例#16
0
CIw2DImage* Transitions2D::CaptureScreenBuffer()
{
	int w = IwGxGetDeviceWidth();
	int h = IwGxGetDeviceHeight();
	int length = w * h * 4;

	uint8* buffer = new uint8[length];

	glReadPixels(0, 0, w, h, 0x1908, 0x1401, buffer);

	uint8* buffer2 = new uint8[length];

	int lineSize = w * 4;
	uint8* b1 = buffer;
	uint8* b2 = buffer2 + h * lineSize;;
	for(int y = h; y > 0; y--)
	{
		b2 -= lineSize;
		for(int x = w; x > 0; x--)
		{
			*b2++ = *b1++;
			*b2++ = *b1++;
			*b2++ = *b1++;
			*b2++ = *b1++;
		}
		b2 -= lineSize;
	}

	CIwTexture* texture = new CIwTexture;
	CIwImage& img = texture->GetImage();

	img.SetFormat(CIwImage::ABGR_8888);
	img.SetWidth(w);
	img.SetHeight(h);
	img.SetBuffers(buffer2, length);
	img.SaveBmp("screenshot.bmp");

	texture->SetMipMapping(false);
	//texture->Upload();

	//delete buffer;
	delete buffer2;
	CIw2DImage* tmp = Iw2DCreateImage(img);
	return tmp;
}
示例#17
0
/**
* Constructor
* @param pImage the name of the image to use
* @param pPos the position of the platform
* @param pWidth the width of the platform
* @param pExt1 the first of two points the platform moves between
* @param pExt2 the second of two points the platform moves between
* @param pWorld the physics world to add the pickup to
*/
Platform::Platform(const char* pImage, CIwSVec2 pPos, float pWidth, int pExt1, int pExt2, b2World* pWorld):
	mImage(Iw2DCreateImage(pImage)),
	xExtent1((((-(768/64)*4)+(0.5*4))+(pExt1*4)) + 0.5), 
	xExtent2((((-(768/64)*4)+(0.5*4))+(pExt2*4)) + 0.5),
	mSpeed(10) {

		mDirection = 1;
		mWidth = pWidth*64;

		float X = -48 + (pWidth*4) + (pPos.x*4) + 0.5;
		float Y = 64 - (0.5*4) - (pPos.y*4) - 0.5;
		X = -(768/16) + (pWidth*4) + (pPos.x*4) + 0.5;
		Y = (1024/16) - (0.9*4) + (-pPos.y*4) - 0.5;
		yReset = Y;

		b2BodyDef bodyDef;
		bodyDef.type = b2_dynamicBody;
		bodyDef.position.Set(X, Y);
		mBody = pWorld->CreateBody(&bodyDef);
		mBody->SetLinearDamping(0.1f);
		mBody->SetFixedRotation(true);

		b2PolygonShape polygonShape;
		polygonShape.SetAsBox((pWidth * (8/2)), (0.5f * (8/2)));

		mType = "platform";

		b2FixtureDef fd;
		fd.shape = &polygonShape;
		fd.friction = 10.0f;
		fd.density = 10.0f;
		fd.restitution = 0.0f;
		fd.userData = mType;
		fd.filter.categoryBits = Constants::PLATFORM;
		fd.filter.maskBits = Constants::PLAYER | Constants::ENEMY;

		mBody->CreateFixture(&fd);
		mBody->SetGravityScale(0.0f);
		mBody->SetUserData(this);
}
示例#18
0
void MapBackground::Init()
{
	g_pThisAndTile = new ThisAndTile;
	((ThisAndTile*)g_pThisAndTile)->pThis = this;

	gError = S3E_RESULT_SUCCESS;
	gResult = NULL;
	gResultLen = 0;
	pImage = 0;
	g_cursorIter = 1;
	g_bInProgress = false;
	g_bInitialLoad = true;
	g_bIsAnimating = false;
	g_latPerPixel = 1;
	g_lonPerPixel = 1;
	g_iTileCacheCount = 0;

	gLocation.m_Latitude = 47.7710083;
	gLocation.m_Longitude = -122.1588533;

	g_bLocationChanged = true;

	g_viewMatrix.SetIdentity();
	g_viewMatrix.t.x = -0x200;

	g_bScaledMode = false;
	g_bShowCursor = true;

	gResult = NULL;

	CIwImage img;
	img.LoadFromFile("cursor.png");
	bool a = img.UsesAlpha();

	gCursor = Iw2DCreateImage(img);

	gScaler = new CoordinateScaler(Iw2DGetSurfaceWidth(), Iw2DGetSurfaceHeight(), NULL, 0, false);
	gScaledModeScaler = new CoordinateScaler(Iw2DGetSurfaceWidth(), Iw2DGetSurfaceHeight(), NULL, 0, true);
}
示例#19
0
/**
* Constructor
* @param pImgName the image to use
* @param pPos the position of the enemy
* @param pID the id number of the enemy
* @param pDiff the difficulty setting of the game
* @param pPatrolA first point which the enemy patrols between
* @param pPatrolB second point the enemy patrols between
*/
Enemy::Enemy(const char * pImgName, CIwSVec2 pPos, int pID, int pDiff, int pPatrolA, int pPatrolB):
	mAlive(true),
	mHealth(100),
	mState(IDLE),
	mTarget(b2Vec2(0, 0)),
	mDirection(1),
	mDrawDirection(1),
	mID(pID),
	mCanMove(false),
	mStunTimer(0.0f) {

		mPatrolPointA = -(768/16) + (0.5*4) + (pPatrolA*4) + 0.5;
		mPatrolPointB = -(768/16) + (0.5*4) + (pPatrolB*4) + 0.5;

		mImg = Iw2DCreateImage(pImgName);
		mPos = CIwSVec2(pPos.x*32, (pPos.y*32)+4);
		mHealth = 100.0f*pDiff;
		mMaxHealth = mHealth;
		mPatSave1 = pPatrolA;
		mPatSave2 = pPatrolB;

		mDeathSoundSpec = (CIwSoundSpec*)IwGetResManager()->GetGroupNamed("Sounds")->GetResNamed("enemyDeath", IW_SOUND_RESTYPE_SPEC);
}
示例#20
0
void IntroPanel::initialize( char *filePath, int16 dir )
{
	position = CIwSVec2( 0, 0 );

	image = Iw2DCreateImage( filePath );
	sprite.setImage( image );
	sprite.setUWidth( image->GetWidth() );
	sprite.setUHeight( image->GetHeight() );
	sprite.setSize( IwGxGetScreenWidth(), IwGxGetScreenHeight() );

	direction = dir; // directions can only be UP, DOWN, LEFT, RIGHT

	// If the panel is moving upward, spawn it at the center bottom of screen
	if( direction == START )
	{
		position = CIwSVec2( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );
	}
	else if( direction == UP )
	{
		position = CIwSVec2( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 * 3 );
	}
	// If the panel is moving downward, spawn it at the center top of screen
	else if( direction == DOWN )
	{
		position = CIwSVec2( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 * -1 );
	}
	// If the panel is moving left, spawn it at the right center of screen
	else if( direction == LEFT )
	{
		position = CIwSVec2( IwGxGetScreenWidth()/2 * 3, IwGxGetScreenHeight()/2 );
	}
	// If the panel is moving right, spawn it at the left center of screen
	else if( direction == RIGHT )
	{
		position = CIwSVec2( IwGxGetScreenWidth()/2 * -1, IwGxGetScreenHeight()/2 );
	}
}
示例#21
0
//-----------------------------------------------------------------------------------------------------Sprite
Sprite::Sprite(char *src)
{
	image = Iw2DCreateImage(src);
	position = new CIwSVec2(0, 0);
	size = new CIwSVec2(0, 0);
}
示例#22
0
/**
* Constructor
*/
Game::Game():

	physicsHz(60),
	timeStep(1.0f/physicsHz),
	velocityIterations(10),
	positionIterations(8),
	g_accumulator(0.0f),
	g_prevTime(s3eTimerGetMs()),
	loadCheckpoint(false), 
	mPaused(false),
	mMultiplayer(false),
	mBytesRecieved(-1),
	timeSinceLastSend(0),
	mRDXVel(0),
	mRecRDXVel(0),
	mDiff(1),
	mTimeSinceLastRequest(0),
	mSelectedLevel("1"),
	mPlayersFinished(0),
	FACEBOOK_APP_ID("160040267492274"),
	FACEBOOK_APP_SECRET("b7d69cf0ef9e50a344d892df3c8c7fe6") {

		mRequestBuffer = NULL;
		mHost = true;
		mSock = NULL;
		mPlayerFound = false;
		mPlayersInLobby = 0;
		mStage = Constants::MAINMENU;
		ServerUrl = "http://10.40.3.237:28003";
		g_GetUID = NULL;
		g_AddScore = NULL;
		mLevel = NULL;
		g_SelectedLvlScore = 0;
		g_Selectedlvl = "tutorial";
		PostScoreRequest = NULL;
		mTimeTaken = 0.0f;
		mPlayerDeaths = 0;
		g_CurrentSession = NULL;

		crateSpawned = true;
		maxCrates = 1;

		moveLeftBtn = Iw2DCreateImage("Images/ArrowLeft.png");
		moveRightBtn = Iw2DCreateImage("Images/ArrowRight.png");
		jumpBtn = Iw2DCreateImage("Images/ArrowJump.png");
		kickBtn = Iw2DCreateImage("Images/kick.png");
		punchBtn = Iw2DCreateImage("Images/punch.png");

		mMenuSystem = new MenuSystem();
		mMenuSystem->init(this);

		mCollListener = new MyContactListener();
		mCollListener->setGame(this);

		// Prepare the iwgxfont resource for rendering using Iw2D
		mFont = Iw2DCreateFontResource("font_large");

		if (s3eAudioIsCodecSupported(S3E_AUDIO_CODEC_MP3)) {
			s3eAudioPlay("Audio/MainMenu.mp3", 0);
		}

		mMusic.push_back("Audio/gameMusic1.mp3");
		mMusic.push_back("Audio/gameMusic2.mp3");

		srand((unsigned)time(0));
}
示例#23
0
int main()
{
    // Initialise the 2D graphics system
    Iw2DInit();

    // Create an image from a PNG file
    CIw2DImage* image = Iw2DCreateImage("textures/Tiles.png");
		
	//Avatar bits
	AnimationData testData;
	testData.animationName = "Up";
	testData.animationPosition = 0;
	testData.frameHeight = 64;
	testData.frameWidth = 32;
	testData.numberOfFrames = 4;

	AnimationData testData2;
	testData2.animationName = "Right";
	testData2.animationPosition = 64;
	testData2.frameHeight = 64;
	testData2.frameWidth = 32;
	testData2.numberOfFrames = 4;

	Animation* animation = new Animation("textures/AvatarTest.png",testData);
	Animation* animation2 = new Animation("textures/AvatarTest.png",testData2);

	s3eFile* file = s3eFileOpen("tilemaps/tilemapdemo.json", "rb");
	int len = s3eFileGetSize(file);
	char* rawTileJSON = new char[len];
	if (file != NULL)
	{
		if (s3eFileRead(rawTileJSON, len, 1, file) != 1)
		{
			s3eFileGetError();
			s3eDebugOutputString(s3eFileGetErrorString());
		}
		s3eFileClose(file);
	}
	else
	{
		s3eFileGetError();
		s3eDebugOutputString(s3eFileGetErrorString());
	}

	cJSON *root = cJSON_Parse(rawTileJSON);
	int gridHeight = cJSON_GetObjectItem(root,"height")->valueint;
	int gridWidth = cJSON_GetObjectItem(root,"width")->valueint;
	int tileWidth = cJSON_GetObjectItem(root,"tileheight")->valueint;
	int tileHeight = cJSON_GetObjectItem(root,"tilewidth")->valueint;
	cJSON *layers = cJSON_GetObjectItem(root,"layers");

	cJSON *tileData;
	int i;
	for (i = 0; i<cJSON_GetArraySize(layers); i++)
	{
		cJSON *layer = cJSON_GetArrayItem(layers,i);
		tileData = cJSON_GetObjectItem(layer,"data");
	}



    // Loop forever, until the user or the OS performs some action to quit the app
    while (!s3eDeviceCheckQuitRequest())
    {
        // Clear the drawing surface
        Iw2DSurfaceClear(0xff000000);

		int x,y,tileIndex,tileType;
		for( y = 0; y < gridHeight; y++)
		{
			for(x = 0; x < gridWidth; x++)
			{
				tileIndex = (y * gridWidth) + x;
				tileType = cJSON_GetArrayItem(tileData,tileIndex)->valueint -1;
				// Draw an image
				Iw2DDrawImageRegion(image, CIwFVec2(x*tileWidth,y*tileHeight),CIwFVec2(tileWidth,tileHeight),CIwFVec2(tileType*tileWidth,0),CIwFVec2(tileWidth,tileHeight));
			}
		}
		animation->render(50,50);
		animation2->render(150,200);
        // Show the drawing surface
        Iw2DSurfaceShow();
		
        // Yield to the OS
        s3eDeviceYield(0);
    }

	cJSON_Delete(root);

    // Clean-up
	delete rawTileJSON;
    delete image;
	delete animation;
	delete animation2;
    Iw2DTerminate();

    return 0;
}
示例#24
0
CGame::CGame()
: m_Position(0,0)
{
	m_ImgBG = Iw2DCreateImage("game-bg.png");
	m_ImgKey = Iw2DCreateImage("key.png");
}
示例#25
0
void MenuScreen::Initialize( int16 t )
{
	image = Iw2DCreateImage("splash.png");
	quitConfirmationImage2 = NULL;

	//counter = 0;
	buttonCount = 0;
	type = t;
	// This is the actual pixel size of the image for stretching and tiling purposes
	sprite.setUWidth( 480 );
	sprite.setUHeight( 320 );
	//sprite.setSize( 480, 320 );
	sprite.setSize( IwGxGetScreenWidth(), IwGxGetScreenHeight() );
	sprite.setImage( image );
	sprite.setPosition( IwGxGetScreenWidth()/2, -IwGxGetScreenHeight()/2 ); // menu screen position spawns off-screen by default!!!

	if( type == MENU )
	{
		delete image;
		image = Iw2DCreateImage("black.png");
		sprite.setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );

		// high score screen has back button, and Rate button
		buttonCount = 2; // make only 1 button for play for now. Add a 2nd button for credits. More button for more links.

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0: // PLAY button
				buttonImageArray[i] = Iw2DCreateImage("test.png");
				//buttonImageArray_pressed[i] = Iw2DCreateImage("rateButton_green.png"); // Load only one image for pressed and unpressed.
				button[i].setLocation( 50, 100 ); // these are irrelevant I believe, because locations are reset in Render()
				break;
			case 1: // High Score Screen button
				buttonImageArray[i] = Iw2DCreateImage("test.png");
				//buttonImageArray_pressed[i] = Iw2DCreateImage("backButton_green.png");
				button[i].setLocation( 300, 100 ); // these are irrelevant I believe, because locations are reset in Render()
				break;
			}
			
			buttonSprite[i].setImage( buttonImageArray[i] );
			buttonSprite[i].setUWidth( 128 );
			buttonSprite[i].setUHeight( 128 );
			//buttonSprite[i].setSize( 64, 64 );
			buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
			//buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
			buttonSprite_pressed[i].setImage( buttonImageArray[i] );	
			buttonSprite_pressed[i].setUWidth( 128 );
			buttonSprite_pressed[i].setUHeight( 128 );
			//buttonSprite_pressed[i].setSize( 50, 50 );
			buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

			button[i].setUnpressedSprite( buttonSprite[i] );
			button[i].setPressedSprite( buttonSprite_pressed[i] );
			//button[i].setTouchSize( 64, 64 );
			button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
		}
	}
	else if( type == CHALLENGE )
	{
		int row = 1;
		int column = 1;
		buttonCount = 21;

		// make 20 buttons for levels, 1 button to go back
		for( int i = 0; i < buttonCount; i++ )
		{
			// add if-condition here to create a different image for every button

			buttonImageArray[i] = Iw2DCreateImage("test.png");
			buttonSprite[i].setImage( buttonImageArray[i] );
			buttonSprite[i].setUWidth( 128 );
			buttonSprite[i].setUHeight( 128 );
			buttonSprite[i].setSize( 40, 40 );

			buttonImageArray_pressed[i] = Iw2DCreateImage("menuButton_Touched.png");
			buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
			buttonSprite_pressed[i].setUWidth( 128 );
			buttonSprite_pressed[i].setUHeight( 128 );
			buttonSprite_pressed[i].setSize( 40, 40 );

			button[i].setUnpressedSprite( buttonSprite[i] );
			button[i].setPressedSprite( buttonSprite_pressed[i] );
			button[i].setTouchSize( 40, 40 );
			button[i].setLocation( column*buttonSprite[i].size.x + 30*(column) + 35, row*buttonSprite[i].size.y + 15*(row) + 5 - IwGxGetScreenHeight()/2 );
			

			// increment the rows/columns
			column++;
			if( column >= 6 )
			{
				column = 1;
				row++;
			}
			
		} // end of for-loop creating buttons
	} // end of type == challenge menu
	else if( type == HIGH_SCORE )
	{
		delete image;
		if( s3eDeviceGetInt( S3E_DEVICE_OS ) == S3E_OS_ID_IPHONE )
		{
			image = Iw2DCreateImage("highscore_screen.png");
		}
		else
		{
			image = Iw2DCreateImage("highscore_screen2.png");
		}
		// high score screen has back button, and Rate button
		buttonCount = 13; // buttons 0-1 are rate, 2-6 are black trophies, 7-11 are trophies, 12 is game center

		for( int i = 0; i < NUM_OF_TROPHIES; i++ )
		{
			trophies[i] = false;
		}

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0: // RATE button
				buttonImageArray[i] = Iw2DCreateImage("rateButton_red.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("rateButton_green.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 64 );
				buttonSprite[i].setUHeight( 64 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 64 );
				buttonSprite_pressed[i].setUHeight( 64 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );

				//button[i].setLocation( 50, 100 ); // not affected here. in render
				break;
			case 1: // BACK button
				buttonImageArray[i] = Iw2DCreateImage("backButton_red.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("backButton_green.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 64 );
				buttonSprite[i].setUHeight( 64 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 64 );
				buttonSprite_pressed[i].setUHeight( 64 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );

				//button[i].setLocation( 300, 100 ); // not affected here. in render
				break;
			case 2: // all the BLACK TROPHY buttons
			case 3:
			case 4:
			case 5:
			case 6:
				buttonImageArray[i] = Iw2DCreateImage("trophyButton_black.png");
				//buttonImageArray_pressed[i] = Iw2DCreateImage("trophyButton_black.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 100 );
				buttonSprite[i].setUHeight( 100 );
				//buttonSprite[i].setSize( 100, 100 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .208, IwGxGetScreenWidth() * .208 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray[i] );	
				buttonSprite_pressed[i].setUWidth( 100 );
				buttonSprite_pressed[i].setUHeight( 100 );
				//buttonSprite_pressed[i].setSize( 80, 80 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .167, IwGxGetScreenWidth() * .167 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .167, IwGxGetScreenWidth() * .167 );
				break;
			case 7:
			case 8:
			case 9:
			case 10:
			case 11: // all the REGULAR TROPHY buttons
				buttonImageArray[i] = Iw2DCreateImage("trophyButton.png");
				//buttonImageArray_pressed[i] = Iw2DCreateImage("trophyButton.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 64 );
				buttonSprite[i].setUHeight( 64 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray[i] );	
				buttonSprite_pressed[i].setUWidth( 64 );
				buttonSprite_pressed[i].setUHeight( 64 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;
			case 12: // GameCenter button

				buttonImageArray[i] = Iw2DCreateImage("gamecenter_64.png");
				//buttonImageArray_pressed[i] = Iw2DCreateImage("trophyButton.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 64 );
				buttonSprite[i].setUHeight( 64 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray[i] );	
				buttonSprite_pressed[i].setUWidth( 64 );
				buttonSprite_pressed[i].setUHeight( 64 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;

			}
		}

	} // end of type == high score
	else if( type == CREDITS )
	{
		delete image;
		image = Iw2DCreateImage("credits_screen.png");

		// high score screen has back button, and Rate button
		buttonCount = 2;

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0: // RATE button
				buttonImageArray[i] = Iw2DCreateImage("rateButton_red.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("rateButton_green.png");
				button[i].setLocation( 50, 100 );
				break;
			case 1: // BACK button
				buttonImageArray[i] = Iw2DCreateImage("backButton_red.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("backButton_green.png");
				button[i].setLocation( 300, 100 );
				break;
			}
			
			buttonSprite[i].setImage( buttonImageArray[i] );
			buttonSprite[i].setUWidth( 64 );
			buttonSprite[i].setUHeight( 64 );
			//buttonSprite[i].setSize( 64, 64 );
			buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
			buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
			buttonSprite_pressed[i].setUWidth( 64 );
			buttonSprite_pressed[i].setUHeight( 64 );
			//buttonSprite_pressed[i].setSize( 50, 50 );
			buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

			button[i].setUnpressedSprite( buttonSprite[i] );
			button[i].setPressedSprite( buttonSprite_pressed[i] );
			//button[i].setTouchSize( 64, 64 );
			button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
		}
	}
	else if( type == TUTORIAL )
	{
		delete image;
		image = Iw2DCreateImage("tutorial.png");

		// high score screen has back button, and Rate button
		buttonCount = 4;

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0:
				buttonImageArray[i] = Iw2DCreateImage("backButton_red.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("backButton_green.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 64 );
				buttonSprite[i].setUHeight( 64 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 64 );
				buttonSprite_pressed[i].setUHeight( 64 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;
			case 1:
				buttonImageArray[i] = Iw2DCreateImage("buttonBasic.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("buttonBasic.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;
			case 2:
				buttonImageArray[i] = Iw2DCreateImage("buttonDanger.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("buttonDanger.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;
			case 3:
				buttonImageArray[i] = Iw2DCreateImage("buttonDefuse.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("buttonDefuse.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 64, 64 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 50, 50 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .104, IwGxGetScreenWidth() * .104 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 64, 64 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .133, IwGxGetScreenWidth() * .133 );
				break;
			}			
		}
	}
	else if( type == QUIT_CONFIRMATION )
	{
		delete image;
		image = Iw2DCreateImage("quitconfirmation.png");
		quitConfirmationImage2 = Iw2DCreateImage("quitconfirmation2.png");
		sprite.setUWidth( 480 );
		sprite.setUHeight( 320 );
		//sprite.setSize( 480, 320 );
		sprite.setSize( IwGxGetScreenWidth(), IwGxGetScreenHeight() );
		sprite.setImage( image );
		sprite.setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );

		// high score screen has back button, and Rate button
		buttonCount = 2;

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0:
				buttonImageArray[i] = Iw2DCreateImage("quitconfirmation_yes.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("quitconfirmation_yes.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 128, 128 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 100, 100 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .208, IwGxGetScreenWidth() * .208 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 128, 128 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
				break;
			case 1:
				buttonImageArray[i] = Iw2DCreateImage("quitconfirmation_no.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("quitconfirmation_no.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 128, 128 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 100, 100 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .208, IwGxGetScreenWidth() * .208 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 128, 128 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
				break;
			}			
		}
	}
	else if( type == NEW_STORY_CONFIRMATION )
	{
		delete image;
		image = Iw2DCreateImage("newstoryconfirmation.png");
		sprite.setUWidth( 480 );
		sprite.setUHeight( 320 );
		//sprite.setSize( 480, 320 );
		sprite.setSize( IwGxGetScreenWidth(), IwGxGetScreenHeight() );
		sprite.setImage( image );
		sprite.setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );

		// high score screen has back button, and Rate button
		buttonCount = 2;

		for( int i = 0; i < buttonCount; i++ )
		{
			switch( i )
			{
			case 0:
				buttonImageArray[i] = Iw2DCreateImage("quitconfirmation_yes.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("quitconfirmation_yes.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 128, 128 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 100, 100 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .208, IwGxGetScreenWidth() * .208 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 128, 128 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );

				break;
			case 1:
				buttonImageArray[i] = Iw2DCreateImage("quitconfirmation_no.png");
				buttonImageArray_pressed[i] = Iw2DCreateImage("quitconfirmation_no.png");

				buttonSprite[i].setImage( buttonImageArray[i] );
				buttonSprite[i].setUWidth( 128 );
				buttonSprite[i].setUHeight( 128 );
				//buttonSprite[i].setSize( 128, 128 );
				buttonSprite[i].setSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
			
				buttonSprite_pressed[i].setImage( buttonImageArray_pressed[i] );	
				buttonSprite_pressed[i].setUWidth( 128 );
				buttonSprite_pressed[i].setUHeight( 128 );
				//buttonSprite_pressed[i].setSize( 100, 100 );
				buttonSprite_pressed[i].setSize( IwGxGetScreenWidth() * .208, IwGxGetScreenWidth() * .208 );

				button[i].setUnpressedSprite( buttonSprite[i] );
				button[i].setPressedSprite( buttonSprite_pressed[i] );
				//button[i].setTouchSize( 128, 128 );
				button[i].setTouchSize( IwGxGetScreenWidth() * .267, IwGxGetScreenWidth() * .267 );
				break;
			}
		}
	}
	else if( type == QUESTION_MARK )
	{
		delete image;
		image = Iw2DCreateImage("questionmarkinfo.png");
		sprite.setUWidth( 480 );
		sprite.setUHeight( 320 );
		//sprite.setSize( 480, 320 );
		sprite.setSize( IwGxGetScreenWidth(), IwGxGetScreenHeight() );
		sprite.setImage( image );
		sprite.setPosition( IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2 );
	}

} // end of initialize()
示例#26
0
Resources::Resources(){
    Blocks[0] = Iw2DCreateImage("textures/EmptyBlock.png");
    Blocks[1] = Iw2DCreateImage("textures/Object 1.png");
    Blocks[2] = Iw2DCreateImage("textures/Object 2.png");
    Blocks[3] = Iw2DCreateImage("textures/Object 3.png");
    BGiPhone4 = Iw2DCreateImage("textures/backiPhone4.png");
    imgBlocks[0]= Iw2DCreateImage("textures/anim12.png");
    imgBlocks[1]= Iw2DCreateImage("textures/anim13.png");
    imgBlocks[2]= Iw2DCreateImage("textures/anim21.png");
    imgBlocks[3]= Iw2DCreateImage("textures/anim23.png");
    imgBlocks[4]= Iw2DCreateImage("textures/anim31.png");
    imgBlocks[5]= Iw2DCreateImage("textures/anim32.png");
    emtBlock = Iw2DCreateImage("textures/EmptyBlock.png");
    imgButtonStart = Iw2DCreateImage("textures/buttonStart.png");
    MenuBG = Iw2DCreateImage("textures/Swiperbackground.png");
    Retry = Iw2DCreateImage("textures/Retry.png");
    Info = Iw2DCreateImage("textures/Info.png");
    //lightToMiddle = Iw2DCreateImage("textures/B-D.png");
    //middleToLight = Iw2DCreateImage("textures/D-B.png");
    backAfterDie = Iw2DCreateImage("textures/BackAfterDie.png");
    Font = (CIwGxFont*)IwGetResManager()->GetResNamed("SansusWR", "CIwGxFont");
    int frame_w = (int)(imgBlocks[0]->GetWidth() / 20.0);
    int frame_h = (int)(imgBlocks[0]->GetHeight()/1);
    for (int i = 0; i < 6; ++i){
        animBetweenBlocks[i] = new CAtlas(frame_w,frame_h,20,imgBlocks[i]);
    }
    
    emptyBlock = new CAtlas(emtBlock->GetWidth(),emtBlock->GetHeight(),1,emtBlock);
    //animLightToMiddle = new CAtlas(frame_w, frame_h, 20, lightToMiddle);
    //frame_w = (int)(middleToLight->GetWidth() / 20.0);
    //frame_h = (int)(middleToLight->GetHeight()/1);
    //animMiddleToLight = new CAtlas(frame_w, frame_h, 20, middleToLight);
    /*// Create atlases
    int frame_w = (int)(Gems[0]->GetWidth() / 5);
    int frame_h = (int)(Gems[0]->GetHeight() / 3);
    for (int t = 0; t < MAX_GEM_TYPES; t++)
        GemAtlases[t] = new CAtlas(frame_w, frame_h, 15, Gems[t]);
    frame_w = (int)(Explosion->GetWidth() / 5);
    frame_h = (int)(Explosion->GetHeight() / 3);
    ExplosionAtlas = new CAtlas(frame_w, frame_h, 15, Explosion);
     */
}
示例#27
0
void Resources::LoadGame()
{
	manHit = Iw2DCreateImage("textures/manHit.png");
	GameBG = Iw2DCreateImage("textures/bkg.png");
	PauseIcon = Iw2DCreateImage("textures/pause_icon.png");
	NewGame = Iw2DCreateImage("textures/new_game.png");
	MenuButton = Iw2DCreateImage("textures/button_bg.png");
	seaImage = Iw2DCreateImage("textures/sea.png");
	birdImage = Iw2DCreateImage("textures/bird.png");
	PooImage = Iw2DCreateImage("textures/poo.png");
	ManImage = Iw2DCreateImage("textures/man.png");
	highScoreImage = Iw2DCreateImage("textures/highscore.png");
	hotDogImage = Iw2DCreateImage("textures/hotdog.png");

	Boat = Iw2DCreateImage("textures/boat.png");
	Splash = Iw2DCreateImage("textures/sprite-splash.png");
	int frame_third = (int)(Splash->GetWidth() / 3);
	SplashAtlas = new CAtlas(frame_third, frame_third, 9, Splash);

	recalibrateImage = Iw2DCreateImage("textures/recal.png");

	cloudImage = new CIw2DImage*[6];

	int i;
	for (i = 0; i < 6; i++)
	{

		char str[16];

		strcpy(str, "textures/cloud");

		char strB[16];
		snprintf(strB, 16, "%d", (i + 1));

		strcat(str, strB);
		strcat(str, ".png");

		cloudImage[i] = Iw2DCreateImage(str);
	}
}
示例#28
0
int main()
{
	Iw2DInit();

	image1 = Iw2DCreateImage("image1.png");
	image2 = Iw2DCreateImage("image2.png");

	while (!s3eDeviceCheckQuitRequest())
	{
		// Transition #1
		// Fade in from black
		Iw2DSurfaceClear(0xff000000);
		Transitions2D::CaptureStartScreen();
		DrawOnRed();
		Transitions2D::CaptureEndScreen();
		Transitions2D::Fade();

		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;
		
		// Transition #2
		// Cross fade from red image to blue image
		DrawOnRed();
		Transitions2D::CaptureStartScreen();
		DrawOnBlue();
		Transitions2D::CaptureEndScreen();
		Transitions2D::Fade();
		
		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;
		
		// Transition #3
		// Slide left
		DrawOnBlue();
		Transitions2D::CaptureStartScreen();
		DrawOnRed();
		Transitions2D::CaptureEndScreen();
		Transitions2D::SlideLeft();

		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;
		
		// Transition #4
		// Slide right
		DrawOnRed();
		Transitions2D::CaptureStartScreen();
		DrawOnBlue();
		Transitions2D::CaptureEndScreen();
		Transitions2D::SlideRight();

		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;

		// Transition #5
		// Slide up
		DrawOnBlue();
		Transitions2D::CaptureStartScreen();
		DrawOnRed();
		Transitions2D::CaptureEndScreen();
		Transitions2D::SlideUp();

		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;

		// Transition #6
		// Slide down
		DrawOnRed();
		Transitions2D::CaptureStartScreen();
		DrawOnBlue();
		Transitions2D::CaptureEndScreen();
		Transitions2D::SlideDown();
		
		s3eDeviceYield(1000);
		if (s3eDeviceCheckQuitRequest()) break;

		// Transition #7
		// Fade out to black
		DrawOnBlue();
		Transitions2D::CaptureStartScreen();
		Iw2DSurfaceClear(0xff000000);
		Transitions2D::CaptureEndScreen();
		Transitions2D::Fade();

		s3eDeviceYield(1000);
	}

	delete image1;
	delete image2;

	Iw2DTerminate();
}