1 Commits

Author SHA1 Message Date
05bb79d4a9 Add CI (#3)
All checks were successful
Linux arm64 / Build (push) Successful in 1m56s
Reviewed-on: #3
Co-authored-by: Persson-dev <sim16.prib@gmail.com>
Co-committed-by: Persson-dev <sim16.prib@gmail.com>
2025-05-24 10:59:12 +00:00
6 changed files with 62 additions and 103 deletions

36
.github/workflows/ubuntu.yml vendored Normal file
View 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

View File

@@ -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 {
float sizeMultiplier = this->settings->getWindowSizeMultiplier();

View File

@@ -10,13 +10,12 @@
InfoAppMenu::InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
AppMenu(menuStack, settings, renderWindow),
playerCursor({INFO_SECTIONS_COUNT}),
playerCursor({4}),
sectionsName(
"< ABOUT >",
"< PIECES TYPES >",
"< 0 DEGREES ROTATIONS >",
"< ROTATION SYSTEM >",
"< SCORING >"
"< SCORING >",
"< 0 DEGREES ROTATIONS >"
),
sectionsContent(
"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"
"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"
"Rotation Sytem, called AutoRS.\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"
"A spin is detected when the piece is\n"
"locked in place, a mini-spin simply\n"
"when the last move was a kick."
),
sectionNameText(this->createText()),
sectionContentText(this->createText()),
renderTexture(this->renderWindow->getSize()),
sprite(this->renderTexture.getTexture()) {
"when the last move was a kick.",
this->setTextOutline(this->sectionNameText, true);
this->sectionContentText.setLineSpacing((float) this->settings->getWindowSizeMultiplier() / 8);
"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->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() {
this->updateMetaBinds();
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) {
this->menuStack->pop();
}
@@ -116,7 +73,15 @@ void InfoAppMenu::computeFrame() {
void InfoAppMenu::drawFrame() const {
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();
}

View File

@@ -7,18 +7,12 @@
#include <memory>
#include <SFML/Graphics.hpp>
static const int INFO_SECTIONS_COUNT = 5;
class InfoAppMenu : public AppMenu {
private:
PlayerCursor playerCursor;
sf::String sectionsName[INFO_SECTIONS_COUNT];
sf::String sectionsContent[INFO_SECTIONS_COUNT];
sf::Text sectionNameText;
sf::Text sectionContentText;
sf::RenderTexture renderTexture;
sf::Sprite sprite;
sf::String sectionsName[4];
sf::String sectionsContent[4];
public:
InfoAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);

View File

@@ -42,13 +42,6 @@ void PlayerCursor::updatePosition() {
}
}
bool PlayerCursor::moved() const {
return (this->movedLeft()
|| this->movedRight()
|| this->movedUp()
|| this->movedDown());
}
bool PlayerCursor::movedLeft() const {
return this->shouldMove(this->leftDAS);
}
@@ -122,7 +115,7 @@ const sf::Vector2u& PlayerCursor::getPosition() const {
bool PlayerCursor::shouldMove(int DAS) const {
return (DAS == 1
|| (DAS > MENU_DAS && (DAS % 5) == 0)
|| (DAS > (MENU_DAS * 4)));
|| (DAS > (FRAMES_PER_SECOND * 2)));
}
void PlayerCursor::moveLeft() {

View File

@@ -18,8 +18,6 @@ class PlayerCursor {
void updatePosition();
bool moved() const;
bool movedLeft() const;
bool movedRight() const;