Page 84 of 91

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

Posted: Fri Dec 02, 2016 7:29 pm
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

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

Posted: Fri Dec 02, 2016 8:31 pm
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

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

Posted: Mon Dec 05, 2016 5:17 pm
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.

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

Posted: Mon Dec 05, 2016 6:11 pm
by pgimeno
See [wiki]love.graphics.setScissor[/wiki].

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

Posted: Mon Dec 05, 2016 6:20 pm
by megalukes
pgimeno wrote:See [wiki]love.graphics.setScissor[/wiki].
Thank you so much!

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

Posted: Tue Dec 06, 2016 12:14 am
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)

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

Posted: Tue Dec 06, 2016 1:17 am
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.

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

Posted: Tue Dec 06, 2016 1:42 am
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.

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

Posted: Tue Dec 06, 2016 1:46 am
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.)

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

Posted: Tue Dec 06, 2016 4:06 pm
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