How to set your game up if you want to make a pixel art game. With Defold, you can make great looking pixel art games. If you wanted to, you could even apply shaders to your game to make your game look like it’s being played on an old style screen (2) (topic for another post).
Say you want to make a NES style game. The resolution of the NES is 256 x 240. You’ll make your assets to fit this resolution.
Here is a screenshot of the NES game Castelvania in native resolution from an emulator.
Playing on a computer in Window mode you’ll probably want your users to have an option to play at a larger screen, at least twice the size.
After you create your project, edit the game.project and set its display width and height to that of double the NES
While you’re there change your graphic sampling so that they are set to nearest
In your render_script, you will make it so that your game assets made for the NES resolution are scaled up during rendering to fix the game’s resolution.
Here is a sample render script to study
pixel.lua (2.8 KB)
This script includes three features 1. it upscales assets to fit your game’s view 2. it constraints the view to be proportional while the game’s window is resized 3. it centers the view inside of the view differently depending on if the window is wider or taller.
You’ll want to modify this script further to optimize and adjust it for the needs of your pixel art game.
And another style to study
Unfortunately at this time (Version 1.2.78)
- there is no way to change the game window size via scripting. If there was, then in your game’s option menu you could give the user the ability to select 1x, 2x, 3x etc. window scaling so that its scaling is pixel perfect
- there is no way to change to and from fullscreen mode with scripting
- while in fullscreen mode, the game is scaled to a bad resolution, and doesn’t scale to the full resolution of a user’s monitor - a maximized game window looks much better than a fullscreen mode window, which looks stretched and blurry
If you want to use pixel fonts in your game you’ll need to know that they do not currently respect the sampling set in game.project - to fix this, make a copy of the font.material from the builtins/font folder, and add a sampler to it with these settings
Then in your .font files for pixel fonts change its material to the new font material.
Your fonts will look right in game, but currently in the editor they will look blurry due to a bug.
These are the basics for starting to make a pixel art game with Defold, the rest is up to you - or another post.