Advertisement
Razvii

Simple oop problem

Aug 13th, 2021
1,307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. entities = {}
  2.  
  3. function entities:create(x,y,w,h,c)
  4.   entity = {}
  5.   entity.x = x or 0
  6.   entity.y = y or 0
  7.   entity.width = w or 1
  8.   entity.height = h or 1
  9.   entity = world:newRectangleCollider(entity.x,entity.y,entity.width,entity.height)
  10.   if c then
  11.     entity:setCollisionClass(c)
  12.   else
  13.     entity:setCollisionClass("wall")
  14.   end
  15.  
  16.  
  17.  entity.draw = function(self,path)
  18.   local sprite = love.graphics.newImage("assets/images/pipe.png")
  19.   love.graphics.draw(sprite,self.x,self.y)
  20. end
  21.  
  22.   return entity
  23. end
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement