LÖVE 0.6.2

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: LÖVE 0.6.2

Post by Jasoco »

Ah yes. That takes me back to my days with TNT Basic and QuickBASIC when I used to do the same thing.
User avatar
smartazz
Prole
Posts: 13
Joined: Mon Jan 11, 2010 10:04 am
Contact:

Re: LÖVE 0.6.2

Post by smartazz »

rude wrote:smartazz: In LevelTileset.lua:166
Thank you rude, much appreciated :) Probably have to update the tutorials in the wiki too ;)
User avatar
devyn
Prole
Posts: 12
Joined: Tue Dec 29, 2009 5:56 am

Re: LÖVE 0.6.2

Post by devyn »

kikito wrote:Yipee!
devyn wrote: But it isn't. As you can see, the line on the right has disappeared suddenly in 0.6.2. In 0.6.1, the whole rectangle displays correctly.
Devyn, I think that what Bartbes means is that on 0.6.1 the rectangle dimensions was wrong.

Your rectangle probably "got around this" and calculated the dimensions so it looked "good". But it was not "correct".

Can you paste the code you are using?
Sorry, I was taking a break from game development for a while. Anyway, here's the full "window.lua". I'm still having issues with it.

Code: Select all

-- Working on the windows for GUI. -Timothy
-- Made Window into a class, and made it draw =D

Window = {}

function Window.new(args)

   local i = {
      position = {0, 0},
      color = {255, 255, 255, 255},
      caption = "PLACE HOLDER",
      size = {500, 500},
      draw = Window._draw,
      update = Window._update,
      mousedown = Window._mousedown,
      mouseup = Window._mouseup,
      content_draw = function (self)
		     end,
      content_update = function (self, dt)
		       end,
      content = {},
      mo = {0, 0},
      ontarget = false
   }

   if args.color then
      i.color = args.color
   end

   if args.position then
      i.position = args.position
   end

   if args.size then
      i.size = args.size
   end

   if args.caption then
      i.caption = args.caption
   end

   return i
end

function Window._dragNdrop(x, y, sizex, sizey)

   sizex = sizex + x
   sizey = sizey + y

   if love.mouse.getX() >= x and love.mouse.getX() <= sizex and
      love.mouse.getY() >= y and love.mouse.getY() <= sizey then
      --
      return true
   end
   
end

function Window:_update(dt)

   local mp = {love.mouse.getPosition()}

   if self.ontarget then
      self.position[1], self.position[2] = mp[1]+self.mo[1], mp[2]+self.mo[2]
   end

   self:content_update(dt)

end

function Window:_draw()

   self.headerSize = {self.size[1], 24}
   self.headerPosition = {self.position[1], self.position[2] - self.headerSize[2]}
   
   love.graphics.setLineWidth(2)
   love.graphics.setLineStyle('smooth')

   love.graphics.setColor(unpack(self.color))
   love.graphics.rectangle("line", self.headerPosition[1], self.headerPosition[2], self.headerSize[1], self.headerSize[2])
   love.graphics.setColor(0,0,0,255)
   love.graphics.rectangle("fill", self.headerPosition[1], self.headerPosition[2], self.headerSize[1], self.headerSize[2])
   love.graphics.setColor(unpack(self.color))
   love.graphics.rectangle("line", self.position[1], self.position[2], self.size[1], self.size[2])
   love.graphics.rectangle("fill", self.position[1], self.position[2], self.size[1], self.size[2])

   love.graphics.setColor(255,255,255,255)
   love.graphics.print(self.caption, self.headerPosition[1]+8, self.headerPosition[2]+15)

   self:content_draw()
   
end

function Window:_mousedown(x, y, button)
   if button == 'l'
         and x >= self.headerPosition[1]
         and y >= self.headerPosition[2]
         and x <= self.headerPosition[1]+self.headerSize[1]
         and y <= self.headerPosition[2]+self.headerSize[2] then
      self.mo = {self.position[1]-x, self.position[2]-y}
      self.ontarget = true
   end
end

function Window:_mouseup(x, y, button)
   if button == 'l' and self.ontarget then self.ontarget = false end
end
Edit: and now I see my problem. LOL. Thanks, I guess I just needed to look at it again.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests