easy way to render pixelart with PIX.lua

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
jeana
Prole
Posts: 3
Joined: Thu Aug 29, 2019 1:41 pm

easy way to render pixelart with PIX.lua

Post by jeana »

this is a library for full window pixel art style games
PIX.lua has 3 modes to display the screen and includes some convenient helper functions.

you set the minimum width and height the screen pixels should be and PIX.lua will create the most optimal screen size

library is available on GitHub: https://github.com/jeanahelver/PIX.lua

modes:
  • "floor", tries most optimal amount of pixels for the aspect ratio, pixels will all be equal size
  • "stretch", stretches the pixels to fill the screen, pixels could be different size
  • number, fixed amount the pixels will scale
helper functions:
  • PIX.newImage( fileName )
  • PIX.mouse.getPosition()
  • PIX.mouse.getX()
  • PIX.mouse.getX()
useful variables are PIX.width and PIX.height they will give you the current screen size

see sample main.lua for implementation details
PIX.love
(2.49 KiB) Downloaded 403 times
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: easy way to render pixelart with PIX.lua

Post by D0NM »

Yo! Cool library.
I was going to use many ifthenS for the same result.

update: I've checked your sources. Well, it is not our case.
I use "push" library and it has all the stretching modes, including the pixel-perfect one.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
jeana
Prole
Posts: 3
Joined: Thu Aug 29, 2019 1:41 pm

Re: easy way to render pixelart with PIX.lua

Post by jeana »

what do you mean, not your case?
User avatar
jeana
Prole
Posts: 3
Joined: Thu Aug 29, 2019 1:41 pm

Re: easy way to render pixelart with PIX.lua

Post by jeana »

the push library you linked to seems weird.
PIX supports windowed, resized window and full screen as love.resize triggers for those switches.
PIX always uses a canvas and can be layered however you want mixed with none pixelart graphics.
PIX has 2 pixelperfect modes indexed and "floor" and can be swapped at runtime if needed for user preferences
highdpi also works on PIX

in addition PIX has helper functions to restore love2D functionality like mouse support and newImage to have crisp pixel graphics. PIX should also support mobile already.

PIX solution to overscan is to have extra pixel to not create a border, if you want a border consider using maid64 wich this library is inspired by
solaris
Prole
Posts: 1
Joined: Mon Sep 28, 2020 8:21 pm

Re: easy way to render pixelart with PIX.lua

Post by solaris »

I know you're probably not checking this account anymore, but I'm trying to use your library and I'm having a bit of an issue. For a tutorial I'm following, you center the player character by dividing the height and width of the window by 2 and using that as your draw coordinates. I tried to use the PIX.width and PIX.height attributes you mentioned in this post, but I get the error "attempt to perform arithmetic on field 'width' (a nil value)". It obviously shouldn't be a nil value, but I don't know what's going wrong. Please advise.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: easy way to render pixelart with PIX.lua

Post by pgimeno »

solaris wrote: Mon Sep 28, 2020 8:35 pm I know you're probably not checking this account anymore, but I'm trying to use your library and I'm having a bit of an issue. For a tutorial I'm following, you center the player character by dividing the height and width of the window by 2 and using that as your draw coordinates. I tried to use the PIX.width and PIX.height attributes you mentioned in this post, but I get the error "attempt to perform arithmetic on field 'width' (a nil value)". It obviously shouldn't be a nil value, but I don't know what's going wrong. Please advise.
I'm not the original author, but after a quick look at the source, I noticed that PIX is returned by the module, and not defined as a global, which made me wonder how you are requiring the library. You should be using it like this:

Code: Select all

local PIX = require 'PIX'
and not like this:

Code: Select all

require 'PIX'
Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests