Text isn't showing up

I really need help. I'm trying to make a game for a game jam that ends tomorrow and I need to have a counter for how much money you have. However, I have followed tons of tutorials, and nothing is working! I'm not getting any error messages, I just can't see any text. I'll give you my code here:


import "CoreLibs/graphics"

import "CoreLibs/object"

import "CoreLibs/sprites"

import "CoreLibs/nineslice"

import "CoreLibs/timer"

import "CoreLibs/graphics"

import "CoreLibs/ui"

import "CoreLibs/animation"

import "CoreLibs/animator"

import "CoreLibs/crank"

import "config"

import "core/definitions"

import "core/cotton/all"

import "scripts/index"

import "core/lieb/all"

import "core/CoreGame"

money = 20

billValue = 20

managers = 0

printers = 1

local gfx <const> = playdate.graphics

playdate.display.setRefreshRate(30)

playdate.ui.crankIndicator:start()

playdate.display.setScale(config.renderScale)

LDtk.load("levels/world.ldtk", shouldUseFastLoader())

if playdate.isSimulator then

    LDtk.export_to_lua_files()

end

local myInputHandlers = {

    cranked = function(change, acceleratedChange)

        -- use the printer

        if acceleratedChange >= 50 then

            print("test")

        end

    end,

}

scene.set(game, LDtk.playerStartLocation)

function playdate.update()

    input.update()

    scene.update()

    if config.showFPS then

        playdate.drawFPS()

    end

    if playdate.isCrankDocked() == true then

        playdate.ui.crankIndicator:update()

    end

    playdate.timer.updateTimers()

    playdate.inputHandlers.push(myInputHandlers)

    gfx.sprite.update()

end

local menu = playdate.getSystemMenu()

local menuItem, error = menu:addMenuItem("Upgrades", function()

    -- nothing for now

end
gfx.drawText("Money: " .. money, 200, 240)

With a quick glance at the code, it just looks like you are drawing the text outside of the screens bounds. The playdate has a screen resolution of 400x240. Try decreasing the y position you are drawing the text to.

E.g.

I just tried that, but it didn't work. Do you have any other ideas? The level is blank with just a black tile border, in case you need to know.

The draw text function is called outside of the update() function.

2 Likes

Oh, that worked! Thanks!

1 Like