erm
This commit is contained in:
commit
55713fff8c
78
bsptest.go
Normal file
78
bsptest.go
Normal file
|
@ -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()
|
||||
}
|
||||
}
|
13
go.mod
Normal file
13
go.mod
Normal file
|
@ -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
|
||||
)
|
8
go.sum
Normal file
8
go.sum
Normal file
|
@ -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=
|
Loading…
Reference in a new issue