• Introduction
• Raw Code
• Code Explanation
• Understanding love.graphics.print
• Conclusion
Introduction
This tutorial will teach you how to display text using LövePotion. To do so, you will need:
• Any text editor.
• A way to launch 3DS homebrew.
• LövePotion set and ready to go.
Raw Code
Code: Select all
-- How to draw text
function love.draw()
love.graphics.setScreen("top")
love.graphics.print("Top screen.", 0, 0)
love.graphics.setScreen("bottom")
love.graphics.print("Bottom screen.", 0, 0)
end
What you see below is a comment. Comments are ignored by LövePotion and are left there for various purposes, such as leaving personal notes. To leave a comment, two hyphens must be together before your text. This is required for every line of comment that is in your code.
Code: Select all
-- How to draw text
Code: Select all
function love.draw()
Code: Select all
love.graphics.setScreen("top")
Code: Select all
love.graphics.print("Top screen.", 0, 0)
Code: Select all
love.graphics.setScreen("bottom")
Code: Select all
love.graphics.print("Bottom screen.", 0, 0)
Code: Select all
end
To draw text on the screens, it is important that you first understand how love.graphics.print works.
The image above is the same resolution as the top screen of the 3DS. (X, Y) is where the text will be drawn. If I tell LövePotion love.graphics.print("Text", 10, 20 ), LövePotion will draw whatever is inside the quotes, in this case "Text", on the (X, Y) coordinates that I gave it, here being (10, 20). Starting from (0, 0), LövePotion will move 10 pixels to the right, 20 pixels down, and will finally draw "Text".
Know that you're visually restricted to the resolution of the screen, 400x240 for the top and 320x240 for the bottom. If you use values greater or smaller than that of the resolution, part of the text may show cut off, or may not show at all. Here is an example where X is -15 and Y is 20.
To display text on the bottom screen, you can follow the same guide for the top screen, keeping in mind the resolution.
Conclusion
Open up any text editor and type what is in the Raw Code section of this tutorial. You are free to experiment and change things to your liking. Once everything is done, save it as main.lua instead of whateverthetextwouldnormallybe.txt, and place it in a directory where LövePotion can read it.
Boot LövePotion and that's that for now.
Advertising