How to make Quads

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
crystalheartstudios
Prole
Posts: 10
Joined: Thu Sep 04, 2014 7:38 pm

How to make Quads

Post by crystalheartstudios »

Alright, well I am currently following https://github.com/kikito/love-tile-tut ... and-images <----- this guide. I am attempting to make a tile based game, but I am having trouble getting the quads to work.

My code is as follows:

Code: Select all


function love.load()
  
  Tileset = love.graphics.newImage('countryside.png')
  
  local tileW = 32
  local tileH = 32
  local tilesetW = Tileset:getWidth()
  local tilesetH = Tileset:getHeight()
  
  GrassQuad = love.graphics.newQuad(0,  0, tileW, tileH, tilesetW, tilesetH)
  BoxQuad = love.graphics.newQuad(32,  0, tileW, tileH, tilesetW, tilesetH)

end

function love.draw()
  love.graphics.draw(Tileset, GrassQuad, 368, 268)
  love.graphics.draw(Tileset, GrassQuad, 400, 268)
  love.graphics.draw(Tileset, GrassQuad, 432, 268)
  love.graphics.draw(Tileset, GrassQuad, 368, 300)
  love.graphics.draw(Tileset, BoxQuad  , 400, 300)
  love.graphics.draw(Tileset, GrassQuad, 432, 300)
  love.graphics.draw(Tileset, GrassQuad, 368, 332)
  love.graphics.draw(Tileset, GrassQuad, 400, 332)
  love.graphics.draw(Tileset, GrassQuad, 432, 332)
end

However when I execute it I recieve the following error:

Code: Select all


main.lua: 16 bad argument #2 to 'draw' (number expected, got userdata)

Traceback

[C]: in function 'draw'
main.lua:16: in function 'draw'
[C]: in function 'xpcall'
Can someone please tell me what I'm doing wrong?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to make Quads

Post by kikito »

Hi, I made that tutorial that you are following :)

The error you are getting suggests that you are using an older version of LÖVE. Try uninstalling what you have, downloading a new version from the website, and installing that instead.
When I write def I mean function.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: How to make Quads

Post by HugoBDesigner »

You're probably using LÖVE 0.8.0. In 0.9.x, Quads are used in love.graphics.draw and are optional, which is great, but before this version quads could only be used with love.graphics.drawq. Drawing things with no quads used love.graphics.draw.

So you can either change all the functions that use quads to "love.graphics.drawq" or use a more recent version of LÖVE :)
@HugoBDesigner - Twitter
HugoBDesigner - Blog
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest