Skip to content

Commit

Permalink
Map view
Browse files Browse the repository at this point in the history
- Not a perfect map view, butit does work
- Removed changeRotations() in favor of init()
- Removed FreeBSD and Tiers from system requirements in README
- Fixed typo in README
  • Loading branch information
Tony Bark committed May 7, 2024
1 parent 77eefcf commit 00255a6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 34 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ See [motivation.md](./docs/motivation.md) for motivation and vision.
- API Server
- [.NET](https://dotnet.microsoft.com/en-us/) 8.0+
- [Mockoon](https://mockoon.com/) for mock APIs (Optional)
- Libaries & Tools
- Libraries & Tools
- TBA

### System Requirements

| Platform | Version | Tier |
| --- | --- | --- |
| Windows | 10+ | 1 |
| Linux | 3.16+ | 1 |
| macOS | 11.0+ | 1 |
| FreeBSD | 12.0+ | 2 |
| Platform | Version | Architectures |
| -------- | ------- | --------------- |
| Windows | 10+ | x86_64, aarch64 |
| Linux | 3.16+ | x86_64 |
| macOS | 11.0+ | x86_64, aarch64 |

## Getting Started

Expand Down
4 changes: 1 addition & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ pub fn build(b: *std.Build) void {
});

exe_unit_tests.linkLibC();
exe_unit_tests.addIncludePath(.{ .path = "./library/formats" });
exe_unit_tests.addIncludePath(.{ .path = "./library/libvitaboy" });
exe_unit_tests.addIncludePath(.{ .path = "./tools" });
exe_unit_tests.addIncludePath(.{ .path = "./library" });

exe_unit_tests.root_module.addImport("raylib", raylib);
exe_unit_tests.root_module.addImport("raylib-math", raylib_math);
Expand Down
66 changes: 42 additions & 24 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const GameScreen = enum {
const Rotations = enum {
left,
right,
pub fn changeRotions(self: Rotations) Rotations {
return self;
}

pub fn init(self: Rotations) Rotations {
return self;
Expand All @@ -34,31 +31,45 @@ pub fn main() anyerror!void {
var current_screen: GameScreen = .login;
var frame_counter: i32 = 0;

// var zoom: f32 = 10;

var camera = rl.Camera3D{
var lot_camera = rl.Camera3D{
.position = rl.Vector3.init(-90.0, 20.0, 90.0),
.target = rl.Vector3.init(0, 0.0, 0),
.up = rl.Vector3.init(0, 1.0, 0),
.fovy = 10,
.projection = rl.CameraProjection.camera_orthographic,
};

var city_camera = rl.Camera3D{
.position = rl.Vector3.init(18.0, 21.0, 18),
.target = rl.Vector3.init(0, 0, 0),
.up = rl.Vector3.init(0, 1.0, 0),
.fovy = 45,
.projection = rl.CameraProjection.camera_perspective,
};

const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0);
const itemStatic = rl.Vector3.init(0.0, 2.0, 0.0);
const itemStatic = rl.Vector3.init(0.0, 1.0, 0.0);

var rotation_manger = Rotations.init(Rotations.right);
var rotation_manager = Rotations.init(Rotations.left);

rl.setTargetFPS(60);

const logo = rl.Texture.init("resources/logo.png");
const splash = rl.Texture.init("resources/tsosplash.png");
const table3 = rl.Texture.init("resources/items/dorms/table_3.png");
const table4 = rl.Texture.init("resources/items/dorms/table_4.png");
const city = rl.loadImage("resources/cities/city_0100/elevation.png");
// const city_texture = rl.Texture.init("resources/cities/city_0100/vertexcolor.png");
defer rl.unloadTexture(splash);
defer rl.unloadTexture(logo);
defer rl.unloadTexture(table4);
defer rl.unloadTexture(table3);
defer rl.unloadImage(city);

const mesh = rl.genMeshHeightmap(city, rl.Vector3.init(16, 8, 16));
const model = rl.loadModelFromMesh(mesh);

// model.materials[0].maps[rl.MATERIAL_MAP_DIFFUSE].texture = city_texture;

while (!rl.windowShouldClose()) {

Expand All @@ -79,30 +90,30 @@ pub fn main() anyerror!void {
const zoom_increment = 5;

if (rl.isKeyPressed(rl.KeyboardKey.key_s)) {
if (camera.fovy == 10) {
camera.fovy += zoom_increment;
if (lot_camera.fovy == 10) {
lot_camera.fovy += zoom_increment;
}

dbg.print("Zoom level: {any}\n", .{
camera.fovy,
lot_camera.fovy,
});
} else if (rl.isKeyPressed(rl.KeyboardKey.key_w)) {
if (camera.fovy == 15) {
camera.fovy -= zoom_increment;
if (lot_camera.fovy == 15) {
lot_camera.fovy -= zoom_increment;
}

dbg.print("Zoom level: {any}\n", .{
camera.fovy,
lot_camera.fovy,
});
}

if (rl.isKeyPressed(rl.KeyboardKey.key_a)) {
camera.position = rl.Vector3.init(-90.0, 20.0, 90.0);
rotation_manger = Rotations.changeRotions(Rotations.left);
lot_camera.position = rl.Vector3.init(-90.0, 20.0, 90.0);
rotation_manager = Rotations.init(Rotations.left);
dbg.print("Rotate right\n", .{});
} else if (rl.isKeyPressed(rl.KeyboardKey.key_d)) {
camera.position = rl.Vector3.init(90.0, 20.0, 90.0);
rotation_manger = Rotations.changeRotions(Rotations.right);
lot_camera.position = rl.Vector3.init(90.0, 20.0, 90.0);
rotation_manager = Rotations.init(Rotations.right);
dbg.print("Rotate left\n", .{});
}

Expand All @@ -127,18 +138,25 @@ pub fn main() anyerror!void {
},
// Skip this for now
.cas => {},
.map => {},
.map => {
rl.clearBackground(rl.Color.sky_blue);

city_camera.begin();
defer city_camera.end();

rl.drawModel(model, floorLevel, 1.0, rl.Color.green);
},
// Low view (i.e. world)
.lot => {
rl.clearBackground(rl.Color.sky_blue);

camera.begin();
defer camera.end();
lot_camera.begin();
defer lot_camera.end();

rl.drawPlane(floorLevel, rl.Vector2.init(64, 64), rl.Color.dark_green);
switch (rotation_manger) {
.right => rl.drawBillboard(camera, table4, itemStatic, 2.0, rl.Color.white),
.left => rl.drawBillboard(camera, table3, itemStatic, 2.0, rl.Color.white),
switch (rotation_manager) {
.right => rl.drawBillboard(lot_camera, table4, itemStatic, 2.0, rl.Color.white),
.left => rl.drawBillboard(lot_camera, table3, itemStatic, 2.0, rl.Color.white),
}

// rl.drawGrid(64, 1.0);
Expand Down

0 comments on commit 00255a6

Please sign in to comment.