mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 12:07:27 +00:00
examples: Use decl literals (#221)
This commit is contained in:
parent
03ec79ef85
commit
d4fc514d54
@ -38,9 +38,9 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray);
|
rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ const CircleWave = struct {
|
|||||||
const screenWidth = 800;
|
const screenWidth = 800;
|
||||||
const screenHeight = 450;
|
const screenHeight = 450;
|
||||||
|
|
||||||
const colors = [14]rl.Color{ rl.Color.orange, rl.Color.red, rl.Color.gold, rl.Color.lime, rl.Color.blue, rl.Color.violet, rl.Color.brown, rl.Color.light_gray, rl.Color.pink, rl.Color.yellow, rl.Color.green, rl.Color.sky_blue, rl.Color.purple, rl.Color.beige };
|
const colors = [14]rl.Color{ .orange, .red, .gold, .lime, .blue, .violet, .brown, .light_gray, .pink, .yellow, .green, .sky_blue, .purple, .beige };
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
@ -57,14 +57,14 @@ pub fn main() !void {
|
|||||||
rl.updateMusicStream(music); // Update music buffer with new stream data
|
rl.updateMusicStream(music); // Update music buffer with new stream data
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
// Restart music playing (stop and play)
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.space)) {
|
if (rl.isKeyPressed(.space)) {
|
||||||
rl.stopMusicStream(music);
|
rl.stopMusicStream(music);
|
||||||
rl.playMusicStream(music);
|
rl.playMusicStream(music);
|
||||||
pause = false;
|
pause = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause/Resume music playing
|
// Pause/Resume music playing
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.p)) {
|
if (rl.isKeyPressed(.p)) {
|
||||||
pause = !pause;
|
pause = !pause;
|
||||||
|
|
||||||
if (pause) {
|
if (pause) {
|
||||||
@ -74,9 +74,9 @@ pub fn main() !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rl.isKeyDown(rl.KeyboardKey.down)) {
|
if (rl.isKeyDown(.down)) {
|
||||||
pitch -= 0.01;
|
pitch -= 0.01;
|
||||||
} else if (rl.isKeyDown(rl.KeyboardKey.up)) {
|
} else if (rl.isKeyDown(.up)) {
|
||||||
pitch += 0.01;
|
pitch += 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,24 +103,24 @@ pub fn main() !void {
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
for (circles) |circle| {
|
for (circles) |circle| {
|
||||||
rl.drawCircleV(circle.position, circle.radius, rl.fade(circle.color, circle.alpha));
|
rl.drawCircleV(circle.position, circle.radius, .fade(circle.color, circle.alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw time bar
|
// Draw time bar
|
||||||
rl.drawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, rl.Color.light_gray);
|
rl.drawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, .light_gray);
|
||||||
rl.drawRectangle(20, screenHeight - 20 - 12, @intFromFloat(timePlayed), 12, rl.Color.maroon);
|
rl.drawRectangle(20, screenHeight - 20 - 12, @intFromFloat(timePlayed), 12, .maroon);
|
||||||
rl.drawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, rl.Color.gray);
|
rl.drawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, .gray);
|
||||||
|
|
||||||
// Draw help instructions
|
// Draw help instructions
|
||||||
rl.drawRectangle(20, 20, 425, 145, rl.Color.white);
|
rl.drawRectangle(20, 20, 425, 145, .white);
|
||||||
rl.drawRectangleLines(20, 20, 425, 145, rl.Color.gray);
|
rl.drawRectangleLines(20, 20, 425, 145, .gray);
|
||||||
rl.drawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, rl.Color.black);
|
rl.drawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, .black);
|
||||||
rl.drawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, rl.Color.black);
|
rl.drawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, .black);
|
||||||
rl.drawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, rl.Color.black);
|
rl.drawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, .black);
|
||||||
rl.drawText(rl.textFormat("SPEED: %f", .{pitch}), 40, 130, 20, rl.Color.maroon);
|
rl.drawText(rl.textFormat("SPEED: %f", .{pitch}), 40, 130, 20, .maroon);
|
||||||
|
|
||||||
rl.endDrawing();
|
rl.endDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -34,13 +34,13 @@ pub fn main() !void {
|
|||||||
rl.updateMusicStream(music); // Update music buffer with new stream data
|
rl.updateMusicStream(music); // Update music buffer with new stream data
|
||||||
|
|
||||||
// Restart music playing (stop and play)
|
// Restart music playing (stop and play)
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.space)) {
|
if (rl.isKeyPressed(.space)) {
|
||||||
rl.stopMusicStream(music);
|
rl.stopMusicStream(music);
|
||||||
rl.playMusicStream(music);
|
rl.playMusicStream(music);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause/Resume music playing
|
// Pause/Resume music playing
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.p)) {
|
if (rl.isKeyPressed(.p)) {
|
||||||
pause = !pause;
|
pause = !pause;
|
||||||
|
|
||||||
if (pause) {
|
if (pause) {
|
||||||
@ -63,16 +63,16 @@ pub fn main() !void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.Color.light_gray);
|
rl.drawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, .light_gray);
|
||||||
|
|
||||||
rl.drawRectangle(200, 200, 400, 12, rl.Color.light_gray);
|
rl.drawRectangle(200, 200, 400, 12, .light_gray);
|
||||||
rl.drawRectangle(200, 200, @intFromFloat(timePlayed * 400), 12, rl.Color.maroon);
|
rl.drawRectangle(200, 200, @intFromFloat(timePlayed * 400), 12, .maroon);
|
||||||
rl.drawRectangleLines(200, 200, 400, 12, rl.Color.gray);
|
rl.drawRectangleLines(200, 200, 400, 12, .gray);
|
||||||
|
|
||||||
rl.drawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.Color.light_gray);
|
rl.drawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, .light_gray);
|
||||||
rl.drawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.Color.light_gray);
|
rl.drawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, .light_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,12 +111,12 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText(rl.textFormat("sine frequency: %i", .{@as(i32, @intFromFloat(frequency))}),
|
rl.drawText(rl.textFormat("sine frequency: %i", .{@as(i32, @intFromFloat(frequency))}),
|
||||||
rl.getScreenWidth() - 220, 10, 20, rl.Color.red);
|
rl.getScreenWidth() - 220, 10, 20, .red);
|
||||||
rl.drawText("click mouse button to change frequency or pan",
|
rl.drawText("click mouse button to change frequency or pan",
|
||||||
10, 10, 20, rl.Color.dark_gray);
|
10, 10, 20, .dark_gray);
|
||||||
|
|
||||||
// Draw the current buffer state proportionate to the screen
|
// Draw the current buffer state proportionate to the screen
|
||||||
for (0..screenWidth) |i| {
|
for (0..screenWidth) |i| {
|
||||||
@ -124,7 +124,7 @@ pub fn main() anyerror!void {
|
|||||||
const y: f32 = @floatFromInt(data[@divFloor(i * MAX_SAMPLES, screenWidth)]);
|
const y: f32 = @floatFromInt(data[@divFloor(i * MAX_SAMPLES, screenWidth)]);
|
||||||
position.y = 250 + 50 * y / 32000;
|
position.y = 250 + 50 * y / 32000;
|
||||||
|
|
||||||
rl.drawPixelV(position, rl.Color.red);
|
rl.drawPixelV(position, .red);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ pub fn main() !void {
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.space)) rl.playSound(fxWav); // Play WAV sound
|
if (rl.isKeyPressed(.space)) rl.playSound(fxWav); // Play WAV sound
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.enter)) rl.playSound(fxOgg); // Play OGG sound
|
if (rl.isKeyPressed(.enter)) rl.playSound(fxOgg); // Play OGG sound
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@ -37,10 +37,10 @@ pub fn main() !void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.Color.light_gray);
|
rl.drawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, .light_gray);
|
||||||
rl.drawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.Color.light_gray);
|
rl.drawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, .light_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
spacing += @as(i32, @intFromFloat(buildings[i].width));
|
spacing += @as(i32, @intFromFloat(buildings[i].width));
|
||||||
|
|
||||||
buildColors[i] = rl.Color.init(
|
buildColors[i] = .init(
|
||||||
@as(u8, @intCast(rl.getRandomValue(200, 240))),
|
@as(u8, @intCast(rl.getRandomValue(200, 240))),
|
||||||
@as(u8, @intCast(rl.getRandomValue(200, 240))),
|
@as(u8, @intCast(rl.getRandomValue(200, 240))),
|
||||||
@as(u8, @intCast(rl.getRandomValue(200, 250))),
|
@as(u8, @intCast(rl.getRandomValue(200, 250))),
|
||||||
@ -36,8 +36,8 @@ pub fn main() anyerror!void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var camera = rl.Camera2D{
|
var camera = rl.Camera2D{
|
||||||
.target = rl.Vector2.init(player.x + 20, player.y + 20),
|
.target = .init(player.x + 20, player.y + 20),
|
||||||
.offset = rl.Vector2.init(screenWidth / 2, screenHeight / 2),
|
.offset = .init(screenWidth / 2, screenHeight / 2),
|
||||||
.rotation = 0,
|
.rotation = 0,
|
||||||
.zoom = 1,
|
.zoom = 1,
|
||||||
};
|
};
|
||||||
@ -58,7 +58,7 @@ pub fn main() anyerror!void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Camera target follows player
|
// Camera target follows player
|
||||||
camera.target = rl.Vector2.init(player.x + 20, player.y + 20);
|
camera.target = .init(player.x + 20, player.y + 20);
|
||||||
|
|
||||||
// Camera rotation controls
|
// Camera rotation controls
|
||||||
if (rl.isKeyDown(.a)) {
|
if (rl.isKeyDown(.a)) {
|
||||||
@ -87,51 +87,51 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
camera.begin();
|
camera.begin();
|
||||||
defer camera.end();
|
defer camera.end();
|
||||||
|
|
||||||
rl.drawRectangle(-6000, 320, 13000, 8000, rl.Color.dark_gray);
|
rl.drawRectangle(-6000, 320, 13000, 8000, .dark_gray);
|
||||||
|
|
||||||
for (buildings, 0..) |building, i| {
|
for (buildings, 0..) |building, i| {
|
||||||
rl.drawRectangleRec(building, buildColors[i]);
|
rl.drawRectangleRec(building, buildColors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawRectangleRec(player, rl.Color.red);
|
rl.drawRectangleRec(player, .red);
|
||||||
|
|
||||||
rl.drawLine(
|
rl.drawLine(
|
||||||
@as(i32, @intFromFloat(camera.target.x)),
|
@as(i32, @intFromFloat(camera.target.x)),
|
||||||
-screenHeight * 10,
|
-screenHeight * 10,
|
||||||
@as(i32, @intFromFloat(camera.target.x)),
|
@as(i32, @intFromFloat(camera.target.x)),
|
||||||
screenHeight * 10,
|
screenHeight * 10,
|
||||||
rl.Color.green,
|
.green,
|
||||||
);
|
);
|
||||||
rl.drawLine(
|
rl.drawLine(
|
||||||
-screenWidth * 10,
|
-screenWidth * 10,
|
||||||
@as(i32, @intFromFloat(camera.target.y)),
|
@as(i32, @intFromFloat(camera.target.y)),
|
||||||
screenWidth * 10,
|
screenWidth * 10,
|
||||||
@as(i32, @intFromFloat(camera.target.y)),
|
@as(i32, @intFromFloat(camera.target.y)),
|
||||||
rl.Color.green,
|
.green,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawText("SCREEN AREA", 640, 10, 20, rl.Color.red);
|
rl.drawText("SCREEN AREA", 640, 10, 20, .red);
|
||||||
|
|
||||||
rl.drawRectangle(0, 0, screenWidth, 5, rl.Color.red);
|
rl.drawRectangle(0, 0, screenWidth, 5, .red);
|
||||||
rl.drawRectangle(0, 5, 5, screenHeight - 10, rl.Color.red);
|
rl.drawRectangle(0, 5, 5, screenHeight - 10, .red);
|
||||||
rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, rl.Color.red);
|
rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, .red);
|
||||||
rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, rl.Color.red);
|
rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, .red);
|
||||||
|
|
||||||
rl.drawRectangle(10, 10, 250, 113, rl.Color.sky_blue.fade(0.5));
|
rl.drawRectangle(10, 10, 250, 113, .fade(.sky_blue, 0.5));
|
||||||
rl.drawRectangleLines(10, 10, 250, 113, rl.Color.blue);
|
rl.drawRectangleLines(10, 10, 250, 113, .blue);
|
||||||
|
|
||||||
rl.drawText("Free 2d camera controls:", 20, 20, 10, rl.Color.black);
|
rl.drawText("Free 2d camera controls:", 20, 20, 10, .black);
|
||||||
rl.drawText("- Right/Left to move Offset", 40, 40, 10, rl.Color.dark_gray);
|
rl.drawText("- Right/Left to move Offset", 40, 40, 10, .dark_gray);
|
||||||
rl.drawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, rl.Color.dark_gray);
|
rl.drawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, .dark_gray);
|
||||||
rl.drawText("- A / S to Rotate", 40, 80, 10, rl.Color.dark_gray);
|
rl.drawText("- A / S to Rotate", 40, 80, 10, .dark_gray);
|
||||||
rl.drawText("- R to reset Zoom and Rotation", 40, 100, 10, rl.Color.dark_gray);
|
rl.drawText("- R to reset Zoom and Rotation", 40, 100, 10, .dark_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
camera.begin();
|
camera.begin();
|
||||||
@ -103,14 +103,14 @@ pub fn main() anyerror!void {
|
|||||||
rl.drawGrid(100, 50);
|
rl.drawGrid(100, 50);
|
||||||
rl.gl.rlPopMatrix();
|
rl.gl.rlPopMatrix();
|
||||||
|
|
||||||
rl.drawCircle(screenWidth / 2, screenHeight / 2, 50, rl.Color.maroon);
|
rl.drawCircle(screenWidth / 2, screenHeight / 2, 50, .maroon);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, rl.Color.dark_gray);
|
rl.drawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, .dark_gray);
|
||||||
if (zoomMode == 0) {
|
if (zoomMode == 0) {
|
||||||
rl.drawText("Mouse right button drag to move, mouse wheel to zoom", 20, 50, 20, rl.Color.dark_gray);
|
rl.drawText("Mouse right button drag to move, mouse wheel to zoom", 20, 50, 20, .dark_gray);
|
||||||
} else {
|
} else {
|
||||||
rl.drawText("Mouse right button drag to move, mouse press and move to zoom", 20, 50, 20, rl.Color.dark_gray);
|
rl.drawText("Mouse right button drag to move, mouse press and move to zoom", 20, 50, 20, .dark_gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -14,9 +14,9 @@ pub fn main() anyerror!void {
|
|||||||
defer rl.closeWindow(); // Close window and OpenGL context
|
defer rl.closeWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
var camera = rl.Camera3D{
|
var camera = rl.Camera3D{
|
||||||
.position = rl.Vector3.init(4, 2, 4),
|
.position = .init(4, 2, 4),
|
||||||
.target = rl.Vector3.init(0, 1.8, 0),
|
.target = .init(0, 1.8, 0),
|
||||||
.up = rl.Vector3.init(0, 1, 0),
|
.up = .init(0, 1, 0),
|
||||||
.fovy = 60,
|
.fovy = 60,
|
||||||
.projection = .perspective,
|
.projection = .perspective,
|
||||||
};
|
};
|
||||||
@ -27,12 +27,12 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
for (0..heights.len) |i| {
|
for (0..heights.len) |i| {
|
||||||
heights[i] = @as(f32, @floatFromInt(rl.getRandomValue(1, 12)));
|
heights[i] = @as(f32, @floatFromInt(rl.getRandomValue(1, 12)));
|
||||||
positions[i] = rl.Vector3.init(
|
positions[i] = .init(
|
||||||
@as(f32, @floatFromInt(rl.getRandomValue(-15, 15))),
|
@as(f32, @floatFromInt(rl.getRandomValue(-15, 15))),
|
||||||
heights[i] / 2.0,
|
heights[i] / 2.0,
|
||||||
@as(f32, @floatFromInt(rl.getRandomValue(-15, 15))),
|
@as(f32, @floatFromInt(rl.getRandomValue(-15, 15))),
|
||||||
);
|
);
|
||||||
colors[i] = rl.Color.init(
|
colors[i] = .init(
|
||||||
@as(u8, @intCast(rl.getRandomValue(20, 255))),
|
@as(u8, @intCast(rl.getRandomValue(20, 255))),
|
||||||
@as(u8, @intCast(rl.getRandomValue(10, 55))),
|
@as(u8, @intCast(rl.getRandomValue(10, 55))),
|
||||||
30,
|
30,
|
||||||
@ -56,31 +56,31 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
camera.begin();
|
camera.begin();
|
||||||
defer camera.end();
|
defer camera.end();
|
||||||
|
|
||||||
// Draw ground
|
// Draw ground
|
||||||
rl.drawPlane(rl.Vector3.init(0, 0, 0), rl.Vector2.init(32, 32), rl.Color.light_gray);
|
rl.drawPlane(.init(0, 0, 0), .init(32, 32), .light_gray);
|
||||||
rl.drawCube(rl.Vector3.init(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Color.blue); // Draw a blue wall
|
rl.drawCube(.init(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, .blue); // Draw a blue wall
|
||||||
rl.drawCube(rl.Vector3.init(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Color.lime); // Draw a green wall
|
rl.drawCube(.init(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, .lime); // Draw a green wall
|
||||||
rl.drawCube(rl.Vector3.init(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, rl.Color.gold); // Draw a yellow wall
|
rl.drawCube(.init(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, .gold); // Draw a yellow wall
|
||||||
|
|
||||||
// Draw some cubes around
|
// Draw some cubes around
|
||||||
for (heights, 0..) |height, i| {
|
for (heights, 0..) |height, i| {
|
||||||
rl.drawCube(positions[i], 2.0, height, 2.0, colors[i]);
|
rl.drawCube(positions[i], 2.0, height, 2.0, colors[i]);
|
||||||
rl.drawCubeWires(positions[i], 2.0, height, 2.0, rl.Color.maroon);
|
rl.drawCubeWires(positions[i], 2.0, height, 2.0, .maroon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawRectangle(10, 10, 220, 70, rl.Color.sky_blue.fade(0.5));
|
rl.drawRectangle(10, 10, 220, 70, .fade(.sky_blue, 0.5));
|
||||||
rl.drawRectangleLines(10, 10, 220, 70, rl.Color.blue);
|
rl.drawRectangleLines(10, 10, 220, 70, .blue);
|
||||||
|
|
||||||
rl.drawText("First person camera default controls:", 20, 20, 10, rl.Color.black);
|
rl.drawText("First person camera default controls:", 20, 20, 10, .black);
|
||||||
rl.drawText("- Move with keys: W, A, S, D", 40, 40, 10, rl.Color.dark_gray);
|
rl.drawText("- Move with keys: W, A, S, D", 40, 40, 10, .dark_gray);
|
||||||
rl.drawText("- Mouse move to look around", 40, 60, 10, rl.Color.dark_gray);
|
rl.drawText("- Mouse move to look around", 40, 60, 10, .dark_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
var camera = rl.Camera{
|
var camera = rl.Camera{
|
||||||
.position = rl.Vector3.init(10, 10, 10),
|
.position = .init(10, 10, 10),
|
||||||
.target = rl.Vector3.init(0, 0, 0),
|
.target = .init(0, 0, 0),
|
||||||
.up = rl.Vector3.init(0, 1, 0),
|
.up = .init(0, 1, 0),
|
||||||
.fovy = 45,
|
.fovy = 45,
|
||||||
.projection = .perspective,
|
.projection = .perspective,
|
||||||
};
|
};
|
||||||
@ -36,7 +36,7 @@ pub fn main() anyerror!void {
|
|||||||
camera.update(.free);
|
camera.update(.free);
|
||||||
|
|
||||||
if (rl.isKeyPressed(.z)) {
|
if (rl.isKeyPressed(.z)) {
|
||||||
camera.target = rl.Vector3.init(0, 0, 0);
|
camera.target = .init(0, 0, 0);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -45,25 +45,25 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
camera.begin();
|
camera.begin();
|
||||||
defer camera.end();
|
defer camera.end();
|
||||||
|
|
||||||
rl.drawCube(cubePosition, 2, 2, 2, rl.Color.red);
|
rl.drawCube(cubePosition, 2, 2, 2, .red);
|
||||||
rl.drawCubeWires(cubePosition, 2, 2, 2, rl.Color.maroon);
|
rl.drawCubeWires(cubePosition, 2, 2, 2, .maroon);
|
||||||
|
|
||||||
rl.drawGrid(10, 1);
|
rl.drawGrid(10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawRectangle(10, 10, 320, 93, rl.Color.fade(rl.Color.sky_blue, 0.5));
|
rl.drawRectangle(10, 10, 320, 93, .fade(.sky_blue, 0.5));
|
||||||
rl.drawRectangleLines(10, 10, 320, 93, rl.Color.blue);
|
rl.drawRectangleLines(10, 10, 320, 93, .blue);
|
||||||
|
|
||||||
rl.drawText("Free camera default controls:", 20, 20, 10, rl.Color.black);
|
rl.drawText("Free camera default controls:", 20, 20, 10, .black);
|
||||||
rl.drawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, rl.Color.dark_gray);
|
rl.drawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, .dark_gray);
|
||||||
rl.drawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, rl.Color.dark_gray);
|
rl.drawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, .dark_gray);
|
||||||
rl.drawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, rl.Color.dark_gray);
|
rl.drawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, .dark_gray);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
var camera = rl.Camera{
|
var camera = rl.Camera{
|
||||||
.position = rl.Vector3.init(10, 10, 10),
|
.position = .init(10, 10, 10),
|
||||||
.target = rl.Vector3.init(0, 0, 0),
|
.target = .init(0, 0, 0),
|
||||||
.up = rl.Vector3.init(0, 1, 0),
|
.up = .init(0, 1, 0),
|
||||||
.fovy = 45,
|
.fovy = 45,
|
||||||
.projection = .perspective,
|
.projection = .perspective,
|
||||||
};
|
};
|
||||||
@ -44,8 +44,8 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
// Check collision between ray and box
|
// Check collision between ray and box
|
||||||
collision = rl.getRayCollisionBox(ray, rl.BoundingBox{
|
collision = rl.getRayCollisionBox(ray, rl.BoundingBox{
|
||||||
.max = rl.Vector3.init(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2),
|
.max = .init(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2),
|
||||||
.min = rl.Vector3.init(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2),
|
.min = .init(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2),
|
||||||
});
|
});
|
||||||
} else collision.hit = false;
|
} else collision.hit = false;
|
||||||
}
|
}
|
||||||
@ -56,33 +56,33 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
camera.begin();
|
camera.begin();
|
||||||
defer camera.end();
|
defer camera.end();
|
||||||
|
|
||||||
if (collision.hit) {
|
if (collision.hit) {
|
||||||
rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.red);
|
rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .red);
|
||||||
rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.maroon);
|
rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .maroon);
|
||||||
|
|
||||||
rl.drawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, rl.Color.green);
|
rl.drawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, .green);
|
||||||
} else {
|
} else {
|
||||||
rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.gray);
|
rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .gray);
|
||||||
rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.dark_gray);
|
rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .dark_gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawRay(ray, rl.Color.maroon);
|
rl.drawRay(ray, .maroon);
|
||||||
rl.drawGrid(10, 1);
|
rl.drawGrid(10, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawText("Try clicking on the box with your mouse!", 240, 10, 20, rl.Color.dark_gray);
|
rl.drawText("Try clicking on the box with your mouse!", 240, 10, 20, .dark_gray);
|
||||||
|
|
||||||
if (collision.hit) {
|
if (collision.hit) {
|
||||||
rl.drawText("BOX SELECTED", @divTrunc((screenWidth - rl.measureText("BOX SELECTED", 30)), 2), screenHeight * 0.1, 30, rl.Color.green);
|
rl.drawText("BOX SELECTED", @divTrunc((screenWidth - rl.measureText("BOX SELECTED", 30)), 2), screenHeight * 0.1, 30, .green);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawText("Right click mouse to toggle camera controls", 10, 430, 10, rl.Color.gray);
|
rl.drawText("Right click mouse to toggle camera controls", 10, 430, 10, .gray);
|
||||||
|
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
}
|
}
|
||||||
|
@ -85,18 +85,18 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
switch (current_screen) {
|
switch (current_screen) {
|
||||||
.logo => {
|
.logo => {
|
||||||
// TODO: Draw `logo` state here!
|
// TODO: Draw `logo` state here!
|
||||||
rl.drawText("LOGO SCREEN", 20, 20, 40, rl.Color.light_gray);
|
rl.drawText("LOGO SCREEN", 20, 20, 40, .light_gray);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"WAIT for 2 SECONDS...",
|
"WAIT for 2 SECONDS...",
|
||||||
290,
|
290,
|
||||||
220,
|
220,
|
||||||
20,
|
20,
|
||||||
rl.Color.gray,
|
.gray,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
.title => {
|
.title => {
|
||||||
@ -106,21 +106,21 @@ pub fn main() anyerror!void {
|
|||||||
0,
|
0,
|
||||||
screen_width,
|
screen_width,
|
||||||
screen_height,
|
screen_height,
|
||||||
rl.Color.green,
|
.green,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"TITLE SCREEN",
|
"TITLE SCREEN",
|
||||||
20,
|
20,
|
||||||
20,
|
20,
|
||||||
40,
|
40,
|
||||||
rl.Color.dark_green,
|
.dark_green,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN",
|
"PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN",
|
||||||
120,
|
120,
|
||||||
220,
|
220,
|
||||||
20,
|
20,
|
||||||
rl.Color.dark_green,
|
.dark_green,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
.gameplay => {
|
.gameplay => {
|
||||||
@ -130,15 +130,15 @@ pub fn main() anyerror!void {
|
|||||||
0,
|
0,
|
||||||
screen_width,
|
screen_width,
|
||||||
screen_height,
|
screen_height,
|
||||||
rl.Color.purple,
|
.purple,
|
||||||
);
|
);
|
||||||
rl.drawText("GAMEPLAY SCREEN", 20, 20, 40, rl.Color.maroon);
|
rl.drawText("GAMEPLAY SCREEN", 20, 20, 40, .maroon);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"PRESS ENTER or TAP to JUMP to ENDING SCREEN",
|
"PRESS ENTER or TAP to JUMP to ENDING SCREEN",
|
||||||
130,
|
130,
|
||||||
220,
|
220,
|
||||||
20,
|
20,
|
||||||
rl.Color.maroon,
|
.maroon,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
.ending => {
|
.ending => {
|
||||||
@ -148,21 +148,21 @@ pub fn main() anyerror!void {
|
|||||||
0,
|
0,
|
||||||
screen_width,
|
screen_width,
|
||||||
screen_height,
|
screen_height,
|
||||||
rl.Color.blue,
|
.blue,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"ENDING SCREEN",
|
"ENDING SCREEN",
|
||||||
20,
|
20,
|
||||||
20,
|
20,
|
||||||
40,
|
40,
|
||||||
rl.Color.dark_blue,
|
.dark_blue,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"PRESS ENTER or TAP to RETURN to TITLE SCREEN",
|
"PRESS ENTER or TAP to RETURN to TITLE SCREEN",
|
||||||
120,
|
120,
|
||||||
220,
|
220,
|
||||||
20,
|
20,
|
||||||
rl.Color.dark_blue,
|
.dark_blue,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray);
|
rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ fn updateDrawFrame() void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray);
|
rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText("move the ball with arrow keys", 10, 10, 20, rl.Color.dark_gray);
|
rl.drawText("move the ball with arrow keys", 10, 10, 20, .dark_gray);
|
||||||
|
|
||||||
rl.drawCircleV(ballPosition, 50, rl.Color.maroon);
|
rl.drawCircleV(ballPosition, 50, .maroon);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ pub fn main() anyerror!void {
|
|||||||
ballPosition.y = @as(f32, @floatFromInt(rl.getMouseY()));
|
ballPosition.y = @as(f32, @floatFromInt(rl.getMouseY()));
|
||||||
|
|
||||||
if (rl.isMouseButtonPressed(.left)) {
|
if (rl.isMouseButtonPressed(.left)) {
|
||||||
ballColor = rl.Color.maroon;
|
ballColor = .maroon;
|
||||||
} else if (rl.isMouseButtonPressed(.middle)) {
|
} else if (rl.isMouseButtonPressed(.middle)) {
|
||||||
ballColor = rl.Color.lime;
|
ballColor = .lime;
|
||||||
} else if (rl.isMouseButtonPressed(.right)) {
|
} else if (rl.isMouseButtonPressed(.right)) {
|
||||||
ballColor = rl.Color.dark_blue;
|
ballColor = .dark_blue;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawCircleV(ballPosition, 40, ballColor);
|
rl.drawCircleV(ballPosition, 40, ballColor);
|
||||||
|
|
||||||
rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.Color.dark_gray);
|
rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, .dark_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,18 +30,18 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawRectangle(screenWidth / 2 - 40, @as(i32, @intFromFloat(boxPositionY)), 80, 80, rl.Color.maroon);
|
rl.drawRectangle(screenWidth / 2 - 40, @as(i32, @intFromFloat(boxPositionY)), 80, 80, .maroon);
|
||||||
|
|
||||||
rl.drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, rl.Color.gray);
|
rl.drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, .gray);
|
||||||
|
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("Box position Y: %03i", .{@as(i32, @intFromFloat(boxPositionY))}),
|
rl.textFormat("Box position Y: %03i", .{@as(i32, @intFromFloat(boxPositionY))}),
|
||||||
10,
|
10,
|
||||||
40,
|
40,
|
||||||
20,
|
20,
|
||||||
rl.Color.light_gray,
|
.light_gray,
|
||||||
);
|
);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,16 @@ pub fn main() anyerror!void {
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
ballPosition = rl.getMousePosition();
|
ballPosition = rl.getMousePosition();
|
||||||
|
|
||||||
ballColor = rl.Color.beige;
|
ballColor = .beige;
|
||||||
|
|
||||||
if (rl.isMouseButtonDown(.left)) {
|
if (rl.isMouseButtonDown(.left)) {
|
||||||
ballColor = rl.Color.maroon;
|
ballColor = .maroon;
|
||||||
}
|
}
|
||||||
if (rl.isMouseButtonDown(.middle)) {
|
if (rl.isMouseButtonDown(.middle)) {
|
||||||
ballColor = rl.Color.lime;
|
ballColor = .lime;
|
||||||
}
|
}
|
||||||
if (rl.isMouseButtonDown(.right)) {
|
if (rl.isMouseButtonDown(.right)) {
|
||||||
ballColor = rl.Color.dark_blue;
|
ballColor = .dark_blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rl.isMouseButtonPressed(.left)) {
|
if (rl.isMouseButtonPressed(.left)) {
|
||||||
@ -58,7 +58,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
const nums = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
const nums = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
for (nums) |i| {
|
for (nums) |i| {
|
||||||
@ -68,13 +68,13 @@ pub fn main() anyerror!void {
|
|||||||
if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) {
|
if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) {
|
||||||
|
|
||||||
// Draw circle and touch index number
|
// Draw circle and touch index number
|
||||||
rl.drawCircleV(touchPosition, 34, rl.Color.orange);
|
rl.drawCircleV(touchPosition, 34, .orange);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("%d", .{i}),
|
rl.textFormat("%d", .{i}),
|
||||||
@as(i32, @intFromFloat(touchPosition.x)) - 10,
|
@as(i32, @intFromFloat(touchPosition.x)) - 10,
|
||||||
@as(i32, @intFromFloat(touchPosition.y)) - 70,
|
@as(i32, @intFromFloat(touchPosition.y)) - 70,
|
||||||
40,
|
40,
|
||||||
rl.Color.black,
|
.black,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,8 +82,8 @@ pub fn main() anyerror!void {
|
|||||||
// Draw the normal mouse location
|
// Draw the normal mouse location
|
||||||
rl.drawCircleV(ballPosition, 30 + (touchCounter * 3), ballColor);
|
rl.drawCircleV(ballPosition, 30 + (touchCounter * 3), ballColor);
|
||||||
|
|
||||||
rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.Color.dark_gray);
|
rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, .dark_gray);
|
||||||
rl.drawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, rl.Color.dark_gray);
|
rl.drawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, .dark_gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,17 +149,17 @@ pub fn main() anyerror!void {
|
|||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
if (rl.isWindowState(rl.ConfigFlags { .window_transparent = true })) {
|
if (rl.isWindowState(rl.ConfigFlags { .window_transparent = true })) {
|
||||||
rl.clearBackground(rl.Color.blank);
|
rl.clearBackground(.blank);
|
||||||
} else rl.clearBackground(rl.Color.ray_white);
|
} else rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawCircleV(ball_position, ball_radius, rl.Color.maroon);
|
rl.drawCircleV(ball_position, ball_radius, .maroon);
|
||||||
rl.drawRectangleLinesEx(
|
rl.drawRectangleLinesEx(
|
||||||
rl.Rectangle.init(0, 0, @floatFromInt(rl.getScreenWidth()), @floatFromInt(rl.getScreenHeight())),
|
.init(0, 0, @floatFromInt(rl.getScreenWidth()), @floatFromInt(rl.getScreenHeight())),
|
||||||
4,
|
4,
|
||||||
rl.Color.ray_white,
|
.ray_white,
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawCircleV(rl.getMousePosition(), 10, rl.Color.dark_blue);
|
rl.drawCircleV(rl.getMousePosition(), 10, .dark_blue);
|
||||||
|
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
40,
|
40,
|
||||||
10,
|
10,
|
||||||
rl.Color.green,
|
.green,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Draw window state info
|
// Draw window state info
|
||||||
@ -177,7 +177,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
60,
|
60,
|
||||||
10,
|
10,
|
||||||
rl.Color.gray,
|
.gray,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[F] flag_fullscreen_mode: %d", .{
|
rl.textFormat("[F] flag_fullscreen_mode: %d", .{
|
||||||
@ -186,7 +186,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
80,
|
80,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[R] flag_window_resizable: %d", .{
|
rl.textFormat("[R] flag_window_resizable: %d", .{
|
||||||
@ -195,7 +195,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
100,
|
100,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[D] flag_window_undecorated: %d", .{
|
rl.textFormat("[D] flag_window_undecorated: %d", .{
|
||||||
@ -204,7 +204,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
120,
|
120,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[H] flag_window_hidden: %d", .{
|
rl.textFormat("[H] flag_window_hidden: %d", .{
|
||||||
@ -213,7 +213,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
140,
|
140,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[N] flag_window_minimized: %d", .{
|
rl.textFormat("[N] flag_window_minimized: %d", .{
|
||||||
@ -222,7 +222,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
160,
|
160,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[M] flag_window_maximized: %d", .{
|
rl.textFormat("[M] flag_window_maximized: %d", .{
|
||||||
@ -231,7 +231,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
180,
|
180,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[U] flag_window_unfocused: %d", .{
|
rl.textFormat("[U] flag_window_unfocused: %d", .{
|
||||||
@ -240,7 +240,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
200,
|
200,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[T] flag_window_topmost: %d", .{
|
rl.textFormat("[T] flag_window_topmost: %d", .{
|
||||||
@ -249,7 +249,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
220,
|
220,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[A] flag_window_always_run: %d", .{
|
rl.textFormat("[A] flag_window_always_run: %d", .{
|
||||||
@ -258,7 +258,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
240,
|
240,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("[V] flag_vsync_hint: %d", .{
|
rl.textFormat("[V] flag_vsync_hint: %d", .{
|
||||||
@ -267,7 +267,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
260,
|
260,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
@ -275,7 +275,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
300,
|
300,
|
||||||
10,
|
10,
|
||||||
rl.Color.gray,
|
.gray,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("flag_window_highdpi: %d", .{
|
rl.textFormat("flag_window_highdpi: %d", .{
|
||||||
@ -284,7 +284,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
320,
|
320,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("flag_window_transparent: %d", .{
|
rl.textFormat("flag_window_transparent: %d", .{
|
||||||
@ -293,7 +293,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
340,
|
340,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("flag_msaa_4x_hint: %d", .{
|
rl.textFormat("flag_msaa_4x_hint: %d", .{
|
||||||
@ -302,7 +302,7 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
360,
|
360,
|
||||||
10,
|
10,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -28,16 +28,16 @@ pub fn main() anyerror!void {
|
|||||||
rl.setTargetFPS(60);
|
rl.setTargetFPS(60);
|
||||||
|
|
||||||
while (!rl.windowShouldClose()) {
|
while (!rl.windowShouldClose()) {
|
||||||
rl.updateCamera(&camera, rl.CameraMode.orbital);
|
rl.updateCamera(&camera, .orbital);
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
rl.beginMode3D(camera);
|
rl.beginMode3D(camera);
|
||||||
rl.drawModel(model, mapPosition, 1, rl.Color.red);
|
rl.drawModel(model, mapPosition, 1, .red);
|
||||||
rl.drawGrid(20, 1.0);
|
rl.drawGrid(20, 1.0);
|
||||||
rl.endMode3D();
|
rl.endMode3D();
|
||||||
rl.drawTexture(texture, screenWidth - texture.width - 20, 20, rl.Color.white);
|
rl.drawTexture(texture, screenWidth - texture.width - 20, 20, .white);
|
||||||
rl.drawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, rl.Color.green);
|
rl.drawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, .green);
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
|
|
||||||
rl.endDrawing();
|
rl.endDrawing();
|
||||||
|
@ -87,7 +87,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
// We only draw a white full-screen rectangle,
|
// We only draw a white full-screen rectangle,
|
||||||
// frame is generated in shader using raymarching
|
// frame is generated in shader using raymarching
|
||||||
@ -100,7 +100,7 @@ pub fn main() anyerror!void {
|
|||||||
0,
|
0,
|
||||||
rl.getScreenWidth(),
|
rl.getScreenWidth(),
|
||||||
rl.getScreenHeight(),
|
rl.getScreenHeight(),
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.getScreenWidth() - 280,
|
rl.getScreenWidth() - 280,
|
||||||
rl.getScreenHeight() - 20,
|
rl.getScreenHeight() - 20,
|
||||||
10,
|
10,
|
||||||
rl.Color.black,
|
.black,
|
||||||
);
|
);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.initWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture");
|
rl.initWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture");
|
||||||
defer rl.closeWindow(); // Close window and OpenGL context
|
defer rl.closeWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
const texture: rl.Texture = try rl.Texture.init("resources/textures/fudesumi.png");
|
const texture: rl.Texture = try .init("resources/textures/fudesumi.png");
|
||||||
defer rl.unloadTexture(texture);
|
defer rl.unloadTexture(texture);
|
||||||
|
|
||||||
const shdrOutline: rl.Shader = try rl.loadShader(null, "resources/shaders/glsl330/outline.fs");
|
const shdrOutline: rl.Shader = try rl.loadShader(null, "resources/shaders/glsl330/outline.fs");
|
||||||
@ -76,7 +76,7 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
{
|
{
|
||||||
rl.beginShaderMode(shdrOutline);
|
rl.beginShaderMode(shdrOutline);
|
||||||
@ -85,18 +85,18 @@ pub fn main() anyerror!void {
|
|||||||
texture.draw(
|
texture.draw(
|
||||||
@divFloor(rl.getScreenWidth(), 2) - @divFloor(texture.width, 2),
|
@divFloor(rl.getScreenWidth(), 2) - @divFloor(texture.width, 2),
|
||||||
-30,
|
-30,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawText("Shader-based\ntexture\noutline", 10, 10, 20, rl.Color.gray);
|
rl.drawText("Shader-based\ntexture\noutline", 10, 10, 20, .gray);
|
||||||
|
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
rl.textFormat("Outline size: %i px", .{@as(i32, @intFromFloat(outlineSize))}),
|
rl.textFormat("Outline size: %i px", .{@as(i32, @intFromFloat(outlineSize))}),
|
||||||
10,
|
10,
|
||||||
120,
|
120,
|
||||||
20,
|
20,
|
||||||
rl.Color.maroon,
|
.maroon,
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawFPS(710, 10);
|
rl.drawFPS(710, 10);
|
||||||
|
@ -26,33 +26,33 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText("some basic shapes available on raylib", 20, 20, 20, rl.Color.dark_gray);
|
rl.drawText("some basic shapes available on raylib", 20, 20, 20, .dark_gray);
|
||||||
|
|
||||||
// Circle shapes and lines
|
// Circle shapes and lines
|
||||||
rl.drawCircle(screenWidth / 5, 120, 35, rl.Color.dark_blue);
|
rl.drawCircle(screenWidth / 5, 120, 35, .dark_blue);
|
||||||
rl.drawCircleGradient(screenWidth / 5, 220, 60, rl.Color.green, rl.Color.sky_blue);
|
rl.drawCircleGradient(screenWidth / 5, 220, 60, .green, .sky_blue);
|
||||||
rl.drawCircleLines(screenWidth / 5, 340, 80, rl.Color.dark_blue);
|
rl.drawCircleLines(screenWidth / 5, 340, 80, .dark_blue);
|
||||||
|
|
||||||
// Rectangle shapes and lines
|
// Rectangle shapes and lines
|
||||||
rl.drawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, rl.Color.red);
|
rl.drawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, .red);
|
||||||
rl.drawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, rl.Color.maroon, rl.Color.gold);
|
rl.drawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, .maroon, .gold);
|
||||||
rl.drawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, rl.Color.orange); // NOTE: Uses QUADS internally, not lines
|
rl.drawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, .orange); // NOTE: Uses QUADS internally, not lines
|
||||||
|
|
||||||
// Triangle shapes and lines
|
// Triangle shapes and lines
|
||||||
rl.drawTriangle((rl.Vector2){ .x = (screenWidth / 4.0 * 3.0), .y = 80.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 - 60.0), .y = 150.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 + 60.0), .y = 150.0 }, rl.Color.violet);
|
rl.drawTriangle(.{ .x = (screenWidth / 4.0 * 3.0), .y = 80.0 }, .{ .x = (screenWidth / 4.0 * 3.0 - 60.0), .y = 150.0 }, .{ .x = (screenWidth / 4.0 * 3.0 + 60.0), .y = 150.0 }, .violet);
|
||||||
|
|
||||||
rl.drawTriangleLines((rl.Vector2){ .x = (screenWidth / 4.0 * 3.0), .y = 160.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 - 20.0), .y = 230.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 + 20.0), .y = 230.0 }, rl.Color.dark_blue);
|
rl.drawTriangleLines(.{ .x = (screenWidth / 4.0 * 3.0), .y = 160.0 }, .{ .x = (screenWidth / 4.0 * 3.0 - 20.0), .y = 230.0 }, .{ .x = (screenWidth / 4.0 * 3.0 + 20.0), .y = 230.0 }, .dark_blue);
|
||||||
|
|
||||||
// Polygon shapes and lines
|
// Polygon shapes and lines
|
||||||
rl.drawPoly((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 80, rotation, rl.Color.brown);
|
rl.drawPoly(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 80, rotation, .brown);
|
||||||
rl.drawPolyLines((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 90, rotation, rl.Color.brown);
|
rl.drawPolyLines(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 90, rotation, .brown);
|
||||||
rl.drawPolyLinesEx((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 85, rotation, 6, rl.Color.beige);
|
rl.drawPolyLinesEx(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 85, rotation, 6, .beige);
|
||||||
|
|
||||||
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
|
||||||
// this way, all LINES are rendered in a single draw pass
|
// this way, all LINES are rendered in a single draw pass
|
||||||
rl.drawLine(18, 42, screenWidth - 18, 42, rl.Color.black);
|
rl.drawLine(18, 42, screenWidth - 18, 42, .black);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawCircleV(ballPosition, ballRadius, rl.Color.maroon);
|
rl.drawCircleV(ballPosition, ballRadius, .maroon);
|
||||||
rl.drawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, rl.getScreenHeight() - 25, 20, rl.Color.light_gray);
|
rl.drawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, rl.getScreenHeight() - 25, 20, .light_gray);
|
||||||
|
|
||||||
// On pause, we draw a blinking message
|
// On pause, we draw a blinking message
|
||||||
if (pause and @mod(@divFloor(framesCounter, 30), 2) == 0) {
|
if (pause and @mod(@divFloor(framesCounter, 30), 2) == 0) {
|
||||||
rl.drawText("PAUSED", 350, 200, 30, rl.Color.gray);
|
rl.drawText("PAUSED", 350, 200, 30, .gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const rl = @import("raylib");
|
const rl = @import("raylib");
|
||||||
|
|
||||||
fn boxFmt(colliding: bool) rl.Color {
|
fn boxFmt(colliding: bool) rl.Color {
|
||||||
if (colliding) return rl.Color.red;
|
if (colliding) return .red;
|
||||||
return rl.Color.black;
|
return .black;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
@ -83,12 +83,12 @@ pub fn main() anyerror!void {
|
|||||||
|
|
||||||
rl.drawRectangle(0, 0, screenWidth, screenUpperLimit, boxFmt(collision));
|
rl.drawRectangle(0, 0, screenWidth, screenUpperLimit, boxFmt(collision));
|
||||||
|
|
||||||
rl.drawRectangleRec(boxA, rl.Color.gold);
|
rl.drawRectangleRec(boxA, .gold);
|
||||||
rl.drawRectangleRec(boxB, rl.Color.blue);
|
rl.drawRectangleRec(boxB, .blue);
|
||||||
|
|
||||||
if (collision) {
|
if (collision) {
|
||||||
// Draw collision area
|
// Draw collision area
|
||||||
rl.drawRectangleRec(boxCollision, rl.Color.lime);
|
rl.drawRectangleRec(boxCollision, .lime);
|
||||||
|
|
||||||
// Draw collision message
|
// Draw collision message
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
@ -96,19 +96,19 @@ pub fn main() anyerror!void {
|
|||||||
@divFloor(rl.getScreenWidth(), @as(i32, 2)) - @divFloor(rl.measureText("COLLISION!", 20), @as(i32, 2)),
|
@divFloor(rl.getScreenWidth(), @as(i32, 2)) - @divFloor(rl.measureText("COLLISION!", 20), @as(i32, 2)),
|
||||||
screenUpperLimit / 2 - 10,
|
screenUpperLimit / 2 - 10,
|
||||||
20,
|
20,
|
||||||
rl.Color.black,
|
.black,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Draw collision area
|
// Draw collision area
|
||||||
rl.drawText(rl.textFormat("Collision Area: %i", .{@as(i32, @intFromFloat(boxCollision.width * boxCollision.height))}), @divFloor(rl.getScreenWidth(), 2) - 100, screenUpperLimit + 10, 20, rl.Color.black);
|
rl.drawText(rl.textFormat("Collision Area: %i", .{@as(i32, @intFromFloat(boxCollision.width * boxCollision.height))}), @divFloor(rl.getScreenWidth(), 2) - 100, screenUpperLimit + 10, 20, .black);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw help instructions
|
// Draw help instructions
|
||||||
rl.drawText("Press SPACE to PAUSE/RESUME", 20, screenHeight - 35, 20, rl.Color.light_gray);
|
rl.drawText("Press SPACE to PAUSE/RESUME", 20, screenHeight - 35, 20, .light_gray);
|
||||||
|
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,27 +20,27 @@ pub fn main() anyerror!void {
|
|||||||
defer rl.closeWindow(); // Close window and OpenGL context
|
defer rl.closeWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
const colors = [maxColorCount]rl.Color{
|
const colors = [maxColorCount]rl.Color{
|
||||||
rl.Color.dark_gray,
|
.dark_gray,
|
||||||
rl.Color.maroon,
|
.maroon,
|
||||||
rl.Color.orange,
|
.orange,
|
||||||
rl.Color.dark_green,
|
.dark_green,
|
||||||
rl.Color.dark_blue,
|
.dark_blue,
|
||||||
rl.Color.dark_purple,
|
.dark_purple,
|
||||||
rl.Color.dark_brown,
|
.dark_brown,
|
||||||
rl.Color.gray,
|
.gray,
|
||||||
rl.Color.red,
|
.red,
|
||||||
rl.Color.gold,
|
.gold,
|
||||||
rl.Color.lime,
|
.lime,
|
||||||
rl.Color.blue,
|
.blue,
|
||||||
rl.Color.violet,
|
.violet,
|
||||||
rl.Color.brown,
|
.brown,
|
||||||
rl.Color.light_gray,
|
.light_gray,
|
||||||
rl.Color.pink,
|
.pink,
|
||||||
rl.Color.yellow,
|
.yellow,
|
||||||
rl.Color.green,
|
.green,
|
||||||
rl.Color.sky_blue,
|
.sky_blue,
|
||||||
rl.Color.purple,
|
.purple,
|
||||||
rl.Color.beige,
|
.beige,
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorNames = [maxColorCount][:0]const u8{
|
const colorNames = [maxColorCount][:0]const u8{
|
||||||
@ -105,18 +105,18 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText("raylib colors palette", 28, 42, 20, rl.Color.black);
|
rl.drawText("raylib colors palette", 28, 42, 20, .black);
|
||||||
rl.drawText("press SPACE to see all colors", rl.getScreenWidth() - 180, rl.getScreenHeight() - 40, 10, rl.Color.gray);
|
rl.drawText("press SPACE to see all colors", rl.getScreenWidth() - 180, rl.getScreenHeight() - 40, 10, .gray);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < maxColorCount) : (i += 1) {
|
while (i < maxColorCount) : (i += 1) {
|
||||||
rl.drawRectangleRec(colorsRecs[i], rl.fade(colors[i], getAlpha(colorState[i])));
|
rl.drawRectangleRec(colorsRecs[i], .fade(colors[i], getAlpha(colorState[i])));
|
||||||
|
|
||||||
if (rl.isKeyDown(.space) or colorState[i]) {
|
if (rl.isKeyDown(.space) or colorState[i]) {
|
||||||
rl.drawRectangle(@intFromFloat(colorsRecs[i].x), @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 26, @as(i32, @intFromFloat(colorsRecs[i].width)), 20, rl.Color.black);
|
rl.drawRectangle(@intFromFloat(colorsRecs[i].x), @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 26, @as(i32, @intFromFloat(colorsRecs[i].width)), 20, .black);
|
||||||
rl.drawRectangleLinesEx(colorsRecs[i], 6, rl.fade(rl.Color.black, 0.3));
|
rl.drawRectangleLinesEx(colorsRecs[i], 6, .fade(.black, 0.3));
|
||||||
|
|
||||||
rl.drawText(colorNames[i], @as(i32, @intFromFloat(colorsRecs[i].x)) + @as(i32, @intFromFloat(colorsRecs[i].width)) - rl.measureText(colorNames[i], 10) - 12, @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 20, 10, colors[i]);
|
rl.drawText(colorNames[i], @as(i32, @intFromFloat(colorsRecs[i].x)) + @as(i32, @intFromFloat(colorsRecs[i].width)) - rl.measureText(colorNames[i], 10) - 12, @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 20, 10, colors[i]);
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ fn labelFmt(segments: f32, minSegments: f32) [*c]const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn colorFmt(segments: f32, minSegments: f32) rl.Color {
|
fn colorFmt(segments: f32, minSegments: f32) rl.Color {
|
||||||
if (segments >= minSegments) return rl.Color.maroon;
|
if (segments >= minSegments) return .maroon;
|
||||||
return rl.Color.dark_gray;
|
return .dark_gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
@ -45,13 +45,13 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawLine(500, 0, 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6));
|
rl.drawLine(500, 0, 500, rl.getScreenHeight(), .fade(.light_gray, 0.6));
|
||||||
rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3));
|
rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3));
|
||||||
|
|
||||||
rl.drawCircleSector(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.3));
|
rl.drawCircleSector(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.3));
|
||||||
rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.6));
|
rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.6));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
_ = rgui.guiSliderBar(rl.Rectangle{ .x = 600, .y = 40, .width = 120, .height = 20 }, "StartAngle", rl.textFormat("%.2", .{startAngle}), &startAngle, 0, 720);
|
_ = rgui.guiSliderBar(rl.Rectangle{ .x = 600, .y = 40, .width = 120, .height = 20 }, "StartAngle", rl.textFormat("%.2", .{startAngle}), &startAngle, 0, 720);
|
||||||
|
@ -7,8 +7,8 @@ fn labelFmt(segments: f32) [*c]const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn colorFmt(segments: f32) rl.Color {
|
fn colorFmt(segments: f32) rl.Color {
|
||||||
if (segments >= 4) return rl.Color.maroon;
|
if (segments >= 4) return .maroon;
|
||||||
return rl.Color.dark_gray;
|
return .dark_gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
@ -45,14 +45,14 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawLine(560, 0, 560, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6));
|
rl.drawLine(560, 0, 560, rl.getScreenHeight(), .fade(.light_gray, 0.6));
|
||||||
rl.drawRectangle(560, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3));
|
rl.drawRectangle(560, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3));
|
||||||
|
|
||||||
if (drawRect) rl.drawRectangleRec(rec, rl.fade(rl.Color.gold, 0.6));
|
if (drawRect) rl.drawRectangleRec(rec, .fade(.gold, 0.6));
|
||||||
if (drawRoundedRect) rl.drawRectangleRounded(rec, roundness, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.2));
|
if (drawRoundedRect) rl.drawRectangleRounded(rec, roundness, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.2));
|
||||||
if (drawRoundedLines) rl.drawRectangleRoundedLinesEx(rec, roundness, @as(i32, @intFromFloat(segments)), lineThick, rl.fade(rl.Color.maroon, 0.4));
|
if (drawRoundedLines) rl.drawRectangleRoundedLinesEx(rec, roundness, @as(i32, @intFromFloat(segments)), lineThick, .fade(.maroon, 0.4));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
_ = rgui.guiSliderBar(rl.Rectangle{ .x = 640, .y = 40, .width = 105, .height = 20 }, "Width", rl.textFormat("%.2", .{width}), &width, 0, @as(f32, @floatFromInt(rl.getScreenWidth() - 300)));
|
_ = rgui.guiSliderBar(rl.Rectangle{ .x = 640, .y = 40, .width = 105, .height = 20 }, "Width", rl.textFormat("%.2", .{width}), &width, 0, @as(f32, @floatFromInt(rl.getScreenWidth() - 300)));
|
||||||
|
@ -9,8 +9,8 @@ fn labelFmt(segments: f32, minSegments: f32) [*c]const u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn colorFmt(segments: f32, minSegments: f32) rl.Color {
|
fn colorFmt(segments: f32, minSegments: f32) rl.Color {
|
||||||
if (segments >= minSegments) return rl.Color.maroon;
|
if (segments >= minSegments) return .maroon;
|
||||||
return rl.Color.dark_gray;
|
return .dark_gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
@ -50,14 +50,14 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawLine(500, 0, 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6));
|
rl.drawLine(500, 0, 500, rl.getScreenHeight(), .fade(.light_gray, 0.6));
|
||||||
rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3));
|
rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3));
|
||||||
|
|
||||||
if (drawRing) rl.drawRing(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.maroon, 0.3));
|
if (drawRing) rl.drawRing(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.maroon, 0.3));
|
||||||
if (drawRingLines) rl.drawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.black, 0.4));
|
if (drawRingLines) rl.drawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.black, 0.4));
|
||||||
if (drawCircleLines) rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.black, 0.4));
|
if (drawCircleLines) rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.black, 0.4));
|
||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -69,17 +69,17 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.drawCircleV(scleraLeftPosition, scleraRadius, rl.Color.light_gray);
|
rl.drawCircleV(scleraLeftPosition, scleraRadius, .light_gray);
|
||||||
rl.drawCircleV(irisLeftPosition, irisRadius, rl.Color.brown);
|
rl.drawCircleV(irisLeftPosition, irisRadius, .brown);
|
||||||
rl.drawCircleV(irisLeftPosition, 10, rl.Color.black);
|
rl.drawCircleV(irisLeftPosition, 10, .black);
|
||||||
|
|
||||||
rl.drawCircleV(scleraRightPosition, scleraRadius, rl.Color.light_gray);
|
rl.drawCircleV(scleraRightPosition, scleraRadius, .light_gray);
|
||||||
rl.drawCircleV(irisRightPosition, irisRadius, rl.Color.dark_green);
|
rl.drawCircleV(irisRightPosition, irisRadius, .dark_green);
|
||||||
rl.drawCircleV(irisRightPosition, 10, rl.Color.black);
|
rl.drawCircleV(irisRightPosition, 10, .black);
|
||||||
|
|
||||||
rl.drawFPS(10, 10);
|
rl.drawFPS(10, 10);
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ fn collisionFmt(isColliding: bool) f32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn movingFmt(isMoving: bool) rl.Color {
|
fn movingFmt(isMoving: bool) rl.Color {
|
||||||
if (isMoving) return rl.Color.red;
|
if (isMoving) return .red;
|
||||||
return rl.Color.blue;
|
return .blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
@ -60,12 +60,12 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText("MOVE START-END POINTS WITH MOUSE", 15, 20, 20, rl.Color.gray);
|
rl.drawText("MOVE START-END POINTS WITH MOUSE", 15, 20, 20, .gray);
|
||||||
|
|
||||||
// Draw line Cubic Bezier, in-out interpolation (easing), no control points
|
// Draw line Cubic Bezier, in-out interpolation (easing), no control points
|
||||||
rl.drawLineBezier(startPoint, endPoint, 4.0, rl.Color.blue);
|
rl.drawLineBezier(startPoint, endPoint, 4.0, .blue);
|
||||||
|
|
||||||
// Draw start-end spline circles with some details
|
// Draw start-end spline circles with some details
|
||||||
rl.drawCircleV(startPoint, collisionFmt(rl.checkCollisionPointCircle(mouse, startPoint, 10.0)), movingFmt(moveStartPoint));
|
rl.drawCircleV(startPoint, collisionFmt(rl.checkCollisionPointCircle(mouse, startPoint, 10.0)), movingFmt(moveStartPoint));
|
||||||
|
@ -28,13 +28,13 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawRectangle(screenWidth / 2 - 128, screenHeight / 2 - 128, 256, 256, raylib_zig);
|
rl.drawRectangle(screenWidth / 2 - 128, screenHeight / 2 - 128, 256, 256, raylib_zig);
|
||||||
rl.drawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, rl.Color.ray_white);
|
rl.drawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, .ray_white);
|
||||||
rl.drawText("raylib-zig", screenWidth / 2 - 96, screenHeight / 2 + 57, 41, raylib_zig);
|
rl.drawText("raylib-zig", screenWidth / 2 - 96, screenHeight / 2 + 57, 41, raylib_zig);
|
||||||
|
|
||||||
rl.drawText("this is NOT a texture!", 350, 370, 10, rl.Color.gray);
|
rl.drawText("this is NOT a texture!", 350, 370, 10, .gray);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,37 +90,37 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
if (@mod(framesCounter, @as(u8, 15)) == 0) rl.drawRectangle(logoPositionX, logoPositionY, 16, 16, rl.Color.black);
|
if (@mod(framesCounter, @as(u8, 15)) == 0) rl.drawRectangle(logoPositionX, logoPositionY, 16, 16, .black);
|
||||||
} else if (state == 1) {
|
} else if (state == 1) {
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.Color.black);
|
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .black);
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, rl.Color.black);
|
rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, .black);
|
||||||
} else if (state == 2) {
|
} else if (state == 2) {
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.Color.black);
|
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .black);
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, rl.Color.black);
|
rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, .black);
|
||||||
|
|
||||||
rl.drawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, rl.Color.black);
|
rl.drawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, .black);
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, rl.Color.black);
|
rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, .black);
|
||||||
} else if (state == 3) {
|
} else if (state == 3) {
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.fade(rl.Color.black, alpha));
|
rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .fade(.black, alpha));
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, rl.fade(rl.Color.black, alpha));
|
rl.drawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, .fade(.black, alpha));
|
||||||
|
|
||||||
rl.drawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, rl.fade(rl.Color.black, alpha));
|
rl.drawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, .fade(.black, alpha));
|
||||||
rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, rl.fade(rl.Color.black, alpha));
|
rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, .fade(.black, alpha));
|
||||||
|
|
||||||
rl.drawRectangle(
|
rl.drawRectangle(
|
||||||
(@divFloor(rl.getScreenWidth(), @as(i32, 2))) - 112,
|
(@divFloor(rl.getScreenWidth(), @as(i32, 2))) - 112,
|
||||||
(@divFloor(rl.getScreenHeight(), @as(i32, 2))) - 112,
|
(@divFloor(rl.getScreenHeight(), @as(i32, 2))) - 112,
|
||||||
224,
|
224,
|
||||||
224,
|
224,
|
||||||
rl.fade(rl.Color.ray_white, alpha),
|
.fade(.ray_white, alpha),
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawText(rl.textSubtext("raylib", 0, lettersCount), @divFloor(rl.getScreenWidth(), @as(i32, 2)) - 44, @divFloor(rl.getScreenHeight(), @as(i32, 2)) + 48, 50, rl.fade(rl.Color.black, alpha));
|
rl.drawText(rl.textSubtext("raylib", 0, lettersCount), @divFloor(rl.getScreenWidth(), @as(i32, 2)) - 44, @divFloor(rl.getScreenHeight(), @as(i32, 2)) + 48, 50, .fade(.black, alpha));
|
||||||
} else if (state == 4) {
|
} else if (state == 4) {
|
||||||
rl.drawText("[R] REPLAY", 340, 200, 20, rl.Color.gray);
|
rl.drawText("[R] REPLAY", 340, 200, 20, .gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -68,15 +68,15 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, rl.Color.gray);
|
rl.drawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, .gray);
|
||||||
|
|
||||||
rl.drawRectangleRec(rec, rl.fade(rl.Color.green, 0.5));
|
rl.drawRectangleRec(rec, .fade(.green, 0.5));
|
||||||
|
|
||||||
if (mouseScaleReady) {
|
if (mouseScaleReady) {
|
||||||
rl.drawRectangleLinesEx(rec, 1, rl.Color.red);
|
rl.drawRectangleLinesEx(rec, 1, .red);
|
||||||
rl.drawTriangle(rl.Vector2{ .x = rec.x + rec.width - mouseScaleMarkSize, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height - mouseScaleMarkSize }, rl.Color.red);
|
rl.drawTriangle(rl.Vector2{ .x = rec.x + rec.width - mouseScaleMarkSize, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height - mouseScaleMarkSize }, .red);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -35,15 +35,15 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.white);
|
rl.clearBackground(.white);
|
||||||
|
|
||||||
rl.drawText(rl.textFormat("Score: %08i", .{score}), 200, 80, 20, rl.Color.red);
|
rl.drawText(rl.textFormat("Score: %08i", .{score}), 200, 80, 20, .red);
|
||||||
|
|
||||||
rl.drawText(rl.textFormat("HiScore: %08i", .{hiscore}), 200, 120, 20, rl.Color.green);
|
rl.drawText(rl.textFormat("HiScore: %08i", .{hiscore}), 200, 120, 20, .green);
|
||||||
|
|
||||||
rl.drawText(rl.textFormat("Lives: %02i", .{lives}), 200, 160, 40, rl.Color.blue);
|
rl.drawText(rl.textFormat("Lives: %02i", .{lives}), 200, 160, 40, .blue);
|
||||||
|
|
||||||
rl.drawText(rl.textFormat("Elapsed Time: %02.02f ms", .{rl.getFrameTime() * 1000}), 200, 220, 20, rl.Color.black);
|
rl.drawText(rl.textFormat("Elapsed Time: %02.02f ms", .{rl.getFrameTime() * 1000}), 200, 220, 20, .black);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ pub fn main() void {
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
framesCounter += if (rl.isKeyDown(rl.KeyboardKey.space)) 8 else 1;
|
framesCounter += if (rl.isKeyDown(.space)) 8 else 1;
|
||||||
|
|
||||||
if (rl.isKeyPressed(rl.KeyboardKey.enter)) framesCounter = 0;
|
if (rl.isKeyPressed(.enter)) framesCounter = 0;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -17,7 +17,7 @@ pub fn main() anyerror!void {
|
|||||||
defer rl.closeWindow(); // Close window and OpenGL context
|
defer rl.closeWindow(); // Close window and OpenGL context
|
||||||
|
|
||||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||||
const scarfy: rl.Texture = try rl.Texture.init("resources/textures/scarfy.png"); // Texture loading
|
const scarfy = try rl.Texture.init("resources/textures/scarfy.png"); // Texture loading
|
||||||
defer rl.unloadTexture(scarfy); // Texture unloading
|
defer rl.unloadTexture(scarfy); // Texture unloading
|
||||||
|
|
||||||
const position = rl.Vector2.init(350.0, 280.0);
|
const position = rl.Vector2.init(350.0, 280.0);
|
||||||
@ -70,37 +70,37 @@ pub fn main() anyerror!void {
|
|||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(rl.Color.ray_white);
|
rl.clearBackground(.ray_white);
|
||||||
|
|
||||||
rl.drawTexture(scarfy, 15, 40, rl.Color.white);
|
rl.drawTexture(scarfy, 15, 40, .white);
|
||||||
rl.drawRectangleLines(15, 40, scarfy.width, scarfy.height, rl.Color.lime);
|
rl.drawRectangleLines(15, 40, scarfy.width, scarfy.height, .lime);
|
||||||
rl.drawRectangleLines(
|
rl.drawRectangleLines(
|
||||||
15 + @as(i32, @intFromFloat(frameRec.x)),
|
15 + @as(i32, @intFromFloat(frameRec.x)),
|
||||||
40 + @as(i32, @intFromFloat(frameRec.y)),
|
40 + @as(i32, @intFromFloat(frameRec.y)),
|
||||||
@as(i32, @intFromFloat(frameRec.width)),
|
@as(i32, @intFromFloat(frameRec.width)),
|
||||||
@as(i32, @intFromFloat(frameRec.height)),
|
@as(i32, @intFromFloat(frameRec.height)),
|
||||||
rl.Color.red,
|
.red,
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawText("FRAME SPEED: ", 165, 210, 10, rl.Color.dark_gray);
|
rl.drawText("FRAME SPEED: ", 165, 210, 10, .dark_gray);
|
||||||
rl.drawText(rl.textFormat("%02i FPS", .{framesSpeed}), 575, 210, 10, rl.Color.dark_gray);
|
rl.drawText(rl.textFormat("%02i FPS", .{framesSpeed}), 575, 210, 10, .dark_gray);
|
||||||
rl.drawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, rl.Color.dark_gray);
|
rl.drawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, .dark_gray);
|
||||||
|
|
||||||
for ([_]u32{0} ** MAX_FRAME_SPEED, 0..) |_, i| {
|
for ([_]u32{0} ** MAX_FRAME_SPEED, 0..) |_, i| {
|
||||||
if (i < framesSpeed) {
|
if (i < framesSpeed) {
|
||||||
rl.drawRectangle(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, rl.Color.red);
|
rl.drawRectangle(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, .red);
|
||||||
}
|
}
|
||||||
rl.drawRectangleLines(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, rl.Color.maroon);
|
rl.drawRectangleLines(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, .maroon);
|
||||||
}
|
}
|
||||||
|
|
||||||
scarfy.drawRec(frameRec, position, rl.Color.white); // Draw part of the texture
|
scarfy.drawRec(frameRec, position, .white); // Draw part of the texture
|
||||||
|
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"(c) Scarfy sprite by Eiden Marsal",
|
"(c) Scarfy sprite by Eiden Marsal",
|
||||||
screenWidth - 200,
|
screenWidth - 200,
|
||||||
screenHeight - 20,
|
screenHeight - 20,
|
||||||
10,
|
10,
|
||||||
rl.Color.gray,
|
.gray,
|
||||||
);
|
);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
@ -59,49 +59,49 @@ pub fn main() anyerror!void {
|
|||||||
// NOTE: Texture is scaled twice its size
|
// NOTE: Texture is scaled twice its size
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
background,
|
background,
|
||||||
rl.Vector2.init(scrolling_back, 20.0),
|
.init(scrolling_back, 20.0),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
background,
|
background,
|
||||||
rl.Vector2.init(@as(f32, @floatFromInt(background.width * 2)) + scrolling_back, 20),
|
.init(@as(f32, @floatFromInt(background.width * 2)) + scrolling_back, 20),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Draw midground image twice
|
// Draw midground image twice
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
midground,
|
midground,
|
||||||
rl.Vector2.init(scrolling_mid, 20.0),
|
.init(scrolling_mid, 20.0),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
midground,
|
midground,
|
||||||
rl.Vector2.init(@as(f32, @floatFromInt(midground.width * 2)) + scrolling_mid, 20),
|
.init(@as(f32, @floatFromInt(midground.width * 2)) + scrolling_mid, 20),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Draw foreground image twice
|
// Draw foreground image twice
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
foreground,
|
foreground,
|
||||||
rl.Vector2.init(scrolling_fore, 70.0),
|
.init(scrolling_fore, 70.0),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
rl.drawTextureEx(
|
rl.drawTextureEx(
|
||||||
foreground,
|
foreground,
|
||||||
rl.Vector2.init(@as(f32, @floatFromInt(foreground.width * 2)) + scrolling_fore, 70),
|
.init(@as(f32, @floatFromInt(foreground.width * 2)) + scrolling_fore, 70),
|
||||||
0.0,
|
0.0,
|
||||||
2.0,
|
2.0,
|
||||||
rl.Color.white,
|
.white,
|
||||||
);
|
);
|
||||||
|
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
@ -109,14 +109,14 @@ pub fn main() anyerror!void {
|
|||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
20,
|
20,
|
||||||
rl.Color.red,
|
.red,
|
||||||
);
|
);
|
||||||
rl.drawText(
|
rl.drawText(
|
||||||
"(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)",
|
"(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)",
|
||||||
screen_width - 330,
|
screen_width - 330,
|
||||||
screen_height - 20,
|
screen_height - 20,
|
||||||
10,
|
10,
|
||||||
rl.Color.ray_white,
|
.ray_white,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user