organize headers, add icon/logo sprites to demo

This commit is contained in:
asrael 2025-10-01 12:56:13 -05:00
parent 553bf95c3b
commit 2a1a3f1768
21 changed files with 52 additions and 44 deletions

View file

@ -15,8 +15,8 @@
(global init (fn []
(pxl8.load_palette "palettes/gruvbox.ase")
(set logo-sprite (pxl8.load_sprite "sprites/pxl8_logo.ase"))))
(set particles (pxl8.particles_new 1000))
(set logo-sprite (pxl8.load_sprite "sprites/pxl8.ase"))))
(global update (fn [dt]
(set time (+ time dt))
@ -52,13 +52,11 @@
(pxl8.particles_update particles dt))))
(global draw (fn []
(match current-effect
(case current-effect
1 (do
(pxl8.clr 0)
(when logo-sprite
(pxl8.sprite logo-sprite logo-x logo-y 128 64))
(pxl8.text "Bouncing Logo" 200 10 15)
(pxl8.text "Press 1-7 for effects" 10 150 7))
(pxl8.sprite logo-sprite logo-x logo-y 128 64)))
2 (pxl8.vfx_plasma time 0.10 0.04 0)
@ -69,8 +67,7 @@
(local bars [{:base_y 40 :amplitude 20 :height 16 :speed 2.0 :phase 0 :color 14 :fade_color 11}
{:base_y 80 :amplitude 15 :height 16 :speed 2.5 :phase 1.5 :color 20 :fade_color 11}
{:base_y 120 :amplitude 25 :height 16 :speed 1.8 :phase 3.0 :color 26 :fade_color 11}])
(pxl8.vfx_raster_bars bars time)
(pxl8.text "Raster Bars" 200 10 15))
(pxl8.vfx_raster_bars bars time))
5 (do
(pxl8.clr 0)
@ -79,8 +76,7 @@
(pxl8.particles_clear particles)
(pxl8.vfx_fire particles 160 140 100 12)
(set fire-init true))
(pxl8.particles_render particles))
(pxl8.text "Fire Effect Test" 200 10 15))
(pxl8.particles_render particles)))
6 (do
(pxl8.clr 0)
@ -89,8 +85,7 @@
(pxl8.particles_clear particles)
(pxl8.vfx_rain particles 320 10.0)
(set rain-init true))
(pxl8.particles_render particles))
(pxl8.text "Rain" 200 10 15))
(pxl8.particles_render particles)))
7 (do
(pxl8.clr 0)
@ -99,7 +94,6 @@
(pxl8.particles_clear particles)
(pxl8.vfx_snow particles 320 5.0)
(set snow-init true))
(pxl8.particles_render particles))
(pxl8.text "Snow" 200 10 15))
(pxl8.particles_render particles)))
_ (pxl8.clr 0))))

BIN
demo/sprites/pxl8_icon.ase Normal file

Binary file not shown.

View file

@ -8,7 +8,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include "linenoise.h"
#include <linenoise.h>
#define SDL_MAIN_USE_CALLBACKS
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>

View file

@ -1,4 +1,3 @@
#include <SDL3/SDL.h>
#include <stdlib.h>
#include <string.h>
@ -7,7 +6,9 @@
#define MINIZ_NO_ARCHIVE_APIS
#define MINIZ_NO_ARCHIVE_WRITING_APIS
#define MINIZ_NO_DEFLATE_APIS
#include "miniz.h"
#include <miniz.h>
#include <SDL3/SDL.h>
#include "pxl8_ase.h"
#include "pxl8_io.h"

View file

@ -1,4 +1,5 @@
#pragma once
#include "pxl8_types.h"
#define PXL8_ASE_MAGIC 0xA5E0

View file

@ -1,7 +1,7 @@
#pragma once
#include "pxl8_types.h"
#include "pxl8_simd.h"
#include "pxl8_types.h"
static inline bool pxl8_is_simd_aligned(u32 w) {
return w >= PXL8_SIMD_WIDTH_U8 && (w % PXL8_SIMD_WIDTH_U8 == 0);

View file

@ -1,12 +1,15 @@
#include "pxl8_cart.h"
#include "pxl8_macros.h"
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../lib/miniz/miniz.h"
#include <miniz.h>
#include "pxl8_cart.h"
#include "pxl8_macros.h"
static pxl8_cart* __pxl8_current_cart = NULL;
static char* __pxl8_original_cwd = NULL;

View file

@ -1,7 +1,9 @@
#include "pxl8_font.h"
#include <SDL3/SDL.h>
#include <string.h>
#include <SDL3/SDL.h>
#include "pxl8_font.h"
pxl8_result pxl8_font_create_atlas(const pxl8_font* font, u8** atlas_data, i32* atlas_width, i32* atlas_height) {
if (!font || !atlas_data || !atlas_width || !atlas_height) {
return PXL8_ERROR_NULL_POINTER;

View file

@ -1,9 +1,10 @@
#include "pxl8_gfx.h"
#include <stdlib.h>
#include "pxl8_ase.h"
#include "pxl8_blit.h"
#include "pxl8_gfx.h"
#include "pxl8_macros.h"
#include "pxl8_types.h"
#include "pxl8_blit.h"
#include <stdlib.h>
static u32 pxl8_get_palette_size(pxl8_color_mode mode) {
switch (mode) {

View file

@ -1,10 +1,11 @@
#pragma once
#include <string.h>
#include <SDL3/SDL.h>
#include "pxl8_types.h"
#include "pxl8_blit.h"
#include "pxl8_types.h"
typedef struct pxl8_atlas_entry {
char path[256];

View file

@ -1,3 +1,5 @@
#include <SDL3/SDL.h>
#include "pxl8_io.h"
pxl8_result pxl8_io_read_file(const char* path, char** content, size_t* size) {

View file

@ -3,8 +3,6 @@
#include <stdio.h>
#include <sys/stat.h>
#include <SDL3/SDL_stdinc.h>
#include "pxl8_types.h"
#ifdef __cplusplus

View file

@ -1,8 +1,9 @@
#include "pxl8_lua.h"
#include "pxl8_vfx.h"
#include "pxl8_macros.h"
#include <unistd.h>
#include "pxl8_lua.h"
#include "pxl8_macros.h"
#include "pxl8_vfx.h"
static const char* pxl8_ffi_cdefs =
"typedef uint8_t u8;\n"
"typedef uint16_t u16;\n"

View file

@ -4,8 +4,8 @@
#include <lualib.h>
#include <lauxlib.h>
#include "pxl8_gfx.h"
#include "pxl8_types.h"
#include "pxl8_gfx.h"
#ifdef __cplusplus
extern "C" {

View file

@ -1,9 +1,10 @@
#include "pxl8_tilemap.h"
#include "pxl8_tilesheet.h"
#include "pxl8_macros.h"
#include <stdlib.h>
#include <string.h>
#include "pxl8_macros.h"
#include "pxl8_tilemap.h"
#include "pxl8_tilesheet.h"
static inline u32 pxl8_chunk_index(u32 x, u32 y, u32 chunks_wide) {
return (y >> 4) * chunks_wide + (x >> 4);
}

View file

@ -1,8 +1,8 @@
#pragma once
#include "pxl8_types.h"
#include "pxl8_gfx.h"
#include "pxl8_tilesheet.h"
#include "pxl8_types.h"
#define PXL8_TILE_SIZE 16
#define PXL8_MAX_TILEMAP_WIDTH 256

View file

@ -1,10 +1,11 @@
#include "pxl8_tilesheet.h"
#include "pxl8_tilemap.h"
#include "pxl8_ase.h"
#include "pxl8_macros.h"
#include <stdlib.h>
#include <string.h>
#include "pxl8_ase.h"
#include "pxl8_macros.h"
#include "pxl8_tilesheet.h"
#include "pxl8_tilemap.h"
void pxl8_tilesheet_free(pxl8_tilesheet* tilesheet) {
if (!tilesheet) return;

View file

@ -1,7 +1,7 @@
#pragma once
#include <SDL3/SDL.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef uint8_t u8;

View file

@ -1,9 +1,11 @@
#include "pxl8_vfx.h"
#include "pxl8_macros.h"
#include <math.h>
#include <stdlib.h>
#include <SDL3/SDL.h>
#include "pxl8_macros.h"
#include "pxl8_vfx.h"
void pxl8_vfx_plasma(pxl8_gfx_ctx* ctx, f32 time, f32 scale1, f32 scale2, u8 palette_offset) {
if (!ctx || !ctx->framebuffer) return;

View file

@ -1,7 +1,7 @@
#pragma once
#include "pxl8_types.h"
#include "pxl8_gfx.h"
#include "pxl8_types.h"
typedef struct pxl8_particle {
f32 x, y, z;