make frugburp LOL
This commit is contained in:
BIN
resources/burp.mp3
Normal file
BIN
resources/burp.mp3
Normal file
Binary file not shown.
23
src/main.zig
23
src/main.zig
@ -2,27 +2,26 @@ const std = @import("std");
|
|||||||
const rl = @import("raylib");
|
const rl = @import("raylib");
|
||||||
|
|
||||||
const Vec3 = rl.Vector3;
|
const Vec3 = rl.Vector3;
|
||||||
|
const Vec2 = rl.Vector2;
|
||||||
|
|
||||||
const Frug = struct {
|
const Frug = struct {
|
||||||
pos: Vec3,
|
pos: Vec3,
|
||||||
radius: f32 = 24,
|
radius: f32 = 24,
|
||||||
pub fn draw(self: @This()) void {
|
pub fn draw(self: @This()) void {
|
||||||
rl.drawCircle(
|
rl.drawCircleV(
|
||||||
@intFromFloat(self.pos.x),
|
Vec2.init(self.pos.x, self.pos.y),
|
||||||
@intFromFloat(self.pos.y),
|
|
||||||
self.radius,
|
self.radius,
|
||||||
.green,
|
.green,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub fn init() Frug {
|
pub fn init() Frug {
|
||||||
return Frug {
|
return Frug{
|
||||||
.pos = .{ .x = 200, .y = 400, .z = 10 },
|
.pos = .{ .x = 200, .y = 400, .z = 10 },
|
||||||
.radius = 24,
|
.radius = 24,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
pub fn main(init: std.process.Init) anyerror!void {
|
pub fn main(init: std.process.Init) anyerror!void {
|
||||||
const io = init.io;
|
const io = init.io;
|
||||||
try std.Io.File.stdout().writeStreamingAll(io, "FRUGG!\n");
|
try std.Io.File.stdout().writeStreamingAll(io, "FRUGG!\n");
|
||||||
@ -33,15 +32,23 @@ pub fn main(init: std.process.Init) anyerror!void {
|
|||||||
rl.initWindow(screenWidth, screenHeight, "Zig Frugger");
|
rl.initWindow(screenWidth, screenHeight, "Zig Frugger");
|
||||||
defer rl.closeWindow();
|
defer rl.closeWindow();
|
||||||
|
|
||||||
|
rl.initAudioDevice();
|
||||||
|
defer rl.closeAudioDevice();
|
||||||
|
const frugBurp = try rl.loadSound("resources/burp.mp3");
|
||||||
|
defer rl.unloadSound(frugBurp);
|
||||||
|
|
||||||
|
|
||||||
rl.setTargetFPS(60);
|
rl.setTargetFPS(60);
|
||||||
|
|
||||||
const frug = Frug.init();
|
const frug = Frug.init();
|
||||||
|
|
||||||
while (!rl.windowShouldClose()) {
|
while (!rl.windowShouldClose()) {
|
||||||
rl.beginDrawing();
|
rl.beginDrawing();
|
||||||
defer rl.endDrawing();
|
defer rl.endDrawing();
|
||||||
|
|
||||||
rl.clearBackground(.white);
|
if (rl.isKeyPressed(.space)) rl.playSound(frugBurp);
|
||||||
|
|
||||||
|
rl.clearBackground(.sky_blue);
|
||||||
|
|
||||||
frug.draw();
|
frug.draw();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user