Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. function editor:selection()
  2.     -- hilights the entity when mouseover
  3.     editor.selname = "null"
  4.  
  5.     for i, type in pairs(world.entities) do
  6.         print (type.group)
  7.         for _,e in ipairs(type) do
  8.             --deselect all before continuing
  9.             --(fixes texture change issue with platforms)
  10.             e.selected = false
  11.         end
  12.        
  13.         --reverse loop
  14.         for _,e in ripairs(type) do
  15.             if world:inview(e) then
  16.                 editor.selname = e.group .. "("..i..")"
  17.                 if e.movex == 1 then
  18.                     --collision area for moving entity
  19.                     if collision:check(self.mouse.x,self.mouse.y,1,1,e.xorigin, e.y, e.movedist+e.w, e.h) then
  20.                         love.graphics.rectangle("line", e.xorigin, e.y, e.movedist+e.w, e.h)
  21.                         e.selected = true
  22.                         return true
  23.                     end
  24.                 elseif e.movey == 1 then
  25.                     --collision area for moving entity
  26.                     if collision:check(self.mouse.x,self.mouse.y,1,1,e.xorigin, e.yorigin, e.w, e.h+e.movedist) then
  27.                         love.graphics.rectangle("line", e.xorigin, e.yorigin,e.w, e.h+e.movedist)
  28.                         e.selected = true
  29.                         return true
  30.                     end
  31.                 elseif e.swing == 1 then
  32.                     --collision area for swinging entity
  33.                     if collision:check(self.mouse.x,self.mouse.y,1,1,
  34.                             e.xorigin-platform_link_origin:getWidth()/2, e.yorigin-platform_link_origin:getHeight()/2,  
  35.                             platform_link_origin:getWidth(),platform_link_origin:getHeight()) then
  36.                        
  37.                             love.graphics.rectangle("line",
  38.                                 e.xorigin-platform_link_origin:getWidth()/2, e.yorigin-platform_link_origin:getHeight()/2,  
  39.                                 platform_link_origin:getWidth(),platform_link_origin:getHeight()
  40.                             )
  41.                             e.selected = true
  42.                             return true
  43.                     end
  44.                 elseif collision:check(self.mouse.x,self.mouse.y,1,1,e.x,e.y,e.w,e.h) then
  45.                     --collision area for static entities
  46.                         love.graphics.rectangle("line", e.x,e.y,e.w,e.h)
  47.                         e.selected = true
  48.                         self.texturesel = e.texture or 1
  49.                         return true
  50.                 end
  51.             end
  52.         end
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement