"Questions that don't deserve their own thread" thread

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.
Locked
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: "Questions that don't deserve their own thread" thread

Post by megalukes »

Thanks, guys. This was kind of hard to understand since the rectangle's draw function doesn't have sx/y and ox/y arguments. I did a bunch of pushes and pops to control it better.

Code: Select all

quad = {}
quad.x = 0
quad.y = 0
quad.sx = 1
quad.sy = 1
quad.r = 0
quad.w = 256
quad.h = 128
quad.ox = quad.w/2
quad.oy = quad.h/2

function love.update(dt)
   quad.x, quad.y = love.mouse.getPosition()
end

function love.draw()

	love.graphics.push()
	love.graphics.translate(quad.x+quad.ox, quad.y+quad.oy)

	love.graphics.push()
	love.graphics.translate(-quad.ox, -quad.oy) 
	love.graphics.rotate(quad.r)
	love.graphics.scale(quad.sx, quad.sy)
	love.graphics.setColor(255,255,255)
	love.graphics.rectangle("fill", 0-quad.ox, 0-quad.oy, quad.w, quad.h) 

	love.graphics.pop()

	love.graphics.pop()
end

function love.wheelmoved( x, y )
   quad.sx = quad.sx + 0.01*y
   quad.sy = quad.sy + 0.01*y
   quad.ox = (quad.w)/2
   quad.oy = (quad.h)/2
   quad.r = quad.r + 0.01*x
end
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: "Questions that don't deserve their own thread" thread

Post by Positive07 »

Slime is there a chance of unifying the syntax for all things drawn to screen so either all provide offsets and scale settings or all depend on transformations? I think I saw a commit a couple of days ago about transformation matrixes that could help on this. What are your ideas about this stuff?

PS: megalukes you may be applying the offset twice in the code you posted
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: "Questions that don't deserve their own thread" thread

Post by megalukes »

Is there a way to clip text? I wanted to print text inside a quad for a scrolling effect, but I didn't find out how.
User avatar
pgimeno
Party member
Posts: 3639
Joined: Sun Oct 18, 2015 2:58 pm

Re: "Questions that don't deserve their own thread" thread

Post by pgimeno »

See [wiki]love.graphics.setScissor[/wiki].
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: "Questions that don't deserve their own thread" thread

Post by megalukes »

pgimeno wrote:See [wiki]love.graphics.setScissor[/wiki].
Thank you so much!
slimefriend
Prole
Posts: 7
Joined: Thu Dec 01, 2016 2:45 am

Re: "Questions that don't deserve their own thread" thread

Post by slimefriend »

how do i make something in bump.lua non-collidable without removing it from the world? (or setting its width and height to 1)
User avatar
Pyuu
Prole
Posts: 22
Joined: Mon Jul 11, 2016 1:19 am

Re: "Questions that don't deserve their own thread" thread

Post by Pyuu »

Is there a way to load fonts that are Installed on the system? Distribution of some font files may require terms that prohibit usage in some ways which bothers me.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: "Questions that don't deserve their own thread" thread

Post by zorg »

Pyuu wrote:Is there a way to load fonts that are Installed on the system? Distribution of some font files may require terms that prohibit usage in some ways which bothers me.
Can be done with either manually dropping them on the project (though it'll only work at that time, not when you start up your project again, since you'll need to do it again*) or using lua's io functions, though those are os-specific, so care must be taken.

That said, if you'd wanted to do this automatically, and you intend your project for others as well, not just you, i don't think you can actually assume that the font will exist on anyone else's computers. Telling them to get font 'xyz' themselves isn't something you should bank on either. :monocle:

*:Probably can be worked around, but very hackishly.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Pyuu
Prole
Posts: 22
Joined: Mon Jul 11, 2016 1:19 am

Re: "Questions that don't deserve their own thread" thread

Post by Pyuu »

zorg wrote:-snip-
Telling them to get font 'xyz' themselves isn't something you should bank on either. :monocle:
The reason I'm curious about this is for common fonts that you can almost bet on existing on most end-user's PCs, such as Arial or Tahoma. Also, detection of those fonts existence and using reasonable alternative fonts based on OS and prepackaged fonts when they don't exist would be a good way to go about not having fonts. (It may cause the experience to differ slightly, but it still avoids the need to go about distribution licenses and potential copyright infringement when packaging the game.)
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: "Questions that don't deserve their own thread" thread

Post by megalukes »

slimefriend wrote:how do i make something in bump.lua non-collidable without removing it from the world? (or setting its width and height to 1)
Define a filter for your collision. When retuning 'cross', it'll ignore it so you can handle it differently.

Code: Select all

local playerFilter = function(item, other)
  if     other.isCoin   then return 'cross'
  elseif other.isWall   then return 'slide'
  elseif other.isExit   then return 'touch'
  elseif other.isSpring then return 'bounce'
  end
  -- else return nil
end

local goalX, goalY = player.vx * dt, player.vy * dt
local actualX, actualY, cols, len = world:move(player, goalX, goalY, playerFilter)
player.x, player.y = actualX, actualY

Locked

Who is online

Users browsing this forum: Google [Bot] and 6 guests