Compiler game work + enable cast from pointer to int
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
#import "raylib.core"
|
||||
|
||||
#load "array.core"
|
||||
|
||||
/*@feature_idea: labeled block
|
||||
|
||||
@@ -63,9 +60,23 @@ Add(&guys, {100, 100})
|
||||
//
|
||||
// Map map = (Map ){.data = (&(map_data[0])), .data = 0x10, .x = 16};
|
||||
|
||||
// @reproduction
|
||||
// if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = {x,y}
|
||||
//
|
||||
// Error! Couldn't infer type of compound expression
|
||||
//
|
||||
// Couldn't figure out type of compound expression when variable got declared and separetly
|
||||
// got assigned a value
|
||||
//
|
||||
|
||||
Guy :: struct
|
||||
pos: Vector2
|
||||
|
||||
#import "raylib.core"
|
||||
MA :: #import "Arena.core"
|
||||
#load "array.core"
|
||||
|
||||
V2I :: struct
|
||||
x: int
|
||||
y: int
|
||||
|
||||
Map_Tile :: int
|
||||
Map :: struct
|
||||
@@ -73,54 +84,85 @@ Map :: struct
|
||||
x: int
|
||||
y: int
|
||||
|
||||
SCR_X := 1280
|
||||
SCR_Y := 720
|
||||
Actor :: struct
|
||||
p: V2I
|
||||
target_p: V2I
|
||||
|
||||
M_X := 0
|
||||
M_Y := 0
|
||||
M_P: Vector2
|
||||
WinX := 1280
|
||||
WinY := 720
|
||||
|
||||
MouseX := 0
|
||||
MouseY := 0
|
||||
MouseP: Vector2
|
||||
|
||||
Mode := 0
|
||||
RectX :: 16
|
||||
RectY :: 16
|
||||
|
||||
GuyP: V2I
|
||||
|
||||
main :: (): int
|
||||
guys: Array(Guy)
|
||||
Add(&guys, {pos = {100, 100}})
|
||||
|
||||
|
||||
map_data: [16*16]int
|
||||
map: Map = {data = &map_data[0], x = 16, y = 16}
|
||||
MAP_X :: 60
|
||||
MAP_Y :: 40
|
||||
map_data: [MAP_X*MAP_Y]int
|
||||
map: Map = {data = &map_data[0], x = MAP_X, y = MAP_Y}
|
||||
|
||||
InitWindow(SCR_X, SCR_Y, "Testing")
|
||||
SetTargetFPS(60)
|
||||
actors: Array(Actor)
|
||||
Reserve(&actors, 4)
|
||||
|
||||
Add(&actors, {{4, 4}, {8, 8}})
|
||||
Assert(Contains(&actors, actors.data) == true)
|
||||
OrderedRemove(&actors, actors.data)
|
||||
Assert(Contains(&actors, actors.data) == false)
|
||||
|
||||
// InitAudioDevice()
|
||||
// sound := LoadSound("catune - Pass the town, and to the C.mp3")
|
||||
// SetMasterVolume(0.01)
|
||||
// PlaySound(sound)
|
||||
|
||||
InitWindow(WinX, WinY, "Testing")
|
||||
SetTargetFPS(60)
|
||||
|
||||
for !WindowShouldClose()
|
||||
SCR_X = GetScreenWidth()
|
||||
SCR_Y = GetScreenHeight()
|
||||
M_X = GetMouseX()
|
||||
M_Y = GetMouseY()
|
||||
M_P = GetMousePosition()
|
||||
WinX = GetScreenWidth()
|
||||
WinY = GetScreenHeight()
|
||||
MouseX = GetMouseX()
|
||||
MouseY = GetMouseY()
|
||||
MouseP = GetMousePosition()
|
||||
|
||||
if IsKeyPressed(KEY_F1) ;; Mode := 0
|
||||
if IsKeyPressed(KEY_F2) ;; Mode := 1
|
||||
|
||||
BeginDrawing()
|
||||
ClearBackground(RAYWHITE)
|
||||
|
||||
RX := 16
|
||||
RY := 16
|
||||
for x := 0, x < 16, x += 1
|
||||
for y := 0, y < 16, y += 1
|
||||
it := map.data[x + y*map.x]
|
||||
r: Rectangle = {(x * RX)->F32, (y * RY)->F32, RX->F32, RY->F32}
|
||||
for x := 0, x < map.x, x += 1
|
||||
for y := 0, y < map.y, y += 1
|
||||
it := map.data + (x + y*map.x)
|
||||
r: Rectangle = {x->F32 * RectX, y->F32 * RectY, RectX, RectY}
|
||||
r2: Rectangle = {r.x + 1, r.y + 1, r.width - 2, r.height - 2}
|
||||
|
||||
color := RED
|
||||
if it == 1 ;; color = GREEN
|
||||
if CheckCollisionPointRec(M_P, r) ;; color = BLUE
|
||||
colliding := CheckCollisionPointRec(MouseP, r)
|
||||
|
||||
if Mode == 0 && colliding && IsMouseButtonDown(MOUSE_BUTTON_LEFT) ;; *it = 1
|
||||
if Mode == 0 && colliding && IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) ;; GuyP = V2I{x,y}
|
||||
|
||||
color := GREEN
|
||||
if *it == 1 ;; color = RED
|
||||
if colliding == true ;; color = MAROON
|
||||
|
||||
DrawRectangleRec(r2, color)
|
||||
|
||||
for i := 0, i < actors.len, i += 1
|
||||
it := actors.data + i
|
||||
r := Rectangle{it.p.x->F32 * RectX, it.p.y->F32 * RectY, RectX, RectY}
|
||||
target_r := Rectangle{it.target_p.x->F32 * RectX, it.target_p.y->F32 * RectY, RectX, RectY}
|
||||
|
||||
DrawRectangleRec(r, YELLOW)
|
||||
DrawRectangleRec(target_r, PURPLE)
|
||||
|
||||
|
||||
// DrawFPS(0, 0)
|
||||
// DrawText(TextFormat("Testing %d", 32), 100, 100, 20, MAROON)
|
||||
|
||||
Reference in New Issue
Block a user