Compare commits
1 Commits
optimizing
...
05bb79d4a9
| Author | SHA1 | Date | |
|---|---|---|---|
| 05bb79d4a9 |
36
.github/workflows/ubuntu.yml
vendored
Normal file
36
.github/workflows/ubuntu.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Linux arm64
|
||||||
|
run-name: Build And Test
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
|
||||||
|
env:
|
||||||
|
XMAKE_ROOT: y
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare XMake
|
||||||
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: latest
|
||||||
|
actions-cache-folder: '.xmake-cache'
|
||||||
|
actions-cache-key: 'ubuntu'
|
||||||
|
|
||||||
|
- name: Install SFML
|
||||||
|
run: |
|
||||||
|
apt update
|
||||||
|
apt install -y libsfml-dev
|
||||||
|
|
||||||
|
- name: XMake config
|
||||||
|
run: xmake f -p linux -y
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: xmake
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: xmake test
|
||||||
@@ -57,33 +57,6 @@ class AppMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Text createText(int fontSize = 2) const {
|
|
||||||
sf::Text newText(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * fontSize);
|
|
||||||
newText.setFillColor(sf::Color::Black);
|
|
||||||
newText.setOutlineColor(sf::Color::White);
|
|
||||||
newText.setOutlineThickness(0);
|
|
||||||
|
|
||||||
return newText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTextPosition(sf::Text& text, float xPos, float yPos) const {
|
|
||||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
|
||||||
|
|
||||||
text.setOrigin(sf::Vector2f({0, text.getLocalBounds().size.y / 2}));
|
|
||||||
text.setPosition(sf::Vector2f({sizeMultiplier * xPos, sizeMultiplier * yPos}));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTitlePosition(sf::Text& text, float yPos) const {
|
|
||||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
|
||||||
|
|
||||||
text.setOrigin({text.getLocalBounds().getCenter().x, text.getLocalBounds().size.y / 2});
|
|
||||||
text.setPosition(sf::Vector2f({sizeMultiplier * 40.f, sizeMultiplier * yPos}));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTextOutline(sf::Text& text, bool hasOutline) const {
|
|
||||||
text.setOutlineThickness(hasOutline * (this->settings->getWindowSizeMultiplier() / 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
void placeText(sf::Text& text, const std::optional<PlayerCursor>& playerCursor, const sf::String& string, float xPos, float yPos, const std::optional<sf::Vector2u>& cursorPos) const {
|
void placeText(sf::Text& text, const std::optional<PlayerCursor>& playerCursor, const sf::String& string, float xPos, float yPos, const std::optional<sf::Vector2u>& cursorPos) const {
|
||||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,12 @@
|
|||||||
|
|
||||||
InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
|
InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
|
||||||
AppMenu(menuStack, settings, renderWindow),
|
AppMenu(menuStack, settings, renderWindow),
|
||||||
playerCursor({INFO_SECTIONS_COUNT}),
|
playerCursor({4}),
|
||||||
sectionsName(
|
sectionsName(
|
||||||
"< ABOUT >",
|
"< ABOUT >",
|
||||||
"< PIECES TYPES >",
|
|
||||||
"< 0 DEGREES ROTATIONS >",
|
|
||||||
"< ROTATION SYSTEM >",
|
"< ROTATION SYSTEM >",
|
||||||
"< SCORING >"
|
"< SCORING >",
|
||||||
|
"< 0 DEGREES ROTATIONS >"
|
||||||
),
|
),
|
||||||
sectionsContent(
|
sectionsContent(
|
||||||
"This game is written in C++,\n"
|
"This game is written in C++,\n"
|
||||||
@@ -28,25 +27,6 @@ InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<S
|
|||||||
"to them in any ways.\n"
|
"to them in any ways.\n"
|
||||||
"Current version: beta.",
|
"Current version: beta.",
|
||||||
|
|
||||||
"There is multiple pieces type in\n"
|
|
||||||
"the selection screen. Use theses\n"
|
|
||||||
"categories for size of at least 7.\n"
|
|
||||||
"Convex, Holeless and Others are\n"
|
|
||||||
"all mutually exclusive.\n"
|
|
||||||
"Others have holes inside them, and\n"
|
|
||||||
"Convex are presumably easier to\n"
|
|
||||||
"play with than Holeless.",
|
|
||||||
|
|
||||||
"This games introduces 0 degrees\n"
|
|
||||||
"rotations, which work by simpling\n"
|
|
||||||
"moving the piece down and kicking\n"
|
|
||||||
"it as is, allowing for new kinds\n"
|
|
||||||
"of kicks.\n"
|
|
||||||
"As a leniency mechanic, when a\n"
|
|
||||||
"piece spawns it will automatically\n"
|
|
||||||
"try a 0 degrees rotations if it\n"
|
|
||||||
"spawned inside a wall.",
|
|
||||||
|
|
||||||
"This game uses its own\n"
|
"This game uses its own\n"
|
||||||
"Rotation Sytem, called AutoRS.\n"
|
"Rotation Sytem, called AutoRS.\n"
|
||||||
"The rotation center is always the\n"
|
"The rotation center is always the\n"
|
||||||
@@ -66,48 +46,25 @@ InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<S
|
|||||||
"and doubles the score gained.\n"
|
"and doubles the score gained.\n"
|
||||||
"A spin is detected when the piece is\n"
|
"A spin is detected when the piece is\n"
|
||||||
"locked in place, a mini-spin simply\n"
|
"locked in place, a mini-spin simply\n"
|
||||||
"when the last move was a kick."
|
"when the last move was a kick.",
|
||||||
),
|
|
||||||
sectionNameText(this->createText()),
|
|
||||||
sectionContentText(this->createText()),
|
|
||||||
renderTexture(this->renderWindow->getSize()),
|
|
||||||
sprite(this->renderTexture.getTexture()) {
|
|
||||||
|
|
||||||
this->setTextOutline(this->sectionNameText, true);
|
"This games introduces 0 degrees\n"
|
||||||
|
"rotations, which work by simpling\n"
|
||||||
this->sectionContentText.setLineSpacing((float) this->settings->getWindowSizeMultiplier() / 8);
|
"moving the piece down and kicking\n"
|
||||||
|
"it as is, allowing for new kinds\n"
|
||||||
|
"of kicks.\n"
|
||||||
|
"As a leniency mechanic, when a\n"
|
||||||
|
"piece spawns it will automatically\n"
|
||||||
|
"try a 0 degrees rotations if it\n"
|
||||||
|
"spawned inside a wall."
|
||||||
|
) {
|
||||||
|
|
||||||
this->sectionNameText.setString(this->sectionsName[this->playerCursor.getPosition().x]);
|
|
||||||
this->setTitlePosition(this->sectionNameText, 10.f);
|
|
||||||
|
|
||||||
this->sectionContentText.setString(this->sectionsContent[this->playerCursor.getPosition().x]);
|
|
||||||
this->setTextPosition(this->sectionContentText, 5.f, 30.f);
|
|
||||||
|
|
||||||
this->renderTexture.clear(sf::Color(200, 200, 200));
|
|
||||||
this->renderTexture.draw(this->sectionNameText);
|
|
||||||
this->renderTexture.draw(this->sectionContentText);
|
|
||||||
this->renderTexture.display();
|
|
||||||
this->sprite.setTexture(this->renderTexture.getTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoAppMenu::computeFrame() {
|
void InfoAppMenu::computeFrame() {
|
||||||
this->updateMetaBinds();
|
this->updateMetaBinds();
|
||||||
this->playerCursor.updatePosition();
|
this->playerCursor.updatePosition();
|
||||||
|
|
||||||
if (this->playerCursor.movedLeft() || this->playerCursor.movedRight()) {
|
|
||||||
this->sectionNameText.setString(this->sectionsName[this->playerCursor.getPosition().x]);
|
|
||||||
this->setTitlePosition(this->sectionNameText, 10.f);
|
|
||||||
|
|
||||||
this->sectionContentText.setString(this->sectionsContent[this->playerCursor.getPosition().x]);
|
|
||||||
this->setTextPosition(this->sectionContentText, 5.f, 30.f);
|
|
||||||
|
|
||||||
this->renderTexture.clear(sf::Color(200, 200, 200));
|
|
||||||
this->renderTexture.draw(this->sectionNameText);
|
|
||||||
this->renderTexture.draw(this->sectionContentText);
|
|
||||||
this->renderTexture.display();
|
|
||||||
this->sprite.setTexture(this->renderTexture.getTexture());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->escReleased) {
|
if (this->escReleased) {
|
||||||
this->menuStack->pop();
|
this->menuStack->pop();
|
||||||
}
|
}
|
||||||
@@ -116,7 +73,15 @@ void InfoAppMenu::computeFrame() {
|
|||||||
void InfoAppMenu::drawFrame() const {
|
void InfoAppMenu::drawFrame() const {
|
||||||
this->renderWindow->clear(sf::Color(200, 200, 200));
|
this->renderWindow->clear(sf::Color(200, 200, 200));
|
||||||
|
|
||||||
this->renderWindow->draw(sprite);
|
sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2);
|
||||||
|
text.setFillColor(sf::Color(0, 0, 0));
|
||||||
|
text.setOutlineColor(sf::Color(255, 255, 255));
|
||||||
|
|
||||||
|
this->placeTitle(text, this->playerCursor, this->sectionsName[this->playerCursor.getPosition().x], 10.f, this->playerCursor.getPosition());
|
||||||
|
|
||||||
|
text.setLineSpacing((float) this->settings->getWindowSizeMultiplier() / 8);
|
||||||
|
text.setOutlineThickness(0);
|
||||||
|
this->placeText(text, {}, this->sectionsContent[this->playerCursor.getPosition().x], 5.f, 30.f, {});
|
||||||
|
|
||||||
this->renderWindow->display();
|
this->renderWindow->display();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
static const int INFO_SECTIONS_COUNT = 5;
|
|
||||||
|
|
||||||
|
|
||||||
class InfoAppMenu : public AppMenu {
|
class InfoAppMenu : public AppMenu {
|
||||||
private:
|
private:
|
||||||
PlayerCursor playerCursor;
|
PlayerCursor playerCursor;
|
||||||
sf::String sectionsName[INFO_SECTIONS_COUNT];
|
sf::String sectionsName[4];
|
||||||
sf::String sectionsContent[INFO_SECTIONS_COUNT];
|
sf::String sectionsContent[4];
|
||||||
sf::Text sectionNameText;
|
|
||||||
sf::Text sectionContentText;
|
|
||||||
sf::RenderTexture renderTexture;
|
|
||||||
sf::Sprite sprite;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);
|
InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ void PlayerCursor::updatePosition() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerCursor::moved() const {
|
|
||||||
return (this->movedLeft()
|
|
||||||
|| this->movedRight()
|
|
||||||
|| this->movedUp()
|
|
||||||
|| this->movedDown());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlayerCursor::movedLeft() const {
|
bool PlayerCursor::movedLeft() const {
|
||||||
return this->shouldMove(this->leftDAS);
|
return this->shouldMove(this->leftDAS);
|
||||||
}
|
}
|
||||||
@@ -122,7 +115,7 @@ const sf::Vector2u& PlayerCursor::getPosition() const {
|
|||||||
bool PlayerCursor::shouldMove(int DAS) const {
|
bool PlayerCursor::shouldMove(int DAS) const {
|
||||||
return (DAS == 1
|
return (DAS == 1
|
||||||
|| (DAS > MENU_DAS && (DAS % 5) == 0)
|
|| (DAS > MENU_DAS && (DAS % 5) == 0)
|
||||||
|| (DAS > (MENU_DAS * 4)));
|
|| (DAS > (FRAMES_PER_SECOND * 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerCursor::moveLeft() {
|
void PlayerCursor::moveLeft() {
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ class PlayerCursor {
|
|||||||
|
|
||||||
void updatePosition();
|
void updatePosition();
|
||||||
|
|
||||||
bool moved() const;
|
|
||||||
|
|
||||||
bool movedLeft() const;
|
bool movedLeft() const;
|
||||||
|
|
||||||
bool movedRight() const;
|
bool movedRight() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user