added texture
This commit is contained in:
parent
fd6d66e465
commit
32900a0b5a
BIN
assets/nice_boy.png
Normal file
BIN
assets/nice_boy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 960 KiB |
@ -4,6 +4,12 @@ pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const assets = b.addInstallDirectory(.{
|
||||
.source_dir = .{ .src_path = .{ .owner = b, .sub_path = "assets" } },
|
||||
.install_dir = .bin,
|
||||
.install_subdir = "assets",
|
||||
});
|
||||
|
||||
const raylib_dep = b.dependency("raylib_zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
@ -104,6 +110,8 @@ pub fn build(b: *std.Build) void {
|
||||
b.installArtifact(client);
|
||||
b.installArtifact(server);
|
||||
|
||||
b.getInstallStep().dependOn(&assets.step);
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
|
||||
const run_cmd_client = b.addRunArtifact(client);
|
||||
|
||||
@ -103,12 +103,16 @@ pub fn main() !void {
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.clearBackground(.sky_blue);
|
||||
|
||||
rl.beginDrawing();
|
||||
defer rl.endDrawing();
|
||||
|
||||
rl.clearBackground(.sky_blue);
|
||||
rl.drawText("Congrats! You created your first window!", rl.getMouseX(), rl.getMouseY(), 20, .white);
|
||||
rl.drawRectangleLines(0, 0, 100, 100, .red);
|
||||
|
||||
rl.drawFPS(0, 0);
|
||||
|
||||
rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray);
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
const std = @import("std");
|
||||
const zm = @import("zmath");
|
||||
const protocol = @import("protocol.zig");
|
||||
const rl = @import();
|
||||
|
||||
pub const entity_id = u64;
|
||||
pub const INVALID_ENTITY_ID: entity_id = 0;
|
||||
@ -16,13 +17,29 @@ pub const Player = struct {
|
||||
pos: zm.Vec,
|
||||
hp: i32,
|
||||
|
||||
pub fn encode(self: Projectile, w: *std.Io.Writer) !void {
|
||||
boy: rl.Texture,
|
||||
|
||||
pub fn init() void {
|
||||
const boy = try rl.loadTexture("assets/nice_boy.png");
|
||||
}
|
||||
|
||||
pub fn update(self: *Player) void {
|
||||
self.pos += zm.f32x4(1, 1, 0, 0);
|
||||
}
|
||||
|
||||
pub fn draw(self: *Player) void {
|
||||
const src = rl.Rectangle.init(0, 0, @floatFromInt(boy.width), @floatFromInt(boy.height));
|
||||
const dst = rl.Rectangle.init(100 + 100 * zm.cos(@as(f32, @floatCast(rl.getTime()))), 100 + 100 * zm.sin(@as(f32, @floatCast(rl.getTime()))), @floatFromInt(boy.width), @floatFromInt(boy.height));
|
||||
boy.drawPro(src, dst, .{ .x = 0, .y = 0 }, 0, .white);
|
||||
}
|
||||
|
||||
pub fn encode(self: Player, w: *std.Io.Writer) !void {
|
||||
try w.writeInt(u64, self.id, .little);
|
||||
try protocol.writeVec4(w, self.pos);
|
||||
try protocol.writeVec4(w, self.vel);
|
||||
}
|
||||
|
||||
pub fn decode(r: *std.Io.Reader) !Projectile {
|
||||
pub fn decode(r: *std.Io.Reader) !Player {
|
||||
return .{
|
||||
.id = try r.readInt(u64, .little),
|
||||
.pos = try protocol.readVec4(r),
|
||||
@ -36,13 +53,13 @@ pub const Monster = struct {
|
||||
pos: zm.Vec,
|
||||
hp: i32,
|
||||
|
||||
pub fn encode(self: Projectile, w: *std.Io.Writer) !void {
|
||||
pub fn encode(self: Monster, w: *std.Io.Writer) !void {
|
||||
try w.writeInt(u64, self.id, .little);
|
||||
try protocol.writeVec4(w, self.pos);
|
||||
try protocol.writeVec4(w, self.vel);
|
||||
}
|
||||
|
||||
pub fn decode(r: *std.Io.Reader) !Projectile {
|
||||
pub fn decode(r: *std.Io.Reader) !Monster {
|
||||
return .{
|
||||
.id = try r.readInt(u64, .little),
|
||||
.pos = try protocol.readVec4(r),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user