About Social Code
summaryrefslogtreecommitdiff
path: root/chunk.rhm
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2025-03-23 00:17:59 +0000
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2025-03-23 00:17:59 +0000
commita2feba2d918db861ea85d22887f73993c173e742 (patch)
tree7027dc2ded85a2ef0f8982e75099434f68c4a0d8 /chunk.rhm
parentbca429dd94dafc49cf9134040dfdfb6baf0de10c (diff)
Reorganize source, create basic threading and server
Need to create main world loop and have it message with web server
Diffstat (limited to 'chunk.rhm')
-rw-r--r--chunk.rhm58
1 files changed, 0 insertions, 58 deletions
diff --git a/chunk.rhm b/chunk.rhm
deleted file mode 100644
index 3ded42d..0000000
--- a/chunk.rhm
+++ /dev/null
@@ -1,58 +0,0 @@
-#lang rhombus/static
-
-export:
- Direction
- TileType
- Tile
- Chunk
- flip_block
-
-enum Direction:
- north
- north_east
- east
- south_east
- south
- south_west
- west
- north_west
-
-enum TileType:
- empty
- wall_north
-
-fun flip_block(block :: maybe(Direction)) :: maybe(Direction):
- match block
- | Direction.north: Direction.south
- | Direction.north_east: Direction.south_west
- | Direction.east: Direction.west
- | Direction.south_east: Direction.north_west
- | Direction.south: Direction.north
- | Direction.south_west: Direction.north_east
- | Direction.west: Direction.east
- | Direction.north_west: Direction.south_east
- | ~else: #false
-
-class Tile(type :: TileType):
- method get_block() :: maybe(Direction):
- match type
- | TileType.empty: #false
- | TileType.wall_north: Direction.north
-
-class Chunk(width :: Int,
- height :: Int,
- offset_x :: Int,
- offset_y :: Int,
- tiles :: Array.now_of(Tile),
- neighbours :: MutableMap.now_of(Direction, Chunk)):
- constructor(width :: Int, height :: Int, offset_x :: Int, offset_y :: Int):
- super(width, height, offset_x, offset_y, Array.make(width * height, Tile(TileType.empty)), MutableMap())
-
- method add_neighbour(chunk :: Chunk, direction :: Direction):
- neighbours[direction] := chunk
-
- method get_tile(x :: Int, y :: Int) :: Tile:
- tiles[y * width + x]
-
- method set_tile(x :: Int, y :: Int, tile :: Tile):
- tiles[y * width + x] := tile