From 55713fff8c60320c9d0e0cc8ee53ab4886ff1bfc Mon Sep 17 00:00:00 2001 From: InventorXtreme Date: Sat, 20 Apr 2024 02:42:15 -0400 Subject: [PATCH] erm --- bsptest.go | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 13 +++++++++ go.sum | 8 ++++++ 3 files changed, 99 insertions(+) create mode 100644 bsptest.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/bsptest.go b/bsptest.go new file mode 100644 index 0000000..9d8cd5d --- /dev/null +++ b/bsptest.go @@ -0,0 +1,78 @@ +package main + +import ( + "fmt" + + rl "github.com/gen2brain/raylib-go/raylib" +) + +const RENDERWIDTH = 1280 +const RENDERHEIGHT = 720 + +const SCREENWIDTH = 1280 +const SCREENHEIGHT = 720 + +const WIDTHSCALE float32 = RENDERWIDTH / float32(SCREENWIDTH) +const HEIGHTSCALE float32 = RENDERHEIGHT / float32(SCREENHEIGHT) + +type bsp_node struct { + front *bsp_node + back *bsp_node + wall wall +} + +type wall struct { + v1 rl.Vector2 + v2 rl.Vector2 + direction rl.Vector2 +} + +func (w wall) Draw() { + rl.DrawLineV(w.v1, w.v2, rl.White) + midpoint := rl.Vector2MoveTowards(w.v1, w.v2, rl.Vector2Distance(w.v1, w.v2)/2) + slopevec := rl.Vector2Subtract(w.v2, w.v1) + perpslope := rl.Vector2{X: slopevec.Y, Y: -slopevec.X} + perpslopeNormalized := rl.Vector2Normalize(perpslope) + rl.DrawLineV(midpoint, rl.Vector2Add(rl.Vector2Scale(perpslopeNormalized, 20), midpoint), rl.Red) +} + +func main() { + fmt.Println("test") + rl.InitWindow(SCREENWIDTH, SCREENHEIGHT, "raylib [core] example - basic window") + rl.SetWindowState(rl.FlagWindowResizable) + defer rl.CloseWindow() + + rl.SetTargetFPS(int32(rl.GetMonitorRefreshRate(0))) + a := rl.GetMonitorPosition(0) + mh := rl.GetMonitorHeight(0) + mw := rl.GetMonitorWidth(0) + rl.SetWindowPosition(int(a.X)+int(0.5*float32(mw))-(SCREENWIDTH/2), int(a.Y)+int(0.5*float32(mh))-(0.5*SCREENHEIGHT)) + + rendertexture := rl.LoadRenderTexture(RENDERWIDTH, RENDERHEIGHT) + rl.SetTextureFilter(rendertexture.Texture, rl.FilterTrilinear) + var frametime float32 = 0 + walltest := wall{rl.Vector2{X: 50, Y: 50}, rl.Vector2{X: 100, Y: 100}, rl.Vector2{X: 50, Y: 50}} + + for !rl.WindowShouldClose() { + + frametime = rl.GetFrameTime() + + //camera.Target = rl.Vector2{0, 0} + rl.BeginTextureMode(rendertexture) + rl.ClearBackground(rl.Black) + //rl.EndMode2D() + //draw Scaled UI (buttons wont work here) + + rl.DrawText(fmt.Sprintf("%f", frametime), 0, 0, 22, rl.Black) + + walltest.Draw() + rl.EndTextureMode() + + rl.BeginDrawing() + + rl.DrawTexturePro(rendertexture.Texture, rl.NewRectangle(0, 0, float32(rendertexture.Texture.Width), -float32(rendertexture.Texture.Height)), rl.NewRectangle(0, 0, float32(rl.GetScreenWidth()), float32(rl.GetScreenHeight())), rl.NewVector2(0, 0), 0, rl.White) + + //Absoulte drawing + rl.EndDrawing() + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8ca240a --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module git.dummkopf.live/InventorX/bsptest + +go 1.22.2 + +require ( + github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6 + github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6 +) + +require ( + github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa // indirect + golang.org/x/sys v0.14.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..339657b --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk= +github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= +github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6 h1:50+kpfeZzxc1A2FralhIzPMJH9gprSm6+36EMlkbyMA= +github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM= +github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6 h1:mNKFgLZIU0eEHKHjb7Uk9ZuSy65DdgmEf2xxum0Tof4= +github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=