mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-04-30 08:21:47 -04:00
Basic rotation!
- Switched to WSAD cause that's easier
This commit is contained in:
parent
86aa6ef65c
commit
b7d7fdcfcd
1 changed files with 40 additions and 12 deletions
44
src/main.zig
44
src/main.zig
|
@ -11,6 +11,18 @@ const GameScreen = enum {
|
|||
lot,
|
||||
};
|
||||
|
||||
const Rotations = enum {
|
||||
left,
|
||||
right,
|
||||
pub fn changeRotions(self: Rotations) Rotations {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn init(self: Rotations) Rotations {
|
||||
return self;
|
||||
}
|
||||
};
|
||||
|
||||
// Still in the proof of concept phase, don't mind the mess
|
||||
pub fn main() anyerror!void {
|
||||
const screen_width = 800;
|
||||
|
@ -25,7 +37,7 @@ pub fn main() anyerror!void {
|
|||
// var zoom: f32 = 10;
|
||||
|
||||
var camera = rl.Camera3D{
|
||||
.position = rl.Vector3.init(0.0, 20.0, 90.0),
|
||||
.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,
|
||||
|
@ -35,6 +47,8 @@ pub fn main() anyerror!void {
|
|||
const floorLevel = rl.Vector3.init(0.0, 0.0, 0.0);
|
||||
const itemStatic = rl.Vector3.init(0.0, 2.0, 0.0);
|
||||
|
||||
var get_rotate = Rotations.init(Rotations.right);
|
||||
|
||||
// const planePosition = rl.Vector3.init(0.0, 0.0, 0.0);
|
||||
|
||||
// var textBox = rl.Rectangle.init(screen_width / 2.0 - 100, 180, 50);
|
||||
|
@ -48,10 +62,12 @@ pub fn main() anyerror!void {
|
|||
// defer rl.closeAudioDevice();
|
||||
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");
|
||||
defer rl.unloadTexture(splash);
|
||||
defer rl.unloadTexture(logo);
|
||||
defer rl.unloadTexture(table4);
|
||||
defer rl.unloadTexture(table3);
|
||||
|
||||
while (!rl.windowShouldClose()) {
|
||||
|
||||
|
@ -71,18 +87,16 @@ pub fn main() anyerror!void {
|
|||
.lot => {
|
||||
const zoom_increment = 5;
|
||||
|
||||
if (rl.isKeyPressed(rl.KeyboardKey.key_equal)) {
|
||||
if (camera.fovy <= 10 or camera.fovy >= 20) {
|
||||
if (rl.isKeyPressed(rl.KeyboardKey.key_s)) {
|
||||
if (camera.fovy == 10) {
|
||||
camera.fovy += zoom_increment;
|
||||
}
|
||||
|
||||
dbg.print("Zoom level: {any}\n", .{
|
||||
camera.fovy,
|
||||
});
|
||||
}
|
||||
|
||||
if (rl.isKeyPressed(rl.KeyboardKey.key_minus)) {
|
||||
if (camera.fovy <= 10 or camera.fovy >= 2.0) {
|
||||
} else if (rl.isKeyPressed(rl.KeyboardKey.key_w)) {
|
||||
if (camera.fovy == 15) {
|
||||
camera.fovy -= zoom_increment;
|
||||
}
|
||||
|
||||
|
@ -91,6 +105,16 @@ pub fn main() anyerror!void {
|
|||
});
|
||||
}
|
||||
|
||||
if (rl.isKeyPressed(rl.KeyboardKey.key_a)) {
|
||||
camera.position = rl.Vector3.init(-90.0, 20.0, 90.0);
|
||||
get_rotate = Rotations.changeRotions(Rotations.left);
|
||||
dbg.print("Roate right\n", .{});
|
||||
} else if (rl.isKeyPressed(rl.KeyboardKey.key_d)) {
|
||||
camera.position = rl.Vector3.init(90.0, 20.0, 90.0);
|
||||
get_rotate = Rotations.changeRotions(Rotations.right);
|
||||
dbg.print("Roate left\n", .{});
|
||||
}
|
||||
|
||||
// camera.update(rl.CameraMode.camera_custom);
|
||||
},
|
||||
}
|
||||
|
@ -121,7 +145,11 @@ pub fn main() anyerror!void {
|
|||
defer camera.end();
|
||||
|
||||
rl.drawPlane(floorLevel, rl.Vector2.init(64, 64), rl.Color.dark_green);
|
||||
rl.drawBillboard(camera, table4, itemStatic, 2.0, rl.Color.white);
|
||||
switch (get_rotate) {
|
||||
.right => rl.drawBillboard(camera, table4, itemStatic, 2.0, rl.Color.white),
|
||||
.left => rl.drawBillboard(camera, table3, itemStatic, 2.0, rl.Color.white),
|
||||
}
|
||||
|
||||
// rl.drawGrid(64, 1.0);
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue