added texture
This commit is contained in:
1 parent
fd6d66e465
commit
32900a0b5a
4 files changed
+35
-6
No files matched your search
+6
-2
@@ -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);
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
+21
-4
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user