Drawing pixelated things

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bruno Ely

I’m working on a game that uses pixel art and like to keep all my pixels the same size. To achieve that, I have the zoom property set to (0.5, 0.5) on my Camera2D (I tried using the viewport stretch mode but that caused a few duplicated horizontal lines which looked really weird).

I’m trying to find a way to draw things in a pixelated way, keeping the visuals pixel-perfect (i.e. no “half-pixels”). Here’s what a default Line2D looks like:

Non-pixelated line drawn by Line2D

As you can see, it doesn’t really respect my camera’s zoom, and its pixels are way smaller than my sprites’ (the sprites are drawn to scale, so each pixel is an actual pixel and they’re not scaled; only the final viewport is scaled through the camera’s zoom).

Is there a way to draw that in a pixelated way? What about lights and other objects that are drawn (such as collision shapes, for example, though there’s probably no use in drawing those in a pixel-perfect manner)?

:bust_in_silhouette: Reply From: Thewolfs

Take a look at this :

What they propose is to have your window size corresponding to your pixel screen size (for example 160x90) and then set your stretch mode to viewport and the aspect to keep, keep_width, keep_height depending on what you want