stoff
(Stoff)
September 24, 2023, 7:42am
1
Hello! I'm having some trouble with sprites leaving behind artifacts. (this is with the Windows SDK) It was working fine until I added an additional layer behind the player character.
For drawing tiles I'm using this script that reads from LDTK files
-- version 1.04
--
-- Read levels made with LDtk level editor
-- More information about LDtk: https://ldtk.io/
--
-- Load the levels at the beginning of the game
-- LDtk.load( "levels/world.ldtk" )
-- tilemap = LDtk.create_tilemap( "Level_0" )
--
-- To get collision information, in LDtk create an enum for tiles (Wall, Water, Ladder etc.)
-- Use the enum in the tileset and tag tiles with the desired property
-- In your code:
-- playdate.graphics.sprite.addWallSprites( game.tilemap, LDtk.get_empty_tileIDs( "Level_0", "Solid") )
-- Tilsets
-- It is recommended to save the tileset image in the same folder (or in a sub folder) as the ldtk file
-- The tileset needs to be an image table so the filename should have the format: mytileset-table-w-h.format
-- If a tilemap use flipped tiles, you need to create an additional tileset image that includes mirrored version of the tiles
-- Original tileset: mytileset-table-8-8.png
-- Additional tileset filename: flipped-mytileset-table-8-8.png
This file has been truncated. show original
and for drawing the animated sprite I'm using this:
-----------------------------------------------
--- Sprite class extension with support of ---
--- imagetables and finite state machine, ---
--- with json configuration and autoplay. ---
--- By @Whitebrim git.brim.ml ---
-----------------------------------------------
-- You can find examples and docs at https://github.com/Whitebrim/AnimatedSprite/wiki
-- Comments use EmmyLua style
import 'CoreLibs/object'
import 'CoreLibs/sprites'
local gfx <const> = playdate.graphics
local function emptyFunc()end
class("AnimatedSprite").extends(gfx.sprite)
---@param imagetable table|string actual imagetable or path
---@param states? table If provided, calls `setStates(states)` after initialisation
---@param animate? boolean If `True`, then the animation of default state will start after initialisation. Default: `False`
This file has been truncated. show original
This is my implementation for drawing the tiles
Z_Indexes.BG = -10
and Z_Indexes.FG = 10
Demonstration of artifacting:
Hopefully this hasn't been asked before. I did look around but couldn't find a solve
Edit:
I found a sort of solve and could use some thoughts. It's looking like the artifacting happens when passing over tiles that have no solid pixels in it. What I was doing was selecting this whole box and drawing it in LDTK
if I just select the tiles that have pixels in them it seems to work well but I feel like it's still strange that this happens
1 Like
matt
(gingerbeardman)
September 24, 2023, 11:28am
2
3 Likes
stoff
(Stoff)
March 8, 2024, 8:03am
3
Realized I never replied to say thanks! Really appreciate getting pointed in the right direction!
2 Likes