Exemple #1
0
void renderMapHealth() {
	IwGxLightingOff();

	Iw2DSetAlphaMode(IW_2D_ALPHA_NONE);
	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);

	int16 w = (double)IwGxGetScreenWidth() * 0.09f;
	if (w > (int16)healthTexture->GetWidth()) w = (int16)healthTexture->GetWidth();

	float whScale = (float)((double)healthTexture->GetWidth() / healthTexture->GetHeight());
	int16 h = w * 1/whScale;

	int leftPadding = IwGxGetScreenWidth() * 0.10f;
	int topPadding = IwGxGetScreenHeight() * 0.02f;

	int leftMargin = IwGxGetScreenWidth() * 0.03f;
	int topMargin = IwGxGetScreenHeight() * 0.05f;

	CIwFVec2 size = CIwFVec2(w, h);
	int vitality = getGameState()->getPlayer()->getVitality();
	
	for (int i = 0; i < PLAYER_MAX_VITALITY; i++) {
		CIwFVec2 topLeft = CIwFVec2(leftPadding + (leftMargin+w)*i, topPadding);

		if (i < vitality) {
			Iw2DDrawImage(healthTexture, topLeft, size);
		} else {
			Iw2DDrawImage(healthLostTexture, topLeft, size);
		}
	}
}
Mouse::Mouse(CIwSVec2 i2Position): ShinyUnit() 
{
   IW_CALLSTACK("Mouse::Mouse");

   this->iAIHole = 10;
   this->bUpdate = false;
   this->bDead = false;
   this->bScared = false;
   this->f2Velocity = CIwFVec2(0.101f, 0);
   this->tTextureList.push_back(ImageManager::getImage("mouse"));
   this->tTextureList.push_back(ImageManager::getImage("mouseleft"));


   this->sSoundList.push_back(SoundManager::getSound("mouse1"));
   this->sSoundList.push_back(SoundManager::getSound("mouse2"));	
   this->sSoundList.push_back(SoundManager::getSound("mouse3"));
   this->sSoundList.push_back(SoundManager::getSound("mouse4"));

   this->i2Position = i2Position;
   this->f2AbsPosition = CIwFVec2((float)this->i2Position.x, (float)this->i2Position.y);
   this->i2InitialPosition = i2Position;
   this->sName = "mouse";
   this->fShininess = 6;
   this->bIsMoving = true;
   this->brBoundingBox = BoundingRectangle(this->getPosition(), this->getSize(), CIwSVec2((int)(this->i2Size.x * 0.3f), (int)(this->i2Size.y * 0.3f)), true);
   this->csPlayWith = CatState::MOUSEPLAYING;

   ClassTracker::addUnit(this);
}
Exemple #3
0
void cameraStreamInit(int camDataW, int camDataH) {
	double w = IwGxGetScreenWidth();
	double h = IwGxGetScreenHeight();

	IwTrace(GHOST_HUNTER, ("camDataW %d camDataH %d w %f h %f", camDataW, camDataH, w, h));
	{
		double whRatio = ((double)camDataW) / camDataH;

		if (whRatio > w/h) {
			w = h * whRatio;
		} else if (whRatio < w/h) {
			h = w * 1.f/whRatio;
		}
	}

	IwTrace(GHOST_HUNTER, ("w %f h %f", w, h));

	int16 x1 = (int16)(-abs(w - IwGxGetScreenWidth())/2); // Negative or 0
	int16 x2 = (int16)(IwGxGetScreenWidth()  - x1);
	int16 y1 = (int16)(-abs(h - IwGxGetScreenHeight())/2); // Negative or 0
	int16 y2 = (int16)(IwGxGetScreenHeight() - y1);

	cameraVert[0].x = x1, cameraVert[0].y = y1;
	cameraVert[1].x = x1, cameraVert[1].y = y2;
	cameraVert[2].x = x2, cameraVert[2].y = y2;
	cameraVert[3].x = x2, cameraVert[3].y = y1;

	cameraUvs[0] = CIwFVec2(1, 0);
    cameraUvs[1] = CIwFVec2(1, 1);
    cameraUvs[2] = CIwFVec2(0, 1);
    cameraUvs[3] = CIwFVec2(0, 0);
}
Exemple #4
0
bool Spreader::update(std::list<Unit*>::iterator itr){
	
	//This is just using magic numbers right now - we need to discuss
	//how to interpret the units stats/do some refactoring.
	
	//wait 30 frames, then spread 1 "layer" of icing every 30 frames
	if(spreadDelay%30 == 0 && spreadDelay >= 30) {
		
		//spread 3 layers of icing
		if(amountSpread < 4) {
			
			float radius = amountSpread*20.0f;
			float thetaJump = PI/4.0/(float)amountSpread;
			
			for (double spreadTheta = 0.0; spreadTheta < 2*PI; spreadTheta += thetaJump) {
				
				float xIncr = radius * cos(spreadTheta);
				float yIncr = radius * sin(spreadTheta);
				
				if(isInWorld(CIwFVec2(position.x + xIncr, position.y + yIncr), worldRad.x, worldRad.y)) {
					game->addIcing(new Icing(CIwFVec2(position.x + xIncr, position.y + yIncr), game, owner));
				}
			}
			
			amountSpread++;
		}
	}
	
	spreadDelay++;
	curFrame = (curFrame + 1) % numFrames;
    return true;
}
Exemple #5
0
void ghostInit() {
	mapGhost = new MapRoamingGhost("textures/map_ghost.png", 
		CIwFVec2(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2));
	mapGhost->modifyCentreWithTexture(-0.18f, -0.13f);
	mapGhost->setNotice(true);

	mapGhost2 = new MapRoamingGhost("textures/map_ghost_xtra.png", 
		CIwFVec2(IwGxGetScreenWidth()*0.80f, IwGxGetScreenHeight()*0.70f));
}
void DrawGround()
{
	for (int i = 0; i < NUM_BUILDINGS; i++) {
		Iw2DSetColour(0xff000000);
		Iw2DFillRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y),
					 CIwFVec2(buildings_dim[i].x, buildings_dim[i].y));
		Iw2DSetColour(0xffffffff);
		Iw2DDrawRect(CIwFVec2(GAME_WIDTH - buildings_pos[i].x, GAME_HEIGHT - buildings_pos[i].y),
					 CIwFVec2(buildings_dim[i].x, buildings_dim[i].y));
	}
}
void ResourceManager::paint(const char* res, int x, int y, int w, int h, int* lm, int* tm, int* rm, int* bm) {
	int width, height;
	if (res == NULL) return;
	CIwMaterial* t = load(res, &width, &height);
	if (t == NULL) return;
    if (vertC + 4 >= MAX_VERTS) return;
	if (width != 0) {
		if (lm != 0) {
			*lm = (*lm * w) / width;
			x -= *lm;
			w += *lm;
		}
		if (rm != 0) {
			*rm = (*rm * w) / width;
			w += *rm;
		}
	}
	if (height != 0) {
		if (tm != 0) {
			*tm = (*tm * h) / height;
			y -= *tm;
			h += *tm;
		}
		if (bm != NULL) {
			*bm = (*bm * h) / height;
			h += *bm;
		}
	}
    int offset = vertC;
	xy3[vertC].x = x,     xy3[vertC].y = y;      vertC++;
	xy3[vertC].x = x,     xy3[vertC].y = y + h;  vertC++;
	xy3[vertC].x = x + w, xy3[vertC].y = y + h;  vertC++;
	xy3[vertC].x = x + w, xy3[vertC].y = y;      vertC++;
	IwGxSetVertStreamScreenSpace(xy3 + offset, 4);
	IwGxSetMaterial(t);
	static CIwFVec2 uvs[4] = {
		CIwFVec2(0, 0),
		CIwFVec2(0, 1),
		CIwFVec2(1, 1),
		CIwFVec2(1, 0),
	};
/*	static CIwSVec2 uvs[4] = {
		CIwSVec2(0,           0),
		CIwSVec2(0,           IW_GEOM_ONE),
		CIwSVec2(IW_GEOM_ONE, IW_GEOM_ONE),
		CIwSVec2(IW_GEOM_ONE, 0),
	};*/
	IwGxSetUVStream(uvs);
	IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
}
void DrawBootSequence()
{
	Iw2DSetFont(font);

	int h = font->GetHeight();

	for (unsigned i = 0; i < g_Current_Line; i++) {
		int w = Iw2DGetStringWidth(g_Bootup_Sequence[i]);

		Iw2DSetColour(0xffffffff);
		Iw2DDrawString(g_Bootup_Sequence[i], CIwFVec2(0, i*h),
			CIwFVec2(w, h), IW_2D_FONT_ALIGN_LEFT, IW_2D_FONT_ALIGN_TOP);
	}
}
Exemple #9
0
//return true means has collide with obstacles
bool Map::CheckCollision(CIwFVec2 characterPos,CIwSVec2 characterBox,CIwFVec2 &target,CIwFVec2 characterPrePos)
{
	//get border info for each _TileObstacles by checking certain tile's border info stored in tileset for each layer
	//-1- get current character standing on tile index from the map

	//check if character has moved to another tile since last frame, if not then don't update the rest
	if(_characterPreIndex!=_characterIndex)
	{	
		int index_Map[9];
		//-2- get nearby 9 tiles index      0,1,2
		//									3,4,5
		//									6,7,8
		index_Map[0]=_characterIndex-_width-1;
		index_Map[1]=_characterIndex-_width;
		index_Map[2]=_characterIndex-_width+1;
		index_Map[3]=_characterIndex-1;
		index_Map[4]=_characterIndex;
		index_Map[5]=_characterIndex+1;
		index_Map[6]=_characterIndex+_width-1;
		index_Map[7]=_characterIndex+_width;
		index_Map[8]=_characterIndex+_width+1;

		//-3- get position for each nearby tiles
		CIwFVec2 pos_Map[9];
		pos_Map[4]=CIwFVec2(_index_Map_X*_tileWidth,_index_Map_Y*_tileHeight);
		pos_Map[0]=CIwFVec2((_index_Map_X-1)*_tileWidth,(_index_Map_Y-1)*_tileHeight);
		pos_Map[1]=CIwFVec2(_index_Map_X*_tileWidth,(_index_Map_Y-1)*_tileHeight);
		pos_Map[2]=CIwFVec2((_index_Map_X+1)*_tileWidth,(_index_Map_Y-1)*_tileHeight);
		pos_Map[3]=CIwFVec2((_index_Map_X-1)*_tileWidth,_index_Map_Y*_tileHeight);
		pos_Map[5]=CIwFVec2((_index_Map_X+1)*_tileWidth,_index_Map_Y*_tileHeight);
		pos_Map[6]=CIwFVec2((_index_Map_X-1)*_tileWidth,(_index_Map_Y+1)*_tileHeight);
		pos_Map[7]=CIwFVec2(_index_Map_X*_tileWidth,(_index_Map_Y+1)*_tileHeight);
		pos_Map[8]=CIwFVec2((_index_Map_X+1)*_tileWidth,(_index_Map_Y+1)*_tileHeight);

		int index_Layer_Base,index_Layer_Middle,index_Layer_Maze;
	
		for(int i=0;i!=9;i++)
		{
			CheckBorder(index_Map[i]);
			_TileObstacles[i].UpdateObstacle(_border,pos_Map[i]);
			if(_TileObstacles[i].CheckCollision(characterPos,characterBox,target,characterPrePos))
				return true;
		}
	}
	else
	{
		for(int i=0;i!=9;i++)
		{
			if(_TileObstacles[i].CheckCollision(characterPos,characterBox,target,characterPrePos))
				return true;
		}
	}
	return false;
}
Exemple #10
0
void N2F::Iw3D::Image::draw(int64 delta, CIwFVec2 offset)
{
	CIwFVec2 p = CIwFVec2(
		((this->pos.x * this->scaleFactor.scale) + this->scaleFactor.offset.x + offset.x),
		((this->pos.y * this->scaleFactor.scale) + this->scaleFactor.offset.y + offset.y)
	);
	CIwFVec2 s = CIwFVec2(
		(this->size.x * this->scaleFactor.scale),
		(this->size.y * this->scaleFactor.scale)
	);

	Iw2DDrawImage(this->img, p, s);

	return;
}
Exemple #11
0
void Map::Load(char * mapFileName)
{
	int temp[2]={0,0};
	memcpy(_StartPos,temp,sizeof(temp));
	memcpy(_EndPos,temp,sizeof(temp));
	showDialog=-1;
	screenHeight= IwGxGetScreenHeight();
	screenWidth=IwGxGetScreenWidth();
	_layer_base=new Layer;
	_layer_middle=new Layer;
	_layer_maze=new Layer;
	_tileset_map=new TileSet;
	_tileset_maze=new TileSet;
	_path=new Path;
	ReadJsonFile(mapFileName);
	_characterPreIndex=0;
	_NPC=new NPC;
	_NPC->m_Dialogs.append("Hello there!!!!");
	_NPC->m_Dialogs.append("How are you?");
	_NPC->m_Dialogs.append("This is World of MI. Welcome!");
	_NPC->Init();
	
	for(int i=0;i!=9;i++)
	{
		TileObstacle tileObs=TileObstacle();
		tileObs.InitialObstacle(CIwFVec2(0,0),CIwSVec2(_tileWidth,_tileHeight));
		_TileObstacles.append(tileObs);
	}
	//_EventBlock.append(4322);
}
Exemple #12
0
Tiles::Tiles()
{
	_Total=12;
	_W=4;
	_H=3;
	m_Position=CIwFVec2(320.0f,320.0f);
}
Exemple #13
0
Character::Character()
{
	// make character start at center of screen
	m_Target=m_Position=m_ScreenCenter=CIwFVec2(Iw2DGetSurfaceWidth()/2.0f,Iw2DGetSurfaceHeight()/2.0f);
	//m_MOVERANGE=50.0f;
	m_HitRange=false;
}
void GameplayState::CheckCollisions(const int &pCharacter)
{
	characters[pCharacter]->UpdateCollider();
	for (size_t m = 0; m < m_Level->GetMap().size(); m++)
	{
		GameObject *t = m_Level->GetMap().at(m);
		if (characters[pCharacter]->isColliding(t, CIwFVec2(0,0)))
		{
			// if colliding with surface and bottom > t-height enable jumping
			characters[pCharacter]->SetPosition(characters[pCharacter]->GetLastPosition());
			if (pCharacter == NIGEL)
			{
				if (m_isThrowing)
				{
					m_canThrow = false;
					m_isThrowing = false;
					m_ThrowingNigelSound->ResetCounter();
				}
			}
			// If the colliding object is lower (on screen higher) than the character, set the jumping flag to be false
			if (characters[pCharacter]->GetBottom() < t->GetBottom())
			{
				characters[pCharacter]->TEMP_LANDEDJUMP = true;
				
			}
			characters[pCharacter]->TEMP_JUSTJUMPED = false;
			
		}
	}
}
void GameplayState::Update(StateEngine* state, double dt)
{
	characters[DAVE]->Update(dt);
	characters[MANDY]->Update(dt);
	if (!m_isThrowing)
		characters[NIGEL]->Update(dt);

	ScrollCranes(dt);

	CheckInterations(state);

	for (int i = 0; i <3; i++)
	{
		CheckObjects(i);
		CheckCollisions(i);	
	}

	m_Cam->SetPosition(
		CIwSVec2(static_cast<int16>(-characters[m_CharacterIndex]->GetPosition().x + (screenWidth /2)),
		static_cast<int16>(-characters[m_CharacterIndex]->GetPosition().y + (screenHeight - characters[m_CharacterIndex]->GetHeight() - 32))));

	if (s3eKeyboardGetState(s3eKeySpace) == 4)
		m_SpacePressed = false;

	if (s3ePointerGetState(S3E_POINTER_BUTTON_LEFTMOUSE) == 4)
	{
		m_MouseClicked = false;
		m_ClickLocation = CIwFVec2(0,0);
		m_TerminalSound->ResetCounter();
	}
}
Exemple #16
0
// Main entry point for the application
int main()
{
	// Initialise Iw2D
	Iw2DInit();

	// Get surface width and height
	int surface_width = Iw2DGetSurfaceWidth();
	int surface_height = Iw2DGetSurfaceHeight();

	// Rotation angle of rectangle
	float angle = 0;
	
	// Wait for a quit request from the host OS
	while (!s3eDeviceCheckQuitRequest())
	{
		// Clear background to blue
		Iw2DSurfaceClear(0xff8080);

		// Set up a transform
		CIwFMat2D mat;
		mat.SetRot(angle);
		mat.ScaleRot(2.0f);
		mat.SetTrans(CIwFVec2((float)surface_width / 2, (float)surface_height / 2));
		Iw2DSetTransformMatrix(mat);
		angle += 0.01f;

		// Render filled rectangle
		Iw2DSetColour(0xff00ffff);
		Iw2DFillRect(CIwFVec2(-50.0f, -100.0f), CIwFVec2(100.0f, 200.0f));

		// Render filled arc
		Iw2DSetColour(0xffff00ff);
		Iw2DFillArc(CIwFVec2(0, 0), CIwFVec2(100.0f, 100.0f), 0, 1.8 * PI);
		
		// Flip the surface buffer to screen
		Iw2DSurfaceShow();

		// Sleep to allow the OS to process events etc.
		s3eDeviceYield(0);
	}
	
	// Shut down Iw2D
	Iw2DTerminate();
	
	return 0;
}
Exemple #17
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;
}
Exemple #18
0
Unit::Unit(const Unit& newUnit)
	: WorldObject(newUnit), 
	hp(newUnit.hp), cost(newUnit.cost), attackDamage(newUnit.attackDamage), speed(newUnit.speed),
	munch_speed(newUnit.munch_speed), range(newUnit.range), sight(newUnit.sight),
	spread_speed(newUnit.spread_speed), spread_radius(newUnit.spread_radius),
	scale(newUnit.scale), target(NULL), curFrame(0), numFrames(newUnit.numFrames), spriteSize(newUnit.spriteSize),
	navTarget(CIwFVec2(0, 0)), repulsion_factor(1)
{
	setOwner(newUnit.owner);
}
Exemple #19
0
void DrawMap()
{
	Iw2DSurfaceClear(0x11550030);
	for(int i=0;i<10;i++)
	{
		for(int j=0;j<10;j++)
		{
			switch(Map[i][j])
			{
			case 0: Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
			case 1: Iw2DDrawImage(three,CIwFVec2((i-j+9)*16,(i+j)*8)); break;
			case 2: Iw2DDrawImage(grass,CIwFVec2((i-j+9)*16,(i+j)*8));
					Iw2DDrawImage(man,CIwFVec2((i-j+9)*16,(i+j)*8));
					break;
			}
		}
	}
	Iw2DSurfaceShow();
}
void GameplayState::ScrollCranes(double dt)
{
	for (int i = 0; i < 3; i++)
	{
		if (m_Cranes[i]->GetPosition().x <= 0 || m_Cranes[i]->GetPosition().x >= screenWidth - m_Cranes[i]->GetWidth())
			m_Cranes[i]->SetMovSpeed(-m_Cranes[i]->GetMovSpeed());

		m_Cranes[i]->MoveBy(CIwFVec2(m_Cranes[i]->GetMovSpeed().x * dt, 0),0);
	}
}
int main()
{
	Initialize();

	// --HowTo: Load the tmx map from the json file
	tmxparser::Map_t *map = new tmxparser::Map_t;
	tmxparser::parseTmxFromJSON_file("testLevel.json", map);
	// --HowTo: Create a renderer
	tmxparser::TmxRenderer *renderer = new tmxparser::TmxRenderer(map);
	// an offset to use for scrolling the map
	CIwFVec2 offset(0,0);
	
	IwGxSetColClear(0x2f, 0x3f, 0x3f, 0xff);
    
    // Loop forever, until the user or the OS performs some action to quit the app
    while (!s3eDeviceCheckQuitRequest())
    {
        //Update the input systems
        s3eKeyboardUpdate();
        s3ePointerUpdate();

        // Clear the surface
        IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

		// --HowTo: render all layers, at original pixel size:
		//renderer->Render(offset); 

		// --HowTo: render all layers at reduced/scaled tile size
		renderer->Render(offset, CIwFVec2(64.0f, 64.0f)); 
		
		// --HowTo: render only one layer at original pixel size
		//renderer->RenderLayer(0, offset, CIwFVec2(0.0f, 0.0f));

		// --HowTo: render only one layer at scaled pixel size
		//renderer->RenderLayer(0, offset, CIwFVec2(64.0f, 64.0f));

		// advance offset
		offset.x += 3;
		if (offset.x>1900)
			offset.x =0;

        // Standard EGL-style flush of drawing to the surface
        IwGxFlush();
        IwGxSwapBuffers();
        s3eDeviceYield(0);
    }

	delete renderer;
	delete map;

	Terminate();    
    // Return
    return 0;
}
Exemple #22
0
void renderMapXpBar() {
	IwGxLightingOff();

	Iw2DSetAlphaMode(IW_2D_ALPHA_NONE);
	Iw2DSetTransformMatrix(CIwFMat2D::g_Identity);

	int16 w = (double)IwGxGetScreenWidth() * 0.40f;
	if (w > (double)xpBarTexture->GetWidth() * 1.80f) w = (double)xpBarTexture->GetWidth() * 1.80f;

	float whScale = (float)((double)xpBarTexture->GetWidth() / xpBarTexture->GetHeight());
	int16 h = w * 1/whScale;

	int rightPadding = IwGxGetScreenWidth() * 0.10f;
	int topPadding  = IwGxGetScreenHeight() * 0.015f;

	CIwFVec2 size = CIwFVec2(w, h);
	CIwFVec2 topLeft = CIwFVec2(IwGxGetScreenWidth() - rightPadding - w, topPadding);

	Iw2DDrawImage(xpBarTexture, topLeft, size);
}
Exemple #23
0
void DrawXm(int x)
{	
	float j=(manX+manY)*8;
	for(int i=(manX-manY+9)*16;i>=(x-manY+9)*16;i--)
	{
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		j=j-0.5;
	}
}
void Physics::update(){
    
    /****
     UPDATE POSITIONS
     ****/
    CIwArray<Entity*> & entities = rM.getEntities(); //move all entities
    for (CIwArray<Entity*>::iterator it = entities.begin(); it != entities.end(); it++){
        Entity * e = *it;
        //maybe move by angle + force?
        this->translate(* e, e->vec);
    }
    SpaceShip * e = &rM.getSpaceShip();
    if(not inbounds(* e)){
        //move the ship back
        CIwFVec2 revVec = CIwFVec2( - e->vec.x, - e->vec.y);
        this->translate(* e, revVec);
    }    
    
    /****
     HITTEST BULLET TO ENEMY
     ****/
    CIwArray<Bullet*> & bulletArray = rM.getBullets();
    for (CIwArray<Bullet*>::iterator b = bulletArray.begin(); b != bulletArray.end(); b++){
        Bullet * bullet = *b;
        CIwArray<Enemy*> & enemyArray = rM.getEnemies();
        for (CIwArray<Enemy*>::iterator en = enemyArray.begin(); en != enemyArray.end(); en++){
            Enemy * enemy = *en;
            if(hitTest(* bullet, * enemy)){
                bullet->remove = true;
                enemy->damageTaken = true;
                if(enemy->health <= 0){
                    enemy->remove = true;
                }
            }
        }
    }
    
    
    /****
     DELETE ENTITIES SET TO REMOVE
     ****/
    CIwArray<Entity*> & entites = rM.getEntities();
    CIwArray<Entity*>::iterator it = entites.begin();
    //if we are removing elements, we need to be careful with the iterator!
    while(it != entites.end()){
        Entity * e = *it;
        if( e->remove || (not inbounds(* e))){
            rM.remove(e);
        } else {
            ++it;
        }
    }
}
Exemple #25
0
void DrawYp(int y)
{
	int i=(manX-manY+9)*16;
	for(float j=(manX+manY)*8;j<=(manX+y)*8;j++)
	{
		j=j-0.5;
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		i--;
	}
}
Exemple #26
0
void DrawYm(int y)
{
	int i=(manX-manY+9)*16;
	for(float j=(manX+manY)*8;j>=(manX+y)*8;j--)
	{
		j=j+0.5;
		DrawMap(manX,manY);
		Iw2DDrawImage(man,CIwFVec2(i,j));
		Iw2DSurfaceShow();
		i++;
	}
}
Exemple #27
0
Unit::Unit(float hp, float cost, float attack, float speed, 
		float munch_speed, float range, float sight,
		float spread_speed, float spread_radius, Player* owner,
		Game* game)
		: WorldObject(game),
		  hp(hp), cost(cost), attackDamage(attack), speed(speed),
		  munch_speed(munch_speed), range(range), sight(sight),
		  spread_speed(spread_speed), spread_radius(spread_radius),
		  curFrame(0), target(NULL), navTarget(CIwFVec2(0, 0)), repulsion_factor(1)
{
    setOwner(owner);
}
void GameplayState::SpawnCharacters()
{
	// Dave (big), Nigel (small), Mandy (girl)
	characters[DAVE] = new Sprite("dave_anim", true, CIwFVec2(6,1));
	characters[DAVE]->SetCenter(CIwSVec2((int16)characters[DAVE]->GetWidth() /2 , (int16)characters[DAVE]->GetHeight() /2));
	characters[DAVE]->SetPosition(m_Level->GetSpawnPositions().at(DAVE));
	characters[DAVE]->SetMovSpeed(CIwFVec2(1.5,5)); // Moves 1.5 units fast in the x axis (slow)
	
	characters[NIGEL] = new Sprite("nigel_anim", true, CIwFVec2(6,1));
	characters[NIGEL]->SetCenter(CIwSVec2((int16)characters[NIGEL]->GetWidth() /2, (int16)characters[NIGEL]->GetHeight() /2));
	characters[NIGEL]->SetPosition(m_Level->GetSpawnPositions().at(NIGEL));
	characters[NIGEL]->SetMovSpeed(CIwFVec2(3,3)); // Moves 3 units fast in the x axis (fastest)

	characters[MANDY] = new Sprite("mandy_anim", true, CIwFVec2(6,1));
	characters[MANDY]->SetCenter(CIwSVec2((int16)characters[MANDY]->GetWidth() /2, (int16)characters[MANDY]->GetHeight() /2));
	characters[MANDY]->SetPosition(m_Level->GetSpawnPositions().at(MANDY));
	characters[MANDY]->SetMovSpeed(CIwFVec2(2,2)); // Moves 2 units fast in the x axis (faster than dave, slower than nigel)

	m_PortraitSounds[DAVE] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("dave_selected", "CIwSoundSpec"));
	m_PortraitSounds[NIGEL] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("nigel_selected", "CIwSoundSpec"));
	m_PortraitSounds[MANDY] = static_cast<CIwSoundSpec*>(IwGetResManager()->GetResNamed("mandy_selected", "CIwSoundSpec"));

	for (int i = 0; i < 3; i++)
	{
//		characters[i]->ShowColliderPos = true;
	}

	characters[DAVE]->Debug_PrintPos();

}
Exemple #29
0
void Map::Init()
{
	_blocked=false;
	mazeFinished=0;
	m_Position=CIwFVec2(_StartPos[0]*_tileWidth-Iw2DGetSurfaceWidth()/2.0f,_StartPos[1]*_tileHeight-Iw2DGetSurfaceHeight()/2.0f);
	m_tileRotating=false;
	_TileDir.clear();
	
	for(int i=0;i!=_total;i++)
	{
		_TileDir.append(0);
	}
}
void GameplayState::CheckObjects(const int &pCharacter)
{
	for (size_t m = 0; m < m_Level->GetObjects().size(); m++)
	{
		GameObject *t = m_Level->GetObjects().at(m);
		if (characters[pCharacter]->isColliding(t, CIwFVec2(0,0)))
		{
			if (characters[pCharacter]->isColliding(t, CIwFVec2(0,0)))
			{
				if (t->GetType() == Door)
				{
					if (t->IsActive)
					{
						if (doorSoundInst == NULL)
							doorSoundInst = doorSound->Play();
						else
						{
							if (!doorSoundInst->IsPlaying())
								doorSound->Play();
						}

						characters[pCharacter]->MoveBy(-characters[pCharacter]->GetLastMovement(),0);
						if (pCharacter == NIGEL) // If nigel is being thrown, he needs to stop as the force of the throw will be greater than the inverse movement value
						{
							if (m_isThrowing)
							{
								m_canThrow = false;
								m_isThrowing = false;
							}
						}

						if (pCharacter == MANDY) // If mandy is jumping and colliding with a door, she should not be allowed to jump again until she lands on the floor
							characters[MANDY]->TEMP_JUSTJUMPED = false;
					}
				}
			}
		}
	}
}