From 63be986ad809c0c34b0f899acb0a6c816c7e28d0 Mon Sep 17 00:00:00 2001 From: Zaka Date: Sun, 26 Jan 2025 18:54:07 +0100 Subject: [PATCH] A bunch of minor markdown fixes --- CHANGELOG.md | 6 +- CONTRIBUTING.md | 16 ++-- LICENSE.md | 9 +-- README.md | 24 +++--- website/about/contributing.md | 25 ++----- website/about/license.md | 9 +-- website/demo/index.md | 4 +- website/docs/latest/events.md | 1 + website/docs/latest/window-render.md | 5 +- website/index.md | 20 ++--- website/install.md | 2 +- website/roadmap/index.md | 89 ++++++----------------- website/roadmap/v1.md | 97 ++++++++++++++++++------- website/roadmap/v2.md | 1 + website/tutorials/beginner/rendering.md | 29 ++++++++ 15 files changed, 180 insertions(+), 157 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32271dc8..5da75be9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ + # Vuelto Changelog ## Vuelto 1.1.2 (25/01/2025) ### Fixes -- Fixed building on older gpu's -- Changed to compatability rather then core profile + +- Fixed builds fon older GPUs +- Changed to OpenGL Compatibility profile (from OpenGL Core profile) ## Vuelto 1.1.1 (05/01/2025) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8046d234..3d0e76f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,15 +24,15 @@ Some technologies we are using If you want to contribute, you have to set up the work environment, so you can develop vuelto the right way. -1. Run `go mod tidy` to install all the packages -2. Fork [the repository](https://github.com/vuelto-org/vuelto). -3. Clone your forked github repository: +- Run `go mod tidy` to install all the packages. +- Fork [the repository](https://github.com/vuelto-org/vuelto). +- Clone your forked github repository: ```bash git clone https://github.com/your_username/vuelto.git ``` -4. Change the branch to the dev branch to follow rule \#1: +- Change the branch to the dev branch to follow rule \#1: ```bash git checkout dev @@ -40,14 +40,12 @@ git checkout dev ## Pull Request -If you're ready with your changes, then you must follow a few steps before pull requesting. - -1. Run `make` to format your code: +When you're ready with your changes, make sure you run `make` to format your code before pull requesting: ```bash make format ``` -Then make sure your pull request code works without erroring and you followed the [contribution rules](#contributing-rules) +Then make sure your code works without erroring and you're following the [contribution rules](#contributing-rules). -After all of this, you can create a pull request and one of our main organization members will look at it. +After all of this, you can create a pull request and one of our main members will look at it (and hopefully merge it!). diff --git a/LICENSE.md b/LICENSE.md index 27ddaf88..e9b791a9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -14,7 +14,6 @@ This software is licensed under the terms of the [GNU General Public License ver β€œ_The source code_” refers to any piece of source code, including but not limited to scripts, computer code, and compiled binaries, that is directly associated with The software. - "_The main repository_" refers to the repository where most of The software's development occurs, and/or where The source code of The software itself (or at least it’s primary / most important parts) is hosted, _not_ implying that other code repositories that are directly linked to the project are to be excluded by the terms of the Vuelto License. ## **1. Primary License** @@ -24,6 +23,7 @@ The software is, by default, licensed under the terms of the main license unless ## **2. Condition for License Change** The software shall be deemed "unmaintained" if any of the following conditions are met: + - The project repository has been archived or set to read-only. - The project has been officially pronounced as "dead", "unmaintained", or something else with the same meaning by The maintainer(s). - No substantial code contributions (beyond minor maintenance tasks or dependency updates) have been made to The main repository for a continuous period of 1.5 years (18 months). @@ -60,13 +60,13 @@ The decision on whether The software is unmaintained will be made by the origina ## **5. Communication of License change** -If The software is declared unmaintained by The maintainer(s), the change shall be communicated by an update to The sroject's "_README_ file", website, or any other mean of communication that makes this change clear. +If The software is declared unmaintained by The maintainer(s), the change shall be communicated by an update to The project's "_README_ file", website, or any other mean of communication that makes this change clear. ## **6. Extensibility of the License** It is possible for The maintainer(s) to extend the Vuelto License with additional terms. These must be made clear by The maintainer(s) by specifying them when using the License's identifier. -All possible extensions are shipped in the License's text, but they shall apply only if specified by The maintainer(s). Extensions are not part of the License's numerical order (Section 1, Section 2, and so); instead they are found at the end, preceeded by a heading with their specific identifier, and then using "A, B, C..." notation rather than "1, 2, 3..." notation for each section. +All possible extensions are shipped in the License's text, but they shall apply only if specified by The maintainer(s). Extensions are not part of the License's numerical order (Section 1, Section 2, and so); instead they are found at the end, preceded by a heading with their specific identifier, and then using "A, B, C..." notation rather than "1, 2, 3..." notation for each section. ### **6.1. License identification** @@ -85,8 +85,7 @@ The following extensions, with their content available at the end of this Licens Any artwork associated with The software, including but not limited to logos, icons, and other visual assets, is copyrighted and licensed under the terms of the Primary License (GNU GPLv3 or later). However, if The software license changes to the MIT License under the conditions outlined in **Section 3**, this copyright on artwork no longer applies, and the artwork is included under the MIT License. - ### **B. Copyright on Code** The source code is copyrighted and licensed under the terms of the Primary License (GNU GPLv3 or later). However, if The software license changes to the MIT License under the conditions outlined in **Section 3**, this copyright on The source code no longer applies, and The source code is included under the MIT License. - + \ No newline at end of file diff --git a/README.md b/README.md index c27259f5..d4338a55 100755 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -

+

banner banner - GitHub last commit - License - - CI Check - - Lines of code - Report card - Powered By - Powered By -

+ +[![GitHub last commit](https://img.shields.io/github/last-commit/vuelto-org/vuelto?style=for-the-badge)](https://github.com/vuelto-org/vuelto) +[![License](https://img.shields.io/badge/license-VL--Cv1.1-blue?style=for-the-badge)](https://github.com/vuelto-org/license) +[![CI Check](https://img.shields.io/github/actions/workflow/status/vuelto-org/vuelto/ci_check.yml?style=for-the-badge)](https://github.com/vuelto-org/vuelto/actions/workflows/ci_check.yml) +[![Lines of code](https://www.aschey.tech/tokei/github/vuelto-org/vuelto?style=for-the-badge)](https://github.com/vuelto-org/vuelto) +[![Report card](https://goreportcard.com/badge/github.com/vuelto-org/vuelto?style=for-the-badge)](https://goreportcard.com/report/github.com/vuelto-org/vuelto) +[![Powered By](https://img.shields.io/badge/powered_by-GL_3.3-blue?style=for-the-badge)](https://www.opengl.org/Documentation/Specs.html) +[![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7&style=for-the-badge)](https://beua.today) + +
Vuelto is an open-source, fast, and lightweight game engine, based on Golang, CGo, and OpenGL. It's easy to use yet very powerful, and it's also cross platform, meaning it can be deployed on almost all major platforms. @@ -131,7 +131,7 @@ A special thanks to: - **Dimkauzh** for the initial idea and development. - **ZakaHaceCosas** for the great improvements on top of vuelto. -Also a big shoutout to our homies and partners at [**Sokora**](https://sokora.org), [**Atom**](https://atomlabs.ie) and [**Epic-Bot**](https://bamb.cl/epic-bot/) +Also a big shout-out to our homies and partners at [**Sokora**](https://sokora.org), [**Atom**](https://atomlabs.ie) and [**Epic-Bot**](https://bamb.cl/epic-bot/) Without the help of these people, Vuelto wouldn't be where it is today. Your support has helped make Vuelto even better! 🀝 πŸ™Œ diff --git a/website/about/contributing.md b/website/about/contributing.md index bed0211f..3d0e76f0 100644 --- a/website/about/contributing.md +++ b/website/about/contributing.md @@ -24,22 +24,15 @@ Some technologies we are using If you want to contribute, you have to set up the work environment, so you can develop vuelto the right way. -1. Install the packages +- Run `go mod tidy` to install all the packages. +- Fork [the repository](https://github.com/vuelto-org/vuelto). +- Clone your forked github repository: ```bash -go mod tidy +git clone https://github.com/your_username/vuelto.git ``` -2. Fork [the repository](https://vuelto.pp.ua/repo). - -3. Clone your forked github repository: - -```bash -git clone https://github.com/your_username_/vuelto.git -cd vuelto -``` - -4. Change the branch to the dev branch to follow rule \#1: +- Change the branch to the dev branch to follow rule \#1: ```bash git checkout dev @@ -47,14 +40,12 @@ git checkout dev ## Pull Request -If you're ready with your changes, then you must follow a few steps before pull requesting. - -1. Run `make` to format your code: +When you're ready with your changes, make sure you run `make` to format your code before pull requesting: ```bash make format ``` -Then make sure your pull request code works without erroring and you followed the [contribution rules](#contributing-rules) +Then make sure your code works without erroring and you're following the [contribution rules](#contributing-rules). -After all of this, you can create a pull request and one of our main organization members will look at it. +After all of this, you can create a pull request and one of our main members will look at it (and hopefully merge it!). diff --git a/website/about/license.md b/website/about/license.md index 27ddaf88..e9b791a9 100644 --- a/website/about/license.md +++ b/website/about/license.md @@ -14,7 +14,6 @@ This software is licensed under the terms of the [GNU General Public License ver β€œ_The source code_” refers to any piece of source code, including but not limited to scripts, computer code, and compiled binaries, that is directly associated with The software. - "_The main repository_" refers to the repository where most of The software's development occurs, and/or where The source code of The software itself (or at least it’s primary / most important parts) is hosted, _not_ implying that other code repositories that are directly linked to the project are to be excluded by the terms of the Vuelto License. ## **1. Primary License** @@ -24,6 +23,7 @@ The software is, by default, licensed under the terms of the main license unless ## **2. Condition for License Change** The software shall be deemed "unmaintained" if any of the following conditions are met: + - The project repository has been archived or set to read-only. - The project has been officially pronounced as "dead", "unmaintained", or something else with the same meaning by The maintainer(s). - No substantial code contributions (beyond minor maintenance tasks or dependency updates) have been made to The main repository for a continuous period of 1.5 years (18 months). @@ -60,13 +60,13 @@ The decision on whether The software is unmaintained will be made by the origina ## **5. Communication of License change** -If The software is declared unmaintained by The maintainer(s), the change shall be communicated by an update to The sroject's "_README_ file", website, or any other mean of communication that makes this change clear. +If The software is declared unmaintained by The maintainer(s), the change shall be communicated by an update to The project's "_README_ file", website, or any other mean of communication that makes this change clear. ## **6. Extensibility of the License** It is possible for The maintainer(s) to extend the Vuelto License with additional terms. These must be made clear by The maintainer(s) by specifying them when using the License's identifier. -All possible extensions are shipped in the License's text, but they shall apply only if specified by The maintainer(s). Extensions are not part of the License's numerical order (Section 1, Section 2, and so); instead they are found at the end, preceeded by a heading with their specific identifier, and then using "A, B, C..." notation rather than "1, 2, 3..." notation for each section. +All possible extensions are shipped in the License's text, but they shall apply only if specified by The maintainer(s). Extensions are not part of the License's numerical order (Section 1, Section 2, and so); instead they are found at the end, preceded by a heading with their specific identifier, and then using "A, B, C..." notation rather than "1, 2, 3..." notation for each section. ### **6.1. License identification** @@ -85,8 +85,7 @@ The following extensions, with their content available at the end of this Licens Any artwork associated with The software, including but not limited to logos, icons, and other visual assets, is copyrighted and licensed under the terms of the Primary License (GNU GPLv3 or later). However, if The software license changes to the MIT License under the conditions outlined in **Section 3**, this copyright on artwork no longer applies, and the artwork is included under the MIT License. - ### **B. Copyright on Code** The source code is copyrighted and licensed under the terms of the Primary License (GNU GPLv3 or later). However, if The software license changes to the MIT License under the conditions outlined in **Section 3**, this copyright on The source code no longer applies, and The source code is included under the MIT License. - + \ No newline at end of file diff --git a/website/demo/index.md b/website/demo/index.md index bfed2a4b..c2b71391 100644 --- a/website/demo/index.md +++ b/website/demo/index.md @@ -1,13 +1,15 @@ # πŸ” Demos + Hey and welcome to the demo section! Here you can find a list of demos that demonstrate how to use Vuelto in different scenarios. All of these work in the web! !!! warning These demo's might take a while to load, depending on the hardware. Please be patient. !!! note - The demo's will be streched to fit the screen. This is done so mobile users can see the demos better. This behavior can be ofcourse changed by changing the last argument of `vuelto.NewWindow`. + The demo's will be stretched to fit the screen. This is done so mobile users can see the demos better. This behavior can be of course changed by changing the last argument of `vuelto.NewWindow`. ## 🧩 All examples + - [Shapes example](1/index.html) - [Images example](2/index.html) - [Rendering example](3/index.html) diff --git a/website/docs/latest/events.md b/website/docs/latest/events.md index 7209ecb4..bf1c6d07 100644 --- a/website/docs/latest/events.md +++ b/website/docs/latest/events.md @@ -11,6 +11,7 @@ type Vector2D struct { Y float32 } ``` + !!! note Every event should be checked in the game loop, else it won't work. diff --git a/website/docs/latest/window-render.md b/website/docs/latest/window-render.md index 76f5e9e0..6747c034 100644 --- a/website/docs/latest/window-render.md +++ b/website/docs/latest/window-render.md @@ -9,6 +9,7 @@ This module allows you to manage the main window and rendering operations, essen ## 🏠 Window To create a window, initialize a new instance and store it in a variable. Pass the following arguments: + - **Title**: The title of your window. - **Width**: The width of the window in pixels. - **Height**: The height of the window in pixels. @@ -52,11 +53,11 @@ for !window.Close() { ```go for !window.Close() { - image.Draw() + image.Draw() // ... - window.Refresh() + window.Refresh() } ``` diff --git a/website/index.md b/website/index.md index d4ba041a..a7d35916 100755 --- a/website/index.md +++ b/website/index.md @@ -10,17 +10,17 @@ hide: } -

+

banner - GitHub last commit - License - - CI Check - - Lines of code - Report card - Powered By - Powered By + +[![GitHub last commit](https://img.shields.io/github/last-commit/vuelto-org/vuelto?style=for-the-badge)](https://github.com/vuelto-org/vuelto) +[![License](https://img.shields.io/badge/license-VL--Cv1.1-blue?style=for-the-badge)](https://github.com/vuelto-org/license) +[![CI Check](https://img.shields.io/github/actions/workflow/status/vuelto-org/vuelto/ci_check.yml?style=for-the-badge)](https://github.com/vuelto-org/vuelto/actions/workflows/ci_check.yml) +[![Lines of code](https://www.aschey.tech/tokei/github/vuelto-org/vuelto?style=for-the-badge)](https://github.com/vuelto-org/vuelto) +[![Report card](https://goreportcard.com/badge/github.com/vuelto-org/vuelto?style=for-the-badge)](https://goreportcard.com/report/github.com/vuelto-org/vuelto) +[![Powered By](https://img.shields.io/badge/powered_by-GL_3.3-blue?style=for-the-badge)](https://www.opengl.org/Documentation/Specs.html) +[![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7&style=for-the-badge)](https://beua.today) +

Welcome to the Vuelto website! Here you will find things like documentation, blogs, tutorials and everything about Vuelto! diff --git a/website/install.md b/website/install.md index 6e67fd41..f126e7b5 100755 --- a/website/install.md +++ b/website/install.md @@ -12,7 +12,7 @@ go get vuelto.pp.ua@latest You have to have X11-dev-packages and C compiler installed. -#### πŸ–₯️ X11 +### πŸ–₯️ X11 On Debian and derivate distributions like Ubuntu and Linux Mint the xorg-dev meta-package pulls in the development packages for all of X11. diff --git a/website/roadmap/index.md b/website/roadmap/index.md index d0a0773d..7f8e83ba 100644 --- a/website/roadmap/index.md +++ b/website/roadmap/index.md @@ -1,73 +1,32 @@ + # πŸ“… Upcoming release -## V1.1 -- [x] Framerates - - [x] Set framerate - - [x] Get framerate - - [x] Deltatime +## V1.2 -- [x] Events - - [x] Keyboard - - [x] Mouse +- [ ] Renderer + - [ ] SetPixel + - [ ] LoadText and .Draw() -- [x] Renderer - - [x] Move the main API to the Rendering driver - - [x] Web - - [x] Web-windowing - - [x] Support for web using wasm - - [x] Web-rendering - - [x] Support for building graphics driver - - [x] WebGL - - [x] Desktop - - [x] Move to OpenGL v3.3 +- [ ] Image + - [ ] Manipulate images -- [x] Windowing - - [x] Platforms - - [x] Windowing for web - - [x] Windowing for desktop - - [x] Framerates - - [x] Set framerate - - [x] Get framerate - - [x] Deltatime +- [ ] Spritesheets + - [ ] Using images + - [ ] returning images + - [ ] Usable with animations -- [x] Imaging - - [x] Load images - - [x] Process images (to string) +- [ ] Node system + - [ ] Movable nodes + - [ ] Custom physics option + - [ ] Static nodes + - [ ] Unmovable + - [ ] Just a basic image/shape -- [x] 2 Ring Rendering Driver - - [x] Ring 1 - - [x] Wrapper around OpenGL C api - - [x] Wrapper around WebGL JS api - - [x] Ring 2 - - [x] API around OpenGL and WebGL +- [ ] Animations + - [ ] Using images + - [ ] Using spritesheets -- [x] 2 Ring Window Driver - - [x] Ring 1 - - [x] Wrapper around GLFW - - [x] Wrapper around JS runtime - - [x] Ring 2 - - [x] API around GLFW and JS windowing - -- [x] 2 Ring Input Driver - - [x] Ring 1 (No ring 1 needed) - - [x] Ring 2 - - [x] API around GLFW and JS events - -- [x] 2 Ring Image Driver - - [x] Ring 1 (No ring 1 needed) - - [x] Ring 2 - - [x] API around Go image library - -- [ ] Website - - [ ] Docs - - [ ] Vuelto Docs - - [ ] Vuelto API - - [ ] How to use vuelto - - [ ] Vuelto's functionality - - [x] Developer Docs - - [x] Vuelto's 3 ring structure - - [x] CONTRIBUTING.md - - [x] Code of Conduct - - [ ] Tutorials - - [ ] Examples - - [ ] Tutorials to build small games +- [ ] Custom color system + - [ ] Color struct + - [ ] NewColor function + - [ ] Predefined Color constants diff --git a/website/roadmap/v1.md b/website/roadmap/v1.md index 2524a2a7..a8a0c319 100755 --- a/website/roadmap/v1.md +++ b/website/roadmap/v1.md @@ -1,3 +1,4 @@ + # πŸ›£οΈ Roadmap for V1 ## V1 @@ -38,33 +39,73 @@ ## V1.1 -Moved to the upcoming releases page. See [here](https://vuelto.pp.ua/roadmap). +- [x] Framerates + - [x] Set framerate + - [x] Get framerate + - [x] Deltatime + +- [x] Events + - [x] Keyboard + - [x] Mouse + +- [x] Renderer + - [x] Move the main API to the Rendering driver + - [x] Web + - [x] Web-windowing + - [x] Support for web using wasm + - [x] Web-rendering + - [x] Support for building graphics driver + - [x] WebGL + - [x] Desktop + - [x] Move to OpenGL v3.3 + +- [x] Windowing + - [x] Platforms + - [x] Windowing for web + - [x] Windowing for desktop + +- [x] Imaging + - [x] Load images + - [x] Process images (to string) + +- [x] 2 Ring Rendering Driver + - [x] Ring 1 + - [x] Wrapper around OpenGL C api + - [x] Wrapper around WebGL JS api + - [x] Ring 2 + - [x] API around OpenGL and WebGL + +- [x] 2 Ring Window Driver + - [x] Ring 1 + - [x] Wrapper around GLFW + - [x] Wrapper around JS runtime + - [x] Ring 2 + - [x] API around GLFW and JS windowing + +- [x] 2 Ring Input Driver + - [x] Ring 1 (No ring 1 needed) + - [x] Ring 2 + - [x] API around GLFW and JS events + +- [x] 2 Ring Image Driver + - [x] Ring 1 (No ring 1 needed) + - [x] Ring 2 + - [x] API around Go image library + +- [x] Website + - [x] Docs + - [x] Vuelto Docs + - [x] Vuelto API + - [x] How to use vuelto + - [x] Vuelto's functionality + - [x] Developer Docs + - [x] Vuelto's 3 ring structure + - [x] CONTRIBUTING.md + - [x] Code of Conduct + - [x] Tutorials + - [x] Examples + - [x] Tutorials to build small games ## V1.2 -- [ ] Renderer - - [ ] SetPixel - - [ ] LoadText and .Draw() - -- [ ] Image - - [ ] Manipulate images - -- [ ] Spritesheets - - [ ] Using images - - [ ] returning images - - [ ] Usable with animations - -- [ ] Node system - - [ ] Movable nodes - - [ ] Custom physics option - - [ ] Static nodes - - [ ] Unmovable - - [ ] Just a basic image/shape - -- [ ] Animations - - [ ] Using images - - [ ] Using spritesheets - -- [ ] Custom color system - - [ ] Color struct - - [ ] NewColor function - - [ ] Predefined Color constants + +Moved to the upcoming releases page. See [here](https://vuelto.pp.ua/roadmap). diff --git a/website/roadmap/v2.md b/website/roadmap/v2.md index 1ec146c4..25fcef0b 100755 --- a/website/roadmap/v2.md +++ b/website/roadmap/v2.md @@ -1,3 +1,4 @@ + # πŸ›£οΈ Roadmap for V2 ## V2 diff --git a/website/tutorials/beginner/rendering.md b/website/tutorials/beginner/rendering.md index b12a4f31..4860b50f 100644 --- a/website/tutorials/beginner/rendering.md +++ b/website/tutorials/beginner/rendering.md @@ -1,18 +1,23 @@ # πŸ“‚ Basic Rendering with vuelto + Hello and welcome to the second tutorial in the beginner series! In this tutorial, we will learn how to render a window with Vuelto. We expect you to at least have the basics from the [first tutorial](new-project.md) setup and ready to go. Let's get started! !!! note This tutorial is designed for the desktop platforms (Windows, macOS, and Linux). The changes for the web platform will be covered in the last paragrap of the tutorial. ## πŸ–ŒοΈ Settings up the renderer + So before the tutorial starts, we need to make sure we have a working renderer. The renderer is a struct that is responsible for rendering everything on the screen. We will use the `vuelto.NewRenderer` function to create a new renderer. Here is how you can do it: + ```go ren := w.NewRenderer2D() ``` + And thats it for the renderer! Now we can move on to rendering different things!. ## πŸš€ Rendering different shapes onto the window + So lets get started with some graphics. A colored background will be our start for now. So lets run the `ClearColor()` function from the `vuelto` package. This function takes in 4 arguments, the red, green, blue, and alpha values. The values follow RGBA color model, where each value is between 0 and 255. Here is an example of how to set the background color to a gray-ish color. Make sure to run this code inside of the game loop. ```go @@ -24,12 +29,15 @@ for !w.Close() { } // ... ``` + And now if you run the code, you should see a gray window. You can change the values to get different colors. Next up, we can get some geometry on the screen. Lets start off with a basic line. For this we first will need to initialize a new line outside of the game loop (`vuelto.NewLine`), and after that draw it inside of the game loop (`line.Draw`). The line arguments work as follows: + - `x1` and `y1` are the starting point of the line. - `x2` and `y2` are the ending point of the line. - `color` is the color of the line, following the RGBA color model (just like in `ClearColor`). + ```go // ... line := ren.NewLine(0.5, 0.5, -0.5, -0.5, [4]int{10, 145, 245, 255}) @@ -37,6 +45,7 @@ line := ren.NewLine(0.5, 0.5, -0.5, -0.5, [4]int{10, 145, 245, 255}) ``` And now we can render the line inside of the game loop. + ```go // ... for !w.Close() { @@ -46,18 +55,23 @@ for !w.Close() { } // ... ``` + And now you should see a line on the screen. You can change the values to get different lines! Now that we got basic lines, lets move on to rectangles. It works really similar to lines. The rectangle arguments work as follows: + - `x` and `y` are the top left corner of the rectangle. - `width` and `height` are the width and height of the rectangle. - `color` is the color of the rectangle, following the RGBA color model. First initialize a new rectangle outside of the game loop (`vuelto.NewRect`). + ```go rect := ren.NewRect(0, 0, 1, 1, [4]int{245, 145, 10, 255}) ``` + And now we can render the rectangle inside of the game loop. + ```go // ... for !w.Close() { @@ -67,18 +81,24 @@ for !w.Close() { } // ... ``` + And now you should see a rectangle on the screen. You can change the values to get different rectangles! ## 🎨 Rendering images + Now that we got some basic shapes on the screen, lets move on to images. The will be a little more complex, but still pretty simple. First we will need to load an image. For this we will use the `ren.LoadImage` function. This function takes in the path to the image and returns a new image. Here is an example of how to load an image: + ```go img := ren.LoadImage("path/to/image.png", 0.5, 0.5, -0.5, 0.5) ``` + The arguments work as follows: + - The first argument is the path to the image. - The next 4 arguments are the x and y coordinates of the top left corner of the image, and the width and height of the image. And now we can render the image inside of the game loop. + ```go // ... for !w.Close() { @@ -90,14 +110,18 @@ for !w.Close() { ``` ## 🌐 Rendering for the web + If you want to render your game for the web, you will need to make a few changes. + - You will need to adapt your image paths to the web. This means that you will need to change the path to the image to an embedded image. Thats it! ### πŸ”„ Adapting the image paths + To adapt the image paths to the web, you will need to embed the images into the binary. This can be done with the `go:embed` directive. Here is an example of how to embed an image: First import the `embed` package. + ```go // ... import ( @@ -107,7 +131,9 @@ import ( ) // ... ``` + Then, create an embed filesystem with your image/images. + ```go // ... //go:embed tree.png /path/to/image.png @@ -116,6 +142,7 @@ var embeddedFiles embed.FS ``` And now create a new `ImageEmbed` object with the path to the image and the filesystem + ```go imageEmbed := vuelto.ImageEmbed{ Filesystem: embeddedFiles, @@ -124,7 +151,9 @@ imageEmbed := vuelto.ImageEmbed{ ``` And now you can use the `LoadImage` function with the `imageEmbed` object. + ```go image := ren.LoadImage(imageEmbed, 0.5, 0.5, -0.5, 0.5) ``` + And now you should be able to render the image on the web!