This commit is contained in:
zongor 2023-12-07 23:47:53 -05:00
parent 1930ace9e6
commit dfcbe4368c
1 changed files with 51 additions and 18 deletions

69
main.go
View File

@ -3,27 +3,12 @@ package main
import ( import (
"fmt" "fmt"
rl "github.com/gen2brain/raylib-go/raylib"
"github.com/gocolly/colly" "github.com/gocolly/colly"
rl "github.com/gen2brain/raylib-go/raylib"
) )
func main() { func main() {
rl.InitWindow(800, 450, "raylib [core] example - basic window")
defer rl.CloseWindow()
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)
rl.EndDrawing()
}
/*
c := colly.NewCollector( c := colly.NewCollector(
colly.AllowedDomains("alfrescocavern.com"), colly.AllowedDomains("alfrescocavern.com"),
) )
@ -31,7 +16,15 @@ func main() {
c.OnHTML("a[href]", func(e *colly.HTMLElement) { c.OnHTML("a[href]", func(e *colly.HTMLElement) {
link := e.Attr("href") link := e.Attr("href")
fmt.Printf("Link found: %q -> %s\n", e.Text, link) fmt.Printf("Link found: %q -> %s\n", e.Text, link)
c.Visit(e.Request.AbsoluteURL(link)) //c.Visit(e.Request.AbsoluteURL(link))
})
c.OnHTML("div", func(h *colly.HTMLElement) {
fmt.Printf(h.Text)
})
c.OnHTML("p", func(h *colly.HTMLElement) {
fmt.Printf(h.Text)
}) })
c.OnRequest(func(r *colly.Request) { c.OnRequest(func(r *colly.Request) {
@ -39,5 +32,45 @@ func main() {
}) })
c.Visit("https://alfrescocavern.com/") c.Visit("https://alfrescocavern.com/")
*/
rl.InitWindow(800, 450, "raylib [core] example - 3d camera first person")
camera := rl.Camera3D{}
camera.Position = rl.NewVector3(4.0, 2.0, 4.0)
camera.Target = rl.NewVector3(0.0, 1.8, 0.0)
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
camera.Fovy = 60.0
camera.Projection = rl.CameraPerspective
rl.SetTargetFPS(60)
rl.DisableCursor()
for !rl.WindowShouldClose() {
rl.UpdateCamera(&camera, rl.CameraFirstPerson) // Update camera with first person mode
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.BeginMode3D(camera)
rl.DrawPlane(rl.NewVector3(0.0, 0.0, 0.0), rl.NewVector2(32.0, 32.0), rl.LightGray) // Draw ground
rl.DrawCube(rl.NewVector3(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Blue) // Draw a blue wall
rl.DrawCube(rl.NewVector3(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Lime) // Draw a green wall
rl.DrawCube(rl.NewVector3(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, rl.Gold) // Draw a yellow wall
rl.EndMode3D()
rl.DrawRectangle(10, 10, 220, 70, rl.Fade(rl.SkyBlue, 0.5))
rl.DrawRectangleLines(10, 10, 220, 70, rl.Blue)
rl.DrawText("First person camera default controls:", 20, 20, 10, rl.Black)
rl.DrawText("- Move with keys: W, A, S, D", 40, 40, 10, rl.DarkGray)
rl.DrawText("- Mouse move to look around", 40, 60, 10, rl.DarkGray)
rl.EndDrawing()
}
rl.EnableCursor()
rl.CloseWindow()
} }