Skip to content

Commit

Permalink
New tutorial and small updates :)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Jan 3, 2025
1 parent c29e4df commit 0a28c88
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 33 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Vuelto is an open-source, fast, and lightweight game engine, based on Golang, CG
You need to have the following installed on your system:

- 🖥️ A C compiler
- 🔧 A Go compiler
- 🔧 A Go compiler (Go 1.18 and above)
- 🪟 Xorg/Wayland development packages (For Linux only)
- 🖱️ Supported platform

Expand All @@ -55,12 +55,10 @@ func main() {
w := vuelto.NewWindow("Image Example - Vuelto", 800, 600, false)
ren := w.NewRenderer2D()

image := ren.LoadImage("test/image.png", 300, 300, 250, 250)
image1 := ren.LoadImage("test/image.png", 100, 100, 150, 150)
image := ren.LoadImage("test/image.png", 0, 0, 0.5, 0.5)

for !w.Close() {
image.Draw()
image1.Draw()
w.Refresh()
}
}
Expand All @@ -70,12 +68,12 @@ func main() {

Vuelto has built-in deployment support for the following platforms:

| Platform | Status |
| :---- | :---- |
| Windows ||
| macOS (Darwin) ||
| Linux ||
| Web | ❌ (*Work In Progress, V1.1*) |
| Platform | Status | Version |
| :---- | :---- | :---- |
| Windows || v1.0 |
| macOS (Darwin) || v1.0 |
| Linux || v1.0 |
| Web | | v1.1 |

## 📖 Docs

Expand Down
12 changes: 7 additions & 5 deletions examples/basic-window/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package main

import vuelto "vuelto.pp.ua/pkg"
import (
vuelto "vuelto.pp.ua/pkg"
)

func main() {
// This works in the web too! Only it would be so fun :(
w := vuelto.NewWindow("hi", 800, 600, false)
// This works in the web too! Only it wouldn't be so fun :(
win := vuelto.NewWindow("hi", 800, 600, false)

for !w.Close() {
w.Refresh()
for !win.Close() {
win.Refresh()
}
}
Binary file added examples/two-windows/galaxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions examples/two-windows/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ func main() {
ren1 := w1.NewRenderer2D()
ren2 := w2.NewRenderer2D()

image := ren2.LoadImage("test/image.png", 300, 300, 250, 250)
image1 := ren2.LoadImage("test/tree.png", 100, 100, 150, 150)
image := ren2.LoadImage("examples/two-windows/galaxy.png", 0, 0, 0.5, 0.5)
image1 := ren2.LoadImage("examples/two-windows/tree.png", -1, -0.5, 0.5, 0.5)

for !w1.Close() && !w2.Close() {
w1.SetCurrent()
ren1.ClearColor([4]int{100, 100, 100, 255})

ren1.DrawRect(0, 0, 500, 500, [4]int{10, 145, 245, 255})
ren1.DrawRect(-0.7, 0.7, 0.7, 0.7, [4]int{10, 145, 245, 255})

w1.Refresh()
w2.SetCurrent()
Expand Down
Binary file added examples/two-windows/tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 5 additions & 8 deletions website/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

There are some extra things you will need to use Vuelto.

- A C compiler
- A Go compiler
- Xorg development packages (For Linux only)

- 🖥️ A C compiler
- 🔧 A Go compiler (Go 1.18 and above)
- 🪟 Xorg/Wayland development packages (For Linux only)
- 🖱️ Supported platform
For a installation guide, [go here](install.md).

## 📦 Go package
Expand All @@ -33,14 +33,11 @@ func main() {
w := vuelto.NewWindow("Image Example - Vuelto", 800, 600, false)
ren := w.NewRenderer2D()

image := ren.LoadImage("your_image1.png", 300, 300, 250, 250)
image1 := ren.LoadImage("your_image2.png", 100, 100, 150, 150)
image := ren.LoadImage("test/image.png", 0, 0, 0.5, 0.5)

for !w.Close() {
image.Draw()
image1.Draw()
w.Refresh()

}
}
```
14 changes: 7 additions & 7 deletions website/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Vuelto is an open-source, fast, and lightweight game engine, based on Golang, CG
You need to have the following installed on your system:

- 🖥️ A C compiler
- 🔧 A Go compiler
- 🔧 A Go compiler (Go 1.18 and above)
- 🪟 Xorg/Wayland development packages (For Linux only)
- 🖱️ Supported platform

Expand All @@ -61,12 +61,12 @@ go get vuelto.pp.ua@latest

Vuelto has built-in deployment support for the following platforms:

| Platform | Status |
| :---- | :---- |
| Windows ||
| macOS (Darwin) ||
| Linux ||
| Web | ❌ (*Work In Progress, V1.1*) |
| Platform | Status | Version |
| :---- | :---- | :---- |
| Windows || v1.0 |
| macOS (Darwin) || v1.0 |
| Linux || v1.0 |
| Web | | v1.1 |

## 📖 Docs

Expand Down
119 changes: 119 additions & 0 deletions website/tutorials/beginner/new-project.md
Original file line number Diff line number Diff line change
@@ -1 +1,120 @@
# 📂 Creating a new project
Hello and welcome to the first tutorial in the beginner series! In this tutorial, we will create a new project using Vuelto. Let's get started!

!!! note
This tutorial assumes you have a basic understanding of Go. If you are new to Go, you can learn more about it.
If you want to follow along, the example we are building is available in the [Github repo](https://github.com/vuelto-org/vuelto/blob/latest/examples/basic-window/main.go).

## 📦 Prerequisites
Before we start, make sure you have the following installed:
- 🖥️ A C compiler
- 🔧 A Go compiler (Go 1.18 and above)
- 🪟 Xorg/Wayland development packages (For Linux only)
- 🖱️ Supported platform
Without this, vuelto might not function. For a installation guide, [go here](../../get-started.md).

## 🚀 Creating a new project
First, create a new directory for your project. You can name it whatever you want. For the sake of this tutorial, we will name it `my-vuelto-project`.

On Linux/macOS:
```bash
mkdir my-vuelto-project
cd my-vuelto-project
```

On Windows (cmd):
```cmd
mkdir my-vuelto-project
cd my-vuelto-project
```

Then init a new Go module:
```
go mod init my-vuelto-project
```

To get started lets create a new file called `main.go`. Here out game will be built in, and this can be expanded into multiple files later on.

On Linux/macOS:
```bash
touch main.go
```

On Windows (cmd):
```cmd
type nul > main.go
```

Now open the file in your favorite text editor. To check if everything is setup correctly lets print "Hello, Vuelto!" to the console.
Put the following go code in the `main.go` file:
```go
package main

import (
"fmt"
)

func main() {
fmt.Println("Hello, Vuelto!")
}
```

Now you can run the project by running:
```
go run main.go
```

This should print `Hello, Vuelto!` to the console. If it does, you have successfully created a new project! 🎉

## 📚 Setup vuelto
In the steps above, we have created a new project and printed "Hello, Vuelto!" to the console. Now we will setup vuelto in our project.

First, we need to get the vuelto package. Run the following command in your terminal:
```
go get vuelto.pp.ua@latest
```

This will download the latest version of vuelto and add it to your `go.mod` file.
Now that we have the package installed, we can start with using it in our project!

First up, import the vuelto package in your `main.go` file:
```go
// ...
import (
// ..
vuelto "vuelto.pp.ua/pkg"
// ..
)
// ...
```

Next, we need to initialize vuelto and create a new window. Add the following code to your `main.go` file:
```go
// ...
func main() {
// ...
win := vuelto.NewWindow("my-vuelto-project title", 800, 600, false)
// ...
}
// ...
```
This will create us a window with the following properties:
- The Title: `my-vuelto-project title`
- The Width: `800`
- The Height: `600`
- Property to make the window resizable: `false`

Now we need to keep the game running. This is done by creating a so called game loop. This loop will keep the game running until the window is closed. Add the following code to your `main.go` file:
```go
// ...
func main() {
// ...
for !win.Close() {
// ...
win.Refresh()
}
// ...
}
// ...
```
Now you can run the project (the same way as before) and you should see a window pop up with the title `my-vuelto-project title`. If you do, you have successfully setup vuelto in your project! 🎉

0 comments on commit 0a28c88

Please sign in to comment.