Skip to content

Commit

Permalink
Update wasm4 bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
ibillingsley committed Aug 23, 2022
1 parent a1f04b5 commit df929e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Binary file modified dist/one-slime-army.wasm
Binary file not shown.
11 changes: 6 additions & 5 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Player = struct {
w4.DRAW_COLORS.* = 0x22;
drawCircle(x + round(i32, self.look_dir.x * 5), y + round(i32, self.look_dir.y * 5), 17);
w4.DRAW_COLORS.* = 0x11;
drawCircle(x, y, 15 - self.attack_timer);
drawCircle(x, y, 15 - @intCast(u32, self.attack_timer));
}
// player
w4.DRAW_COLORS.* = if (self.dodge_timer > 0) 0x31 else 0x33;
Expand Down Expand Up @@ -580,7 +580,7 @@ const Explosion = struct {

fn draw(self: @This()) void {
w4.DRAW_COLORS.* = self.color;
if (self.timer > 0) drawCircle(self.pos.x, self.pos.y, self.timer * 2 - 1);
if (self.timer > 0) drawCircle(self.pos.x, self.pos.y, @intCast(u32, self.timer) * 2 - 1);
}
};

Expand Down Expand Up @@ -863,12 +863,13 @@ fn drawPixel(x: i32, y: i32) void {
w4.rect(x, y, 1, 1);
}

fn drawCircle(x: i32, y: i32, size: i32) void {
w4.oval(x - @divFloor(size, 2), y - @divFloor(size, 2), size, size);
fn drawCircle(x: i32, y: i32, size: u32) void {
const s = @intCast(i32, size / 2);
w4.oval(x - s, y - s, size, size);
}

fn drawCircleF(x: f64, y: f64, size: f64) void {
const s = round(i32, size);
const s = round(u32, size);
w4.oval(round(i32, x - (size / 2)), round(i32, y - (size / 2)), s, s);
}

Expand Down
6 changes: 3 additions & 3 deletions src/wasm4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ pub const SYSTEM_HIDE_GAMEPAD_OVERLAY: u8 = 2;
// └───────────────────────────────────────────────────────────────────────────┘

/// Copies pixels to the framebuffer.
pub extern fn blit(sprite: [*]const u8, x: i32, y: i32, width: i32, height: i32, flags: u32) void;
pub extern fn blit(sprite: [*]const u8, x: i32, y: i32, width: u32, height: u32, flags: u32) void;

/// Copies a subregion within a larger sprite atlas to the framebuffer.
pub extern fn blitSub(sprite: [*]const u8, x: i32, y: i32, width: i32, height: i32, src_x: u32, src_y: u32, stride: i32, flags: u32) void;
pub extern fn blitSub(sprite: [*]const u8, x: i32, y: i32, width: u32, height: u32, src_x: u32, src_y: u32, stride: u32, flags: u32) void;

pub const BLIT_2BPP: u32 = 1;
pub const BLIT_1BPP: u32 = 0;
Expand All @@ -64,7 +64,7 @@ pub const BLIT_ROTATE: u32 = 8;
pub extern fn line(x1: i32, y1: i32, x2: i32, y2: i32) void;

/// Draws an oval (or circle).
pub extern fn oval(x: i32, y: i32, width: i32, height: i32) void;
pub extern fn oval(x: i32, y: i32, width: u32, height: u32) void;

/// Draws a rectangle.
pub extern fn rect(x: i32, y: i32, width: u32, height: u32) void;
Expand Down
2 changes: 1 addition & 1 deletion wapm.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ibillingsley/one-slime-army"
version = "1.2.1"
version = "1.2.2"
description = "One Slime Army is an arcade endless wave survival game for the WASM-4 fantasy console"
license = "ISC"
readme = "README.md"
Expand Down

0 comments on commit df929e8

Please sign in to comment.