Fix binop bugs

This commit is contained in:
nub31
2025-09-28 23:01:06 +02:00
parent 48a2dc0ee7
commit 268a9ac474
2 changed files with 51 additions and 11 deletions

View File

@@ -8,12 +8,12 @@ extern "main" func main(args: []cstring): i64
raylib::InitWindow(1600, 900, "Hi from nub-lang")
raylib::SetTargetFPS(240)
let x: i32 = 0
let y: i32 = 0
let width: i32 = 100
let height: i32 = 100
let x: i32 = raylib::GetScreenWidth() / 2 - (width / 2)
let y: i32 = raylib::GetScreenHeight() / 2 - (height / 2)
let direction: raylib::Vector2 = { x = 1 y = 1 }
let bgColor: raylib::Color = { r = 0 g = 0 b = 0 a = 255 }
@@ -28,12 +28,12 @@ extern "main" func main(args: []cstring): i64
}
raylib::EndDrawing()
if x + width > raylib::GetScreenWidth()
if x + width >= raylib::GetScreenWidth() || x <= 0
{
direction.x = -direction.x
}
if y + height > raylib::GetScreenHeight()
if y + height >= raylib::GetScreenHeight() || y <= 0
{
direction.y = -direction.y
}