Beispiel #1
0
C_Player1::C_Player1()
{
	//FLAGS
	BitManip.Set_bit(m_flags, ENTITY_PLAYER_TYPE, ON);//ONLY USE 'g_entityFlags' FROM CONFIG

	//Init stuff
	Set_X(256);
	Set_Y(721);
	Set_xvel(0);
	Set_yvel(0);
	Set_xSpeed(0);
	Set_ySpeed(0);
	Set_gravityOffset(0);
	Set_hitPoints(5);
	Set_flags(0);
	m_fixedXvel = .4;
	m_fixedYvel = .4;
	m_xMaxSpeed = 2;
	m_yMaxSpeed = 2;

	m_hitPoints = 100;
	m_takingDamage = false;
	damagedTimePassed = 0;

	m_lockControls = false;//can move by default


	PlayerTimer.start();

	Weapons.clear();//wtf why needed
}
Beispiel #2
0
void Boss::Init()
{
	Set_X(Boss_X);
	Set_Y(Boss_Y);
	Set_HP(Boss_HP);
	Set_Have_Bomb(true);
}
Beispiel #3
0
Monster::Monster(int x, int y)
{
	Set_X(x);
	Set_Y(y);
	Set_Shape(MONSTER_EMPTY);
	Set_Type(T_monster);
	Set_Frame_Cnt(0);
	Have_Bomb = false;
}
Beispiel #4
0
Boss::Boss(int x, int y)
{
	Set_X(x);
	Set_Y(y);
	Set_Shape(BOSS_EMPTY);
	Set_Type(T_boss);
	Set_Frame_Cnt(0);
	Set_Have_Bomb(true);
}
Beispiel #5
0
void Monster::Rand_Move()
{
	int idx[4] = { -1,0,1,0 };
	int idy[4] = { 0,-1,0,1 };
	int rand_dir = Singleton::getSingleton().Rand_Dir();
	int temp = Singleton::getSingleton().Search(Get_X() + idx[rand_dir], Get_Y() + idy[rand_dir]);

	if (temp == -1) Set_X(Get_X() + idx[rand_dir]), Set_Y(Get_Y() + idy[rand_dir]);
	else if (Singleton::getSingleton().obj_list[temp]->Get_Type() == T_item)
	{
		Set_X(Get_X() + idx[rand_dir]), Set_Y(Get_Y() + idy[rand_dir]);
		Singleton::getSingleton().Delete(temp);
		Set_Have_Bomb(true);
	}
	else
	{
		bool Is_Move = false;
		for (int i = 0; i < 4; i++)if (Singleton::getSingleton().Search(Get_X() + idx[i], Get_Y() + idy[i]) == -1)Is_Move = true;
		if (Is_Move) Rand_Move();
	}
}
Beispiel #6
0
void Boss::Boss_Init()
{
	Set_X(Boss_X);
	Set_Y(Boss_Y);
	Set_HP(Boss_HP);
}
Beispiel #7
0
void C_Player1::Move()
{
	//MOVE PLAYER/////////////////////
	

	//LIMITS to keep things from getting stupid
	if(Get_xSpeed() > m_xMaxSpeed)
		Set_xSpeed(m_xMaxSpeed);
	if(Get_xSpeed() < -m_xMaxSpeed)
		Set_xSpeed(-m_xMaxSpeed);

	if(Get_ySpeed() > m_yMaxSpeed)
		Set_ySpeed(m_yMaxSpeed);
	if(Get_ySpeed() < -m_yMaxSpeed)
		Set_ySpeed(-m_yMaxSpeed);

	//Update the position TODO: Make variable 'requested position' for future collision checking
	Set_X(Get_X() + Get_xSpeed());
	Set_Y(Get_Y() + Get_ySpeed());

	//Window collision
	if(Get_X() + Get_xSpeed() < 0)
		Set_X(0);
	if(Get_X() + Get_xSpeed() > LEVEL_WIDTH - PLAYER_WIDTH)//factor in player height/width TODO
		m_X = (m_X - m_xSpeed);
	if(Get_Y() + Get_ySpeed() < 0)
		Set_Y(0);
	if(Get_Y() + Get_ySpeed() > LEVEL_HEIGHT - PLAYER_HEIGHT)
		m_Y = (m_Y - m_ySpeed);
	 
	//If there's a sword swing, move the shield
	for(int i = 0; i < Weapons.size(); i++)
		if(Weapons[i]->Get_weaponType() == SWORD)//if sword found
			Controls.key_S = true;//simulate shield



				

	//***************************************************ZONING STUFF /Scroll the screen and load in new zones when player hits an edge
			//  16 X 8  sized map!!!!


	if(m_Y < 10 && TileManager.Get_transitionDirection() == -1)//ZONE UP if not already zoning  // THE -1 means no transition is happening
		if(TileManager.Get_mapPosition().y != 1){//if not at the top
			TileManager.MapTransition(UP);	
			SDL_Rect updateMapPosition = {TileManager.Get_mapPosition().x, TileManager.Get_mapPosition().y - 1};
			TileManager.Set_mapPosition(updateMapPosition);
		}
	if(m_Y > 930 && TileManager.Get_transitionDirection() == -1)//ZONE DOWN if not already zoning
		if(TileManager.Get_mapPosition().y != 4){//if not at the bottom (16 x 8 map)
			TileManager.MapTransition(DOWN);	
			SDL_Rect updateMapPosition = {TileManager.Get_mapPosition().x, TileManager.Get_mapPosition().y + 1};
			TileManager.Set_mapPosition(updateMapPosition);
		}
	if(m_X < 10 && TileManager.Get_transitionDirection() == -1)//zone LEFT if not already zoning
		if(TileManager.Get_mapPosition().x != 1){//if not at far left
			TileManager.MapTransition(LEFT);	
			SDL_Rect updateMapPosition = {TileManager.Get_mapPosition().x - 1, TileManager.Get_mapPosition().y};
			TileManager.Set_mapPosition(updateMapPosition);
		}
	if(m_X > 1250 && TileManager.Get_transitionDirection() == -1)//zone RIGHT if not already zoning
		if(TileManager.Get_mapPosition().x != 8){//if not at far right
			TileManager.MapTransition(RIGHT);
			SDL_Rect updateMapPosition = {TileManager.Get_mapPosition().x + 1, TileManager.Get_mapPosition().y};
			TileManager.Set_mapPosition(updateMapPosition);
		}


	if(TileManager.Get_transitionDirection() == UP){
		m_Y = TileManager.Get_offsetCounterY();
		if(m_Y > SCREEN_HEIGHT - PLAYER_HEIGHT )//keep player from going into another transition
			m_Y = LEVEL_HEIGHT - PLAYER_HEIGHT - 11;
	}
	if(TileManager.Get_transitionDirection() == DOWN){
		m_Y = LEVEL_HEIGHT + TileManager.Get_offsetCounterY();
		if(m_Y < LEVEL_HEIGHT - SCREEN_HEIGHT + PLAYER_HEIGHT/2)
			m_Y = 11;
	}
	if(TileManager.Get_transitionDirection() == LEFT){
		m_X = TileManager.Get_offsetCounterX();
		if(m_X > SCREEN_WIDTH - PLAYER_WIDTH/2)
			m_X = LEVEL_WIDTH - PLAYER_WIDTH -11;
	}
	if(TileManager.Get_transitionDirection() == RIGHT){
		m_X = LEVEL_WIDTH + TileManager.Get_offsetCounterX();
		if(m_X < LEVEL_WIDTH - SCREEN_WIDTH + PLAYER_WIDTH/3)
			m_X = 11;
	}
	

}