Ejemplo n.º 1
0
	void StateGameMode::Draw(){


		GetMap()->DrawMap();

		player1_->DrawObject();
	
		al_draw_rectangle(GetMouseCursorX(),GetMouseCursorY(),GetMouseCursorX()+Constants::TileSize,GetMouseCursorY()+Constants::TileSize, al_map_rgb_f(0,0,0),2);//1
	}
Ejemplo n.º 2
0
	void StateEditorMode::Draw(){


		GetMap()->DrawMap();


		editorOverLayController_->Draw();


		al_draw_rectangle(GetMouseCursorX(),GetMouseCursorY(),GetMouseCursorX()+Constants::TileSize,GetMouseCursorY()+Constants::TileSize, al_map_rgb_f(0,0,0),2);//1
	}
Ejemplo n.º 3
0
	void StateEditorMode::EditorModeMouseActivity()
	{
		if(GetEvent()->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
		{
			switch(GetEvent()->mouse.button)
			{
				case 1:
					SetLeftMouseDown(true);
					break;
				case 2:
					SetRightMouseDown(true);
					SetRightMousePos(GetMouseCursorX(),GetMouseCursorY());
					GetMap()->SetOldMapXOffset(GetMap()->GetMapXOffset());
					GetMap()->SetOldMapYOffset(GetMap()->GetMapYOffset());
					
					break;
			}
		}
		if(GetEvent()->type == ALLEGRO_EVENT_MOUSE_BUTTON_UP)
		{
			switch(GetEvent()->mouse.button)
			{
				case 1:
					SetLeftMouseDown(false);
					break;
				case 2:
					SetRightMouseDown(false);
					break;
			}
		}
	}
Ejemplo n.º 4
0
	void StateEditorMode::MouseActivity(){


		if(GetEvent()->type == ALLEGRO_EVENT_MOUSE_AXES)
		{			
			SetMouseCursorPos(GetEvent()->mouse.x-10,GetEvent()->mouse.y-10);
		}


		//If the editor overlay didnt take control of mouse activity let editor mode handle it
		if(!editorOverLayController_->MouseActivity(GetEvent(), GetMouseCursorX(),GetMouseCursorY()))
		{
			EditorModeMouseActivity();
		}
		else
		{
			selectedTile_  = editorOverLayController_->GetSelectedObject();
		}


	}
Ejemplo n.º 5
0
	void StateEditorMode::DragMap()
	{
		GetMap()->SetMapXOffset(GetMap()->GetOldMapXOffset() + (GetMouseCursorX())-(GetRightMouseX()));
		GetMap()->SetMapYOffset(GetMap()->GetOldMapYOffset() + (GetMouseCursorY())-(GetRightMouseY()));
	}
Ejemplo n.º 6
0
	void StateEditorMode::Update(){
		if(GetRightMouseDown())
		{
			DragMap();
		}

		if(GetLeftMouseDown())
		{
			if(selectedTile_.second != nullptr)
			{
				int mapSizeX = GetMap()->GetTiles().size();
				int mapSizeY = GetMap()->GetTiles()[0].size();
				int tileXPos = (GetMouseCursorX() - GetMap()->GetMapXOffset() + Constants::TileSize/2)/Constants::TileSize;
				int tileYPos = (GetMouseCursorY() - GetMap()->GetMapYOffset() + Constants::TileSize/2)/Constants::TileSize;
				if(tileXPos >= 0 && 
					tileXPos < mapSizeX &&
					tileYPos >= 0 && 
					tileYPos < mapSizeY)
				{
					if(selectedTile_.first == EnumDLL::STATES::TILEIMAGEPICKER)
					{
						if(selectedTile_.second->GetObjectImage()->GetId() == 0)
						{
							GetMap()->GetTiles()[tileXPos][tileYPos].RemoveImage();
						}
						else
						{
							GetMap()->GetTiles()[tileXPos][tileYPos].SetTileProperties(selectedTile_.second);
						}
					}
					else if(selectedTile_.first == EnumDLL::STATES::TILECOLORPICKER)
					{
						if(selectedTile_.second->GetObjectImage() != nullptr)
						{
							if(selectedTile_.second->GetObjectImage()->GetId() == 0)
							{
								GetMap()->GetTiles()[tileXPos][tileYPos].RemoveColor();
							}
						}
						else
						{
							GetMap()->GetTiles()[tileXPos][tileYPos].SetTileProperties(selectedTile_.second);
						}
					}
					else if(selectedTile_.first == EnumDLL::STATES::TILETYPEPICKER)
					{
						GetMap()->GetTiles()[tileXPos][tileYPos].SetTileTypeProperties(selectedTile_.second);
					}



				}
			}
		}


		if(GetEvent()->type == ALLEGRO_EVENT_TIMER)
		{			
			GetMap()->PreCalc();
			//Update overlay. Will return with no actions if action state of it is NONE.
			editorOverLayController_->Update();
			SetRedraw(true);
		}


	}