Remove redundant namespaces from enums (#178)

This commit is contained in:
vent 2024-12-23 20:27:02 +00:00 committed by GitHub
parent 0dcee846f4
commit 845af357e4
Failed to generate hash of commit
15 changed files with 620 additions and 620 deletions

View file

@ -69,7 +69,7 @@ pub fn main() anyerror!void {
// Update
//----------------------------------------------------------------------------------
if (rl.isMouseButtonDown(.mouse_button_left)) {
if (rl.isMouseButtonDown(.left)) {
// Sample mouse input.
const mousePosition = rl.getMousePosition();

View file

@ -51,9 +51,9 @@ pub fn main() anyerror!void {
//----------------------------------------------------------------------------------
// Player movement
if (rl.isKeyDown(rl.KeyboardKey.key_right)) {
if (rl.isKeyDown(.right)) {
player.x += 2;
} else if (rl.isKeyDown(rl.KeyboardKey.key_left)) {
} else if (rl.isKeyDown(.left)) {
player.x -= 2;
}
@ -61,9 +61,9 @@ pub fn main() anyerror!void {
camera.target = rl.Vector2.init(player.x + 20, player.y + 20);
// Camera rotation controls
if (rl.isKeyDown(rl.KeyboardKey.key_a)) {
if (rl.isKeyDown(.a)) {
camera.rotation -= 1;
} else if (rl.isKeyDown(rl.KeyboardKey.key_s)) {
} else if (rl.isKeyDown(.s)) {
camera.rotation += 1;
}
@ -76,7 +76,7 @@ pub fn main() anyerror!void {
camera.zoom = rl.math.clamp(camera.zoom, 0.1, 3.0);
// Camera reset (zoom and rotation)
if (rl.isKeyPressed(rl.KeyboardKey.key_r)) {
if (rl.isKeyPressed(.r)) {
camera.zoom = 1.0;
camera.rotation = 0.0;
}

View file

@ -27,14 +27,14 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
if (rl.isKeyPressed(.key_one)) {
if (rl.isKeyPressed(.one)) {
zoomMode = 0;
} else if (rl.isKeyPressed(.key_two)) {
} else if (rl.isKeyPressed(.two)) {
zoomMode = 1;
}
// Translate based on mouse right click
if (rl.isMouseButtonDown(.mouse_button_right)) {
if (rl.isMouseButtonDown(.right)) {
var delta = rl.getMouseDelta();
delta = rl.math.vector2Scale(delta, -1.0 / camera.zoom);
camera.target = rl.math.vector2Add(camera.target, delta);
@ -63,7 +63,7 @@ pub fn main() anyerror!void {
}
} else {
// Zoom based on left click
if (rl.isMouseButtonPressed(.mouse_button_left)) {
if (rl.isMouseButtonPressed(.left)) {
// Get the world point that is under the mouse
const mouseWorldPos = rl.getScreenToWorld2D(rl.getMousePosition(), camera);
@ -74,7 +74,7 @@ pub fn main() anyerror!void {
// under the cursor to the screen space point under the cursor at any zoom
camera.target = mouseWorldPos;
}
if (rl.isMouseButtonDown(.mouse_button_left)) {
if (rl.isMouseButtonDown(.left)) {
// Zoom increment
const deltaX = rl.getMouseDelta().x;
var scaleFactor = 1.0 + (0.01 * @abs(deltaX));

View file

@ -18,7 +18,7 @@ pub fn main() anyerror!void {
.target = rl.Vector3.init(0, 1.8, 0),
.up = rl.Vector3.init(0, 1, 0),
.fovy = 60,
.projection = rl.CameraProjection.camera_perspective,
.projection = .perspective,
};
var heights: [MAX_COLUMNS]f32 = undefined;
@ -48,7 +48,7 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
camera.update(rl.CameraMode.camera_first_person);
camera.update(.first_person);
//----------------------------------------------------------------------------------
// Draw

View file

@ -20,7 +20,7 @@ pub fn main() anyerror!void {
.target = rl.Vector3.init(0, 0, 0),
.up = rl.Vector3.init(0, 1, 0),
.fovy = 45,
.projection = rl.CameraProjection.camera_perspective,
.projection = .perspective,
};
const cubePosition = rl.Vector3.init(0, 0, 0);
@ -33,9 +33,9 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) { // Detect window close button or ESC key
// Update
//-----------------------------------------------------------------------------
camera.update(rl.CameraMode.camera_free);
camera.update(.free);
if (rl.isKeyPressed(rl.KeyboardKey.key_z)) {
if (rl.isKeyPressed(.z)) {
camera.target = rl.Vector3.init(0, 0, 0);
}
//-----------------------------------------------------------------------------

View file

@ -15,7 +15,7 @@ pub fn main() anyerror!void {
.target = rl.Vector3.init(0, 0, 0),
.up = rl.Vector3.init(0, 1, 0),
.fovy = 45,
.projection = rl.CameraProjection.camera_perspective,
.projection = .perspective,
};
const cubePosition = rl.Vector3.init(0, 1, 0);
@ -31,14 +31,14 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
if (rl.isCursorHidden()) rl.updateCamera(&camera, rl.CameraMode.camera_first_person);
if (rl.isCursorHidden()) rl.updateCamera(&camera, .first_person);
// Toggle camera controls
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_right)) {
if (rl.isMouseButtonPressed(.right)) {
if (rl.isCursorHidden()) rl.enableCursor() else rl.disableCursor();
}
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_left)) {
if (rl.isMouseButtonPressed(.left)) {
if (!collision.hit) {
ray = rl.getScreenToWorldRay(rl.getMousePosition(), camera);

View file

@ -56,7 +56,7 @@ pub fn main() anyerror!void {
// TODO: Update `title` state variables here!
// Press ENTER to change to `gameplay` state
if (rl.isKeyPressed(.key_enter) or rl.isGestureDetected(.gesture_tap)) {
if (rl.isKeyPressed(.enter) or rl.isGestureDetected(.tap)) {
current_screen = .gameplay;
}
},
@ -64,7 +64,7 @@ pub fn main() anyerror!void {
// TODO: Update `gameplay` state variables here!
// Press ENTER to change to `ending` state
if (rl.isKeyPressed(.key_enter) or rl.isGestureDetected(.gesture_tap)) {
if (rl.isKeyPressed(.enter) or rl.isGestureDetected(.tap)) {
current_screen = .ending;
}
},
@ -72,7 +72,7 @@ pub fn main() anyerror!void {
// TODO: Update `ending` state variables here!
// Press ENTER to return to `title` state
if (rl.isKeyPressed(.key_enter) or rl.isGestureDetected(.gesture_tap)) {
if (rl.isKeyPressed(.enter) or rl.isGestureDetected(.tap)) {
current_screen = .title;
}
},

View file

@ -21,16 +21,16 @@ pub fn main() anyerror!void {
// Update
//----------------------------------------------------------------------------------
if (rl.isKeyDown(rl.KeyboardKey.key_right)) {
if (rl.isKeyDown(.right)) {
ballPosition.x += 2.0;
}
if (rl.isKeyDown(rl.KeyboardKey.key_left)) {
if (rl.isKeyDown(.left)) {
ballPosition.x -= 2.0;
}
if (rl.isKeyDown(rl.KeyboardKey.key_up)) {
if (rl.isKeyDown(.up)) {
ballPosition.y -= 2.0;
}
if (rl.isKeyDown(rl.KeyboardKey.key_down)) {
if (rl.isKeyDown(.down)) {
ballPosition.y += 2.0;
}
//----------------------------------------------------------------------------------

View file

@ -25,11 +25,11 @@ pub fn main() anyerror!void {
ballPosition.x = @as(f32, @floatFromInt(rl.getMouseX()));
ballPosition.y = @as(f32, @floatFromInt(rl.getMouseY()));
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_left)) {
if (rl.isMouseButtonPressed(.left)) {
ballColor = rl.Color.maroon;
} else if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_middle)) {
} else if (rl.isMouseButtonPressed(.middle)) {
ballColor = rl.Color.lime;
} else if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_right)) {
} else if (rl.isMouseButtonPressed(.right)) {
ballColor = rl.Color.dark_blue;
}
//----------------------------------------------------------------------------------

View file

@ -28,23 +28,23 @@ pub fn main() anyerror!void {
ballColor = rl.Color.beige;
if (rl.isMouseButtonDown(rl.MouseButton.mouse_button_left)) {
if (rl.isMouseButtonDown(.left)) {
ballColor = rl.Color.maroon;
}
if (rl.isMouseButtonDown(rl.MouseButton.mouse_button_middle)) {
if (rl.isMouseButtonDown(.middle)) {
ballColor = rl.Color.lime;
}
if (rl.isMouseButtonDown(rl.MouseButton.mouse_button_right)) {
if (rl.isMouseButtonDown(.right)) {
ballColor = rl.Color.dark_blue;
}
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_left)) {
if (rl.isMouseButtonPressed(.left)) {
touchCounter = 10;
}
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_middle)) {
if (rl.isMouseButtonPressed(.middle)) {
touchCounter = 10;
}
if (rl.isMouseButtonPressed(rl.MouseButton.mouse_button_right)) {
if (rl.isMouseButtonPressed(.right)) {
touchCounter = 10;
}

View file

@ -58,9 +58,9 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) {
// Update
// ---------------------------------------------------------------------
if (rl.isKeyPressed(.key_f)) rl.toggleFullscreen(); // Modifies window size when scaling!
if (rl.isKeyPressed(.f)) rl.toggleFullscreen(); // Modifies window size when scaling!
if (rl.isKeyPressed(.key_r)) {
if (rl.isKeyPressed(.r)) {
if (rl.isWindowState(rl.ConfigFlags { .window_resizable = true })) {
rl.clearWindowState(rl.ConfigFlags { .window_resizable = true });
} else {
@ -68,7 +68,7 @@ pub fn main() anyerror!void {
}
}
if (rl.isKeyPressed(.key_d)) {
if (rl.isKeyPressed(.d)) {
if (rl.isWindowState(rl.ConfigFlags { .window_undecorated = true })) {
rl.clearWindowState(rl.ConfigFlags { .window_undecorated = true });
} else {
@ -76,7 +76,7 @@ pub fn main() anyerror!void {
}
}
if (rl.isKeyPressed(.key_h)) {
if (rl.isKeyPressed(.h)) {
if (!rl.isWindowState(rl.ConfigFlags { .window_hidden = true })) {
rl.setWindowState(rl.ConfigFlags { .window_hidden = true });
}
@ -88,7 +88,7 @@ pub fn main() anyerror!void {
if (frames_counter >= 240) rl.clearWindowState(rl.ConfigFlags { .window_hidden = true }); // Show window after 3 seconds
}
if (rl.isKeyPressed(.key_n)) {
if (rl.isKeyPressed(.n)) {
if (!rl.isWindowState(rl.ConfigFlags { .window_minimized = true })) {
rl.minimizeWindow();
}
@ -100,32 +100,32 @@ pub fn main() anyerror!void {
if (frames_counter >= 240) rl.restoreWindow(); // Restore window after 3 seconds
}
if (rl.isKeyPressed(.key_m)) {
if (rl.isKeyPressed(.m)) {
// NOTE: Requires `flag_window_resizable` enabled!
if (rl.isWindowState(rl.ConfigFlags { .window_maximized = true })) {
rl.restoreWindow();
} else rl.maximizeWindow();
}
if (rl.isKeyPressed(.key_u)) {
if (rl.isKeyPressed(.u)) {
if (rl.isWindowState(rl.ConfigFlags { .window_unfocused = true })) {
rl.clearWindowState(rl.ConfigFlags { .window_unfocused = true });
} else rl.setWindowState(rl.ConfigFlags { .window_unfocused = true });
}
if (rl.isKeyPressed(.key_t)) {
if (rl.isKeyPressed(.t)) {
if (rl.isWindowState(rl.ConfigFlags { .window_topmost = true })) {
rl.clearWindowState(rl.ConfigFlags { .window_topmost = true });
} else rl.setWindowState(rl.ConfigFlags { .window_topmost = true });
}
if (rl.isKeyPressed(.key_a)) {
if (rl.isKeyPressed(.a)) {
if (rl.isWindowState(rl.ConfigFlags { .window_always_run = true })) {
rl.clearWindowState(rl.ConfigFlags { .window_always_run = true });
} else rl.setWindowState(rl.ConfigFlags { .window_always_run = true });
}
if (rl.isKeyPressed(.key_v)) {
if (rl.isKeyPressed(.v)) {
if (rl.isWindowState(rl.ConfigFlags { .vsync_hint = true })) {
rl.clearWindowState(rl.ConfigFlags { .vsync_hint = true });
} else rl.setWindowState(rl.ConfigFlags { .vsync_hint = true });

View file

@ -38,19 +38,19 @@ pub fn main() anyerror!void {
shdrOutline,
outlineSizeLoc,
&outlineSize,
rl.ShaderUniformDataType.shader_uniform_float,
.float,
);
rl.setShaderValue(
shdrOutline,
outlineColorLoc,
&outlineColor,
rl.ShaderUniformDataType.shader_uniform_vec4,
.vec4,
);
rl.setShaderValue(
shdrOutline,
textureSizeLoc,
&textureSize,
rl.ShaderUniformDataType.shader_uniform_vec2,
.vec2,
);
rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -67,7 +67,7 @@ pub fn main() anyerror!void {
shdrOutline,
outlineSizeLoc,
&outlineSize,
rl.ShaderUniformDataType.shader_uniform_float,
.float,
);
//----------------------------------------------------------------------------------

View file

@ -51,9 +51,9 @@ pub fn main() anyerror!void {
}
// Control frames speed
if (rl.isKeyPressed(rl.KeyboardKey.key_right)) {
if (rl.isKeyPressed(.right)) {
framesSpeed += 1;
} else if (rl.isKeyPressed(rl.KeyboardKey.key_left)) {
} else if (rl.isKeyPressed(.left)) {
framesSpeed -= 1;
}