Assert error when running "Basic Playdate Game" in simulator

Hi all,
I'm trying to run the Basic Playdate Game in the simulator and I keep getting an assert error on line 31, where it's checking the image. Here's what the console is showing:

21:15:23: Loading: c:\Users\Michael\workspaces\playdate\myFirstTestProject\main.pdx\
21:15:27: Loading: Failed
Load failed, error: main.lua:31: assertion failed!
stack traceback:
	[C]: in function 'assert'
	main.lua:31: in function 'myGameSetUp'
	main.lua:61: in main chunk

I'm able to compile the project without issue. I'm running this on Windows 11. Not sure what I'm doing wrong, any advice is appreciated.

Update: Just tried in Linux and got the same result

Here is where it's failing:

    -- Set up the player sprite.
    local playerImage = gfx.image.new("Images/playerImage")
    assert( playerImage ) -- make sure the image was where we thought

The assert is triggering because the playerImage variable is nil because there is no image to load.

That example is kinda incomplete, you'll need to have two images for it to work.

Source\Images\playerImage.png
Source\Images\background.png

The latter should be 400x240 and the former can be any size.


Note, assert takes an optional message as the second parameter which will give friendlier/custom error messages:

local playerImage = gfx.image.new( "Images/playerImage" )
assert( playerImage, "failed to load playerImage from file")
2 Likes

That makes sense. I’ll add those files to fix. Thank you!