fixed quickwings, added me to readme, fixed readme

This commit is contained in:
_brxxh 2023-11-23 17:49:07 +01:00
parent b9c7ce3b48
commit 2a42731628
8 changed files with 94 additions and 66 deletions

View file

@ -1,40 +1,41 @@
# ParadiSO - eine minimale 2D-Grafikengine # ParadiSO - eine minimale 2D-Grafikengine
**ParadiSO** wurde als stark abgespeckte 2D-Version meiner `pixwerx`-Engine konzipiert. *ParadiSO* verfolgt einen minimalistischen Ansatz f<>r 2D-Grafik zu Bildungszwecken. Es verwendet modernes C++ und ein datengetriebenes Design, jedoch keine ECS (Entity Component System). **ParadiSO** wurde als stark abgespeckte 2D-Version meiner `pixwerx`-Engine konzipiert. _ParadiSO_ verfolgt einen minimalistischen Ansatz für 2D-Grafik zu Bildungszwecken. Es verwendet modernes C++ und ein datengetriebenes Design, jedoch keine ECS (Entity Component System).
## Bildungszwecke ## Bildungszwecke
Einige Argumente f<EFBFBD>r seinen Bildungsaspekt: Einige Argumente für seinen Bildungsaspekt:
- Kombination verschiedener Konzepte und Paradigmen zur Erstellung ausdrucksstarker, aber knappen Codes - Kombination verschiedener Konzepte und Paradigmen zur Erstellung ausdrucksstarker, aber knappen Codes
- Stark von Rust-Code inspiriert - Stark von Rust-Code inspiriert
- F<EFBFBD>r den mathematischen Code wird eine sofortige Auswertung verwendet (keine Expression-Templates), jedoch mit der Verwendung von `constexpr`, um eventuelle Performance-Overheads auszugleichen und optimale Vektorisierung zu erreichen. - r den mathematischen Code wird eine sofortige Auswertung verwendet (keine Expression-Templates), jedoch mit der Verwendung von `constexpr`, um eventuelle Performance-Overheads auszugleichen und optimale Vektorisierung zu erreichen.
- Versteckt alte `C`-APIs hinter einer modernisierten Fassade - Versteckt alte `C`-APIs hinter einer modernisierten Fassade
- Es lehnt sich stark an die STL und ihre Algorithmen an - Es lehnt sich stark an die STL und ihre Algorithmen an
## Minimalistisch ## Minimalistisch
Da diese Engine einige Muster und Designkonzepte zeigen soll, versucht sie, unn<EFBFBD>tigen Ballast zu vermeiden. Da diese Engine einige Muster und Designkonzepte zeigen soll, versucht sie, unnötigen Ballast zu vermeiden.
## Abh<EFBFBD>ngigkeiten ## Abhängigkeiten
ParadiSO wird mit den notwendigen Komponenten geliefert. Diese sollte jedoch hier erw<EFBFBD>hnt werden: ParadiSO wird mit den notwendigen Komponenten geliefert. Diese sollte jedoch hier erwähnt werden:
- [GLFW 3.3.8](https://github.com/glfw/glfw) - [GLFW 3.3.8](https://github.com/glfw/glfw)
- [GLAD](https://github.com/Dav1dde/glad) - [GLAD](https://github.com/Dav1dde/glad)
- [STB image](https://github.com/nothings/stb) - [STB image](https://github.com/nothings/stb)
## Toolchains ## Toolchains
ParadiSO kann auf verschiedenen Plattformen gebaut werden ParadiSO kann auf verschiedenen Plattformen gebaut werden
- Windows (Visual Studio Build Tools 2022) - Windows (Visual Studio Build Tools 2022)
- MacOS (clang 14 or later) - MacOS (clang 14 or later)
- Linux (clang 14 or later, gcc 13.2.1) - Linux (clang 14 or later, gcc 13.2.1)
Andere Kombinationen sind möglich aber nicht getestet. Andere Kombinationen sind möglich aber nicht getestet.
## Beitr<EFBFBD>ge ## Beiträge
* [Tim G<>tzelmann](https://code.technotecture.net/Timeplex) Windows Build - [Tim Götzelmann](https://code.technotecture.net/Timeplex) Windows Build
* [Robin Rottst<73>dt](https://code.technotecture.net/robin_rottstaedt) Flappy Bird Clone, Bitmap Loader - [Robin Rottstädt](https://code.technotecture.net/robin_rottstaedt) Flappy Bird Clone, Bitmap Loader
- [brxxh](https://code.technotecture.net/brxxh) Flappy Bird Clone

View file

@ -1,16 +1,16 @@
# ParadiSO - a minimal 2D graphics engine # ParadiSO - a minimal 2D graphics engine
**ParadiSO** was conceived as a heavily stripped down 2D version of my `pixwerx` engine. *ParadiSO* mimics a minimalistic approach to 2D graphics for educational purposes. It uses modern C++ and a data-driven design, but no ECS. **ParadiSO** was conceived as a heavily stripped down 2D version of my `pixwerx` engine. _ParadiSO_ mimics a minimalistic approach to 2D graphics for educational purposes. It uses modern C++ and a data-driven design, but no ECS.
## Educational ## Educational
Some arguments for its educational side: Some arguments for its educational side:
* mix and match of various concepts and paradigms to write expressive but concise code - mix and match of various concepts and paradigms to write expressive but concise code
* heavily inspired by Rust code - heavily inspired by Rust code
* math code is eager evaluation but `constexpr` to compensate overheads - math code is eager evaluation but `constexpr` to compensate overheads
* hides old-style `C` APIs behind a renovated facade - hides old-style `C` APIs behind a renovated facade
* it leans heavily on the STL and its algorithms - it leans heavily on the STL and its algorithms
## Minimal ## Minimal
@ -20,22 +20,22 @@ Because this engine should show some patterns and design concepts it tries to av
ParadiSO comes with batteries included. However, it should be mentioned here: ParadiSO comes with batteries included. However, it should be mentioned here:
- [GLFW 3.3.8](https://github.com/glfw/glfw) - [GLFW 3.3.8](https://github.com/glfw/glfw)
- [GLAD](https://github.com/Dav1dde/glad) - [GLAD](https://github.com/Dav1dde/glad)
- [STB image](https://github.com/nothings/stb) - [STB image](https://github.com/nothings/stb)
## Toolchains ## Toolchains
ParadiSO is being developed to work on all major desktop systems. ParadiSO is being developed to work on all major desktop systems.
- Windows (Visual Studio Build Tools 2022) - Windows (Visual Studio Build Tools 2022)
- MacOS (clang 14 or later) - MacOS (clang 14 or later)
- Linux (clang 14 or later, gcc 13.2.1) - Linux (clang 14 or later, gcc 13.2.1)
Other combinations might work but are untested. Other combinations might work but are untested.
## Contributors ## Contributors
* [Tim Götzelmann](https://code.technotecture.net/Timeplex) Windows Build - [Tim Götzelmann](https://code.technotecture.net/Timeplex) Windows Build
* [Robin Rottstädt](https://code.technotecture.net/robin_rottstaedt) Flappy Bird Clone, Bitmap Loader - [Robin Rottstädt](https://code.technotecture.net/robin_rottstaedt) Flappy Bird Clone, Bitmap Loader
- [brxxh](https://code.technotecture.net/brxxh) Flappy Bird Clone

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,7 +1,7 @@
/** /**
* paradiso - Paradigmen der Softwareentwicklung * paradiso - Paradigmen der Softwareentwicklung
* *
* (c) Copyright 2023 Hartmut Seichter, Robin Rottstädt * (c) Copyright 2023 Hartmut Seichter, Robin Rottstädt, brxxh (Hannes Brothuhn)
* *
*/ */
@ -38,22 +38,22 @@ struct Background {
paradiso::BitmapIO::get().load("background-day.png"); paradiso::BitmapIO::get().load("background-day.png");
backgroundLeft = paradiso::Sprite{ backgroundLeft = paradiso::Sprite{
.bitmap = backgroundImage, .bitmap = backgroundImage,
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f), .pivot = {paradiso::Vector2<float>::make(0.0f, 0.16f)},
.scale = paradiso::Vector2<float>::make(1.01f, 1.0f)}; .scale = {paradiso::Vector2<float>::make(1.01f, 1.3f)}};
backgroundRight = paradiso::Sprite{ backgroundRight = paradiso::Sprite{
.bitmap = backgroundImage, .bitmap = backgroundImage,
.pivot = paradiso::Vector2<float>::make(2.0f, 0.0f), .pivot = {paradiso::Vector2<float>::make(2.018f, 0.16f)},
.scale = paradiso::Vector2<float>::make(1.01f, 1.0f)}; .scale = {paradiso::Vector2<float>::make(1.01f, 1.3f)}};
auto grassImage = paradiso::BitmapIO::get().load("base.png"); auto grassImage = paradiso::BitmapIO::get().load("base.png");
grassLeft = paradiso::Sprite{ grassLeft = paradiso::Sprite{
.bitmap = grassImage, .bitmap = grassImage,
.pivot = paradiso::Vector2<float>::make(0.0f, -1.0f), .pivot = {paradiso::Vector2<float>::make(0.0f, -1.0f)},
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)}; .scale = {paradiso::Vector2<float>::make(1.0f, 0.33333f)}};
grassRight = paradiso::Sprite{ grassRight = paradiso::Sprite{
.bitmap = grassImage, .bitmap = grassImage,
.pivot = paradiso::Vector2<float>::make(2.0f, -1.0f), .pivot = {paradiso::Vector2<float>::make(2.0f, -1.0f)},
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)}; .scale = {paradiso::Vector2<float>::make(1.0f, 0.33333f)}};
} }
void draw(const paradiso::Shader& shader) { void draw(const paradiso::Shader& shader) {
@ -61,7 +61,7 @@ struct Background {
if (sprite->pivot.x() <= -2.0f) { if (sprite->pivot.x() <= -2.0f) {
sprite->pivot.x() += 4.0f; sprite->pivot.x() += 4.0f;
} }
sprite->pivot.x() -= 0.001f; sprite->pivot.x() -= 0.002f;
shader.set_uniform("pivot", sprite->pivot); shader.set_uniform("pivot", sprite->pivot);
shader.set_uniform("scale", sprite->scale); shader.set_uniform("scale", sprite->scale);
shader.set_uniform("rotation", sprite->rotation); shader.set_uniform("rotation", sprite->rotation);
@ -79,23 +79,23 @@ struct Grass {
paradiso::Sprite* scrolling[2] = {&grassLeft, &grassRight}; paradiso::Sprite* scrolling[2] = {&grassLeft, &grassRight};
Grass() { Grass() {
auto grassImage = paradiso::BitmapIO::get().load(std::string("base.png")); auto grassImage = paradiso::BitmapIO::get().load("base.png");
grassLeft = paradiso::Sprite{ grassLeft = paradiso::Sprite{
.bitmap = grassImage, .bitmap = grassImage,
.pivot = paradiso::Vector2<float>::make(0.0f, -0.9f), .pivot = {paradiso::Vector2<float>::make(1.0f, -0.9f)},
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)}; .scale = {paradiso::Vector2<float>::make(2.0f, 0.33333f)}};
grassRight = paradiso::Sprite{ grassRight = paradiso::Sprite{
.bitmap = grassImage, .bitmap = grassImage,
.pivot = paradiso::Vector2<float>::make(2.0f, -0.9f), .pivot = {paradiso::Vector2<float>::make(1.0f, -0.9f)},
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)}; .scale = {paradiso::Vector2<float>::make(2.6f, 0.33333f)}};
} }
void draw(const paradiso::Shader& shader) { void draw(const paradiso::Shader& shader) {
for (auto sprite : scrolling) { for (auto sprite : scrolling) {
if (sprite->pivot.x() <= -2.0f) { if (sprite->pivot.x() <= -1.0f) {
sprite->pivot.x() += 4.0f; sprite->pivot.x() += 2.0f;
} }
sprite->pivot.x() -= 0.035f; sprite->pivot.x() -= 0.03f;
shader.set_uniform("pivot", sprite->pivot); shader.set_uniform("pivot", sprite->pivot);
shader.set_uniform("scale", sprite->scale); shader.set_uniform("scale", sprite->scale);
shader.set_uniform("rotation", sprite->rotation); shader.set_uniform("rotation", sprite->rotation);
@ -106,6 +106,7 @@ struct Grass {
paradiso::Renderer renderer{}; paradiso::Renderer renderer{};
}; };
struct QuickWings { struct QuickWings {
paradiso::Renderer renderer1{}; paradiso::Renderer renderer1{};
@ -118,10 +119,10 @@ struct QuickWings {
unsigned int flapCounter = 0; // How many ticks since last flap unsigned int flapCounter = 0; // How many ticks since last flap
float velocity = 0.0f; float velocity = 0.0f;
const float max_velocity = 0.05f; const float max_velocity = 0.04f;
const float gravity = -0.004f; const float gravity = -0.004f;
const float move_up_velocity = 0.0055f; const float move_up_velocity = 0.04f;
bool move_up = false; bool move_up = false;
bool paused = true; bool paused = true;
@ -129,30 +130,30 @@ struct QuickWings {
const float max_pos = 0.95f; const float max_pos = 0.95f;
const float min_pos = -0.5f; const float min_pos = -0.5f;
float pos = 0.0f; float pos = 0.34f;
float rotation = 0.0f; float rotation = 0.0f;
QuickWings() { QuickWings() {
float scaleh = 0.07f; float scaleh = 0.08f;
float scalew = scaleh * 1.416666666666667f; float scalew = 0.158f;
birds = { birds = {
paradiso::Sprite{ paradiso::Sprite{
.bitmap = .bitmap =
paradiso::BitmapIO::get().load("yellowbird-downflap.png"), paradiso::BitmapIO::get().load("yellowbird-downflap.png"),
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f), .pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
.scale = paradiso::Vector2<float>::make(scalew, scaleh)}, .scale = {paradiso::Vector2<float>::make(scalew, scaleh)}},
paradiso::Sprite{ paradiso::Sprite{
.bitmap = .bitmap =
paradiso::BitmapIO::get().load("yellowbird-midflap.png"), paradiso::BitmapIO::get().load("yellowbird-midflap.png"),
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f), .pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
.scale = paradiso::Vector2<float>::make(scalew, scaleh)}, .scale = {paradiso::Vector2<float>::make(scalew, scaleh)}},
paradiso::Sprite{ paradiso::Sprite{
.bitmap = .bitmap =
paradiso::BitmapIO::get().load("yellowbird-upflap.png"), paradiso::BitmapIO::get().load("yellowbird-upflap.png"),
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f), .pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
.scale = paradiso::Vector2<float>::make(scalew, scaleh)}}; .scale = {paradiso::Vector2<float>::make(scalew, scaleh)}}};
} }
void draw(const paradiso::Shader& shader) { void draw(const paradiso::Shader& shader) {
@ -185,6 +186,7 @@ struct QuickWings {
} }
void update() { void update() {
// Stop game // Stop game
if (paused) if (paused)
return; return;
@ -213,7 +215,7 @@ struct QuickWings {
} }
// Update rotation // Update rotation
rotation = velocity * 15.0f; rotation = velocity * 10.0f;
} }
// keyboard handler // keyboard handler
@ -231,6 +233,30 @@ struct QuickWings {
} }
}; };
/*
TODO: finish this
struct Message {
paradiso::Sprite messageSprite;
paradiso::Renderer renderer{};
Message() {
auto messageImage = paradiso::BitmapIO::get().load("message.png");
messageSprite = paradiso::Sprite{
.bitmap = messageImage,
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
.scale = {paradiso::Vector2<float>::make(0.8f, 0.8f)}
};
};
void draw(const paradiso::Shader& shader) {
shader.set_uniform("pivot", messageSprite.pivot);
shader.set_uniform("scale", messageSprite.scale);
renderer.draw(messageSprite, shader);
}
};
*/
auto main() -> int { auto main() -> int {
// Ausgabefenster ... sieht aus als wäre es auf dem Stack // Ausgabefenster ... sieht aus als wäre es auf dem Stack
@ -274,9 +300,9 @@ auto main() -> int {
paradiso::BitmapIO::get().set_path("assets"); paradiso::BitmapIO::get().set_path("assets");
// Load // Load
//* auto message = Message{};
auto background = Background{}; auto background = Background{};
auto grass = Grass{}; auto grass = Grass{};
auto quickwingsapp = QuickWings{}; auto quickwingsapp = QuickWings{};
// timer // timer
@ -298,6 +324,7 @@ auto main() -> int {
// Draw // Draw
background.draw(shader); background.draw(shader);
grass.draw(shader); grass.draw(shader);
//* message.draw(shader);
quickwingsapp.draw(shader); quickwingsapp.draw(shader);
// wait for frame rate // wait for frame rate