Drawing Quads

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Drawing Quads

Post by davisdude » Mon Oct 13, 2014 9:03 pm

When you create a quad using love.graphics.newQuad, is there any particular reason that the image is not stored as part of the data?
What I mean by that is this:
Why should I have to do

Code: Select all

local Image = love.graphics.newImage( 'Image.png' )
local Quad = love.graphics.newQuad( 0, 0, 32, 32, 32, 32 )

-- Later:
love.graphics.draw( Image, Quad, 0, 0 )
Why can I not just do this:

Code: Select all

local Image = love.graphisc.newImage( 'Image.png' )
local Quad = love.graphics.newQuad( Image, 0, 0, 32, 32, 32, 32 )

-- Later
love.graphics.draw( Quad, 0, 0 )
This would be more like the traditional love.draw method and less confusing, in my opinion.

It could be argued that this keeps less typing (i.e. not typing the image every time you make a new quad), which I understand.
It could also be argued that it is a good coding method to remind you that it is a quad, and not an image, or for flexibility (but are there any examples of this?).

I'm just wondering, that's all. I think this would be better, but I'm no engine developer, just a curious programmer. Thanks. :)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Santos
Party member
Posts: 383
Joined: Sat Oct 22, 2011 7:37 am

Re: Drawing Quads

Post by Santos » Mon Oct 13, 2014 10:42 pm


davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Drawing Quads

Post by davisdude » Tue Oct 14, 2014 1:14 am

Thanks for the link.
SpriteBatches might be the way to go.
Still, I think it would be nice.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

User avatar
Karai17
Party member
Posts: 892
Joined: Sun Sep 02, 2012 10:46 pm

Re: Drawing Quads

Post by Karai17 » Sat Oct 18, 2014 12:34 am

A Quad is not an image, it is set of metadata describing part of an image.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Drawing Quads

Post by davisdude » Sat Oct 18, 2014 2:20 am

That's a good point. I hadn't though of that. :oops:
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests