refactor some api things
This commit is contained in:
parent
27b6459b9a
commit
1634b1126b
9 changed files with 35 additions and 34 deletions
|
|
@ -19,10 +19,11 @@
|
|||
(var transition-pending nil)
|
||||
|
||||
(fn switch-demo [new-demo]
|
||||
(set transition-pending new-demo)
|
||||
(set transition (pxl8.transition_create :pixelate 0.5))
|
||||
(pxl8.transition_set_color transition 0xFF000000)
|
||||
(pxl8.transition_start transition))
|
||||
(when (not= active-demo new-demo)
|
||||
(set transition-pending new-demo)
|
||||
(set transition (pxl8.transition_create :pixelate 0.5))
|
||||
(pxl8.transition_set_color transition 0xFF000000)
|
||||
(pxl8.transition_start transition)))
|
||||
|
||||
(global init (fn []
|
||||
(cube3d.init)
|
||||
|
|
@ -77,7 +78,7 @@
|
|||
(global frame (fn []
|
||||
(case active-demo
|
||||
:logo (do
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
(when logo-sprite
|
||||
(pxl8.sprite logo-sprite logo-x logo-y 128 64)))
|
||||
|
||||
|
|
@ -86,14 +87,14 @@
|
|||
:tunnel (pxl8.vfx_tunnel time 2.0 0.25)
|
||||
|
||||
:raster (do
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
(local bars [{:base_y 60 :amplitude 30 :height 16 :speed 2.0 :phase 0 :color 1 :fade_color 18}
|
||||
{:base_y 180 :amplitude 35 :height 16 :speed 1.8 :phase 2.0 :color 1 :fade_color 27}
|
||||
{:base_y 300 :amplitude 25 :height 16 :speed 2.2 :phase 4.0 :color 1 :fade_color 24}])
|
||||
(pxl8.vfx_raster_bars bars time))
|
||||
|
||||
:fire (do
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
(when particles
|
||||
(when (not fire-init?)
|
||||
(pxl8.particles_clear particles)
|
||||
|
|
@ -102,7 +103,7 @@
|
|||
(pxl8.particles_render particles)))
|
||||
|
||||
:rain (do
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
(when particles
|
||||
(when (not rain-init?)
|
||||
(pxl8.particles_clear particles)
|
||||
|
|
@ -111,7 +112,7 @@
|
|||
(pxl8.particles_render particles)))
|
||||
|
||||
:snow (do
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
(when particles
|
||||
(when (not snow-init?)
|
||||
(pxl8.particles_clear particles)
|
||||
|
|
@ -123,7 +124,7 @@
|
|||
|
||||
:worldgen (worldgen.frame)
|
||||
|
||||
_ (pxl8.clr 0))
|
||||
_ (pxl8.clear 0))
|
||||
|
||||
(when transition
|
||||
(pxl8.transition_render transition))))
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@
|
|||
(pxl8.draw_triangle_3d v0 v1 v2 color)))))))
|
||||
|
||||
(fn frame []
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
|
||||
(pxl8.clear_zbuffer)
|
||||
(pxl8.set_affine_textures affine?)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@
|
|||
(set bob-time (+ (* bob-time 0.8) (* target-phase 0.2))))))))
|
||||
|
||||
(fn frame []
|
||||
(pxl8.clr 0)
|
||||
(pxl8.clear 0)
|
||||
|
||||
(when (pxl8.world_is_loaded world)
|
||||
(let [bob-offset (* (math.sin bob-time) bob-amount)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
local ffi = require("ffi")
|
||||
|
||||
local core = require("pxl8.core")
|
||||
local graphics = require("pxl8.graphics")
|
||||
local gfx2d = require("pxl8.gfx2d")
|
||||
local input = require("pxl8.input")
|
||||
local vfx = require("pxl8.vfx")
|
||||
local particles = require("pxl8.particles")
|
||||
|
|
@ -26,21 +26,21 @@ pxl8.error = core.error
|
|||
pxl8.debug = core.debug
|
||||
pxl8.trace = core.trace
|
||||
|
||||
pxl8.clr = graphics.clr
|
||||
pxl8.pixel = graphics.pixel
|
||||
pxl8.line = graphics.line
|
||||
pxl8.rect = graphics.rect
|
||||
pxl8.rect_fill = graphics.rect_fill
|
||||
pxl8.circle = graphics.circle
|
||||
pxl8.circle_fill = graphics.circle_fill
|
||||
pxl8.text = graphics.text
|
||||
pxl8.sprite = graphics.sprite
|
||||
pxl8.load_palette = graphics.load_palette
|
||||
pxl8.load_sprite = graphics.load_sprite
|
||||
pxl8.create_texture = graphics.create_texture
|
||||
pxl8.upload_atlas = graphics.upload_atlas
|
||||
pxl8.gfx_color_ramp = graphics.color_ramp
|
||||
pxl8.gfx_fade_palette = graphics.fade_palette
|
||||
pxl8.clear = gfx2d.clear
|
||||
pxl8.pixel = gfx2d.pixel
|
||||
pxl8.line = gfx2d.line
|
||||
pxl8.rect = gfx2d.rect
|
||||
pxl8.rect_fill = gfx2d.rect_fill
|
||||
pxl8.circle = gfx2d.circle
|
||||
pxl8.circle_fill = gfx2d.circle_fill
|
||||
pxl8.text = gfx2d.text
|
||||
pxl8.sprite = gfx2d.sprite
|
||||
pxl8.load_palette = gfx2d.load_palette
|
||||
pxl8.load_sprite = gfx2d.load_sprite
|
||||
pxl8.create_texture = gfx2d.create_texture
|
||||
pxl8.upload_atlas = gfx2d.upload_atlas
|
||||
pxl8.gfx_color_ramp = gfx2d.color_ramp
|
||||
pxl8.gfx_fade_palette = gfx2d.fade_palette
|
||||
|
||||
pxl8.key_down = input.key_down
|
||||
pxl8.key_pressed = input.key_pressed
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ local core = require("pxl8.core")
|
|||
|
||||
local graphics = {}
|
||||
|
||||
function graphics.clr(color)
|
||||
C.pxl8_clr(core.gfx, color or 0)
|
||||
function graphics.clear(color)
|
||||
C.pxl8_clear(core.gfx, color or 0)
|
||||
end
|
||||
|
||||
function graphics.pixel(x, y, color)
|
||||
|
|
@ -252,7 +252,7 @@ pxl8_game_result pxl8_frame(pxl8_game* game) {
|
|||
pxl8_error("Error calling frame: %s", pxl8_script_get_last_error(game->script));
|
||||
}
|
||||
} else {
|
||||
pxl8_clr(game->gfx, 32);
|
||||
pxl8_clear(game->gfx, 32);
|
||||
|
||||
i32 render_width, render_height;
|
||||
pxl8_gfx_get_resolution_dimensions(game->resolution, &render_width, &render_height);
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ void pxl8_gfx_project(pxl8_gfx* gfx, f32 left, f32 right, f32 top, f32 bottom) {
|
|||
(void)gfx; (void)left; (void)right; (void)top; (void)bottom;
|
||||
}
|
||||
|
||||
void pxl8_clr(pxl8_gfx* gfx, u32 color) {
|
||||
void pxl8_clear(pxl8_gfx* gfx, u32 color) {
|
||||
if (!gfx || !gfx->framebuffer) return;
|
||||
|
||||
static u32 frame_count = 0;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ void pxl8_gfx_swap_palette(pxl8_gfx* gfx, u8 start, u8 count, u32* new_colors);
|
|||
|
||||
void pxl8_circle(pxl8_gfx* gfx, i32 cx, i32 cy, i32 radius, u32 color);
|
||||
void pxl8_circle_fill(pxl8_gfx* gfx, i32 cx, i32 cy, i32 radius, u32 color);
|
||||
void pxl8_clr(pxl8_gfx* gfx, u32 color);
|
||||
void pxl8_clear(pxl8_gfx* gfx, u32 color);
|
||||
u32 pxl8_get_pixel(pxl8_gfx* gfx, i32 x, i32 y);
|
||||
void pxl8_line(pxl8_gfx* gfx, i32 x0, i32 y0, i32 x1, i32 y1, u32 color);
|
||||
void pxl8_pixel(pxl8_gfx* gfx, i32 x, i32 y, u32 color);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ static const char* pxl8_ffi_cdefs =
|
|||
"i32 pxl8_gfx_get_width(pxl8_gfx* ctx);\n"
|
||||
"void pxl8_circle(pxl8_gfx* ctx, i32 x, i32 y, i32 r, u32 color);\n"
|
||||
"void pxl8_circle_fill(pxl8_gfx* ctx, i32 x, i32 y, i32 r, u32 color);\n"
|
||||
"void pxl8_clr(pxl8_gfx* ctx, u32 color);\n"
|
||||
"void pxl8_clear(pxl8_gfx* ctx, u32 color);\n"
|
||||
"u32 pxl8_get_pixel(pxl8_gfx* ctx, i32 x, i32 y);\n"
|
||||
"void pxl8_line(pxl8_gfx* ctx, i32 x0, i32 y0, i32 x1, i32 y1, u32 color);\n"
|
||||
"void pxl8_pixel(pxl8_gfx* ctx, i32 x, i32 y, u32 color);\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue