-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new top down screen implementation.
- Loading branch information
Showing
7 changed files
with
90 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "playerInfo.h" | ||
#include "gameGlobalInfo.h" | ||
#include "topDownScreen.h" | ||
#include "main.h" | ||
#include "menus/shipSelectionScreen.h" | ||
|
||
#include "screenComponents/indicatorOverlays.h" | ||
|
||
TopDownScreen::TopDownScreen() | ||
{ | ||
viewport = new GuiViewport3D(this, "VIEWPORT"); | ||
viewport->showCallsigns(); | ||
viewport->setPosition(0, 0, ATopLeft)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); | ||
|
||
new GuiIndicatorOverlays(this); | ||
} | ||
|
||
void TopDownScreen::update(float delta) | ||
{ | ||
camera_yaw = -90.0f; | ||
camera_pitch = 90.0f; | ||
|
||
camera_position.z = 7000.0; | ||
|
||
if (!target) | ||
{ | ||
for(int n=0; n<GameGlobalInfo::max_player_ships; n++) | ||
{ | ||
target = gameGlobalInfo->getPlayerShip(n); | ||
if (target) | ||
break; | ||
} | ||
} | ||
|
||
if (target) | ||
{ | ||
sf::Vector2f position = target->getPosition(); | ||
|
||
camera_position.x = position.x; | ||
camera_position.y = position.y; | ||
} | ||
} | ||
|
||
void TopDownScreen::onKey(sf::Keyboard::Key key, int unicode) | ||
{ | ||
switch(key) | ||
{ | ||
//TODO: This is more generic code and is duplicated. | ||
case sf::Keyboard::Escape: | ||
case sf::Keyboard::Home: | ||
destroy(); | ||
new ShipSelectionScreen(); | ||
break; | ||
case sf::Keyboard::P: | ||
if (game_server) | ||
engine->setGameSpeed(0.0); | ||
break; | ||
default: | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef TOP_DOWN_SCREEN_H | ||
#define TOP_DOWN_SCREEN_H | ||
|
||
#include "engine.h" | ||
#include "gui/gui2.h" | ||
#include "screenComponents/viewport3d.h" | ||
#include "screenComponents/radarView.h" | ||
|
||
class TopDownScreen : public GuiCanvas, public Updatable | ||
{ | ||
private: | ||
GuiViewport3D* viewport; | ||
P<SpaceObject> target; | ||
public: | ||
TopDownScreen(); | ||
|
||
virtual void update(float delta); | ||
|
||
virtual void onKey(sf::Keyboard::Key key, int unicode); | ||
}; | ||
|
||
#endif//TOP_DOWN_SCREEN_H |