瀏覽代碼

Add TeamWall;

bjorn 11 年之前
父節點
當前提交
680b8f1e44
共有 3 個文件被更改,包括 57 次插入0 次删除
  1. 32 0
      data/maps/industria/props.lua
  2. 19 0
      data/prop/teamwall.lua
  3. 6 0
      lib/player.lua

+ 32 - 0
data/maps/industria/props.lua

@@ -711,4 +711,36 @@ return {
     height = 64,
     z = 64
   },
+  {
+    kind = 'teamwall',
+    x = 864,
+    y = 2720,
+    width = 64,
+    height = 128,
+    team = 1
+  },
+  {
+    kind = 'teamwall',
+    x = 1184,
+    y = 2720,
+    width = 64,
+    height = 128,
+    team = 1
+  },
+  {
+    kind = 'teamwall',
+    x = 1184,
+    y = 480,
+    width = 64,
+    height = 128,
+    team = 0
+  },
+  {
+    kind = 'teamwall',
+    x = 1504,
+    y = 480,
+    width = 64,
+    height = 128,
+    team = 0
+  }
 }

+ 19 - 0
data/prop/teamwall.lua

@@ -0,0 +1,19 @@
+local TeamWall = {}
+TeamWall.name = 'TeamWall'
+TeamWall.code = 'teamwall'
+
+TeamWall.collision = {}
+TeamWall.collision.shape = 'rectangle'
+TeamWall.collision.static = true
+TeamWall.collision.tag = 'teamwall'
+
+function TeamWall:activate()
+  ctx.event:emit('collision.attach', {object = self})
+end
+
+function TeamWall:draw()
+  love.graphics.setColor(255, 0, 0)
+  love.graphics.rectangle('fill', self.x, self.y, self.x + self.width, self.y + self.height)
+end
+
+return TeamWall

+ 6 - 0
lib/player.lua

@@ -9,6 +9,12 @@ Player.collision = {
       self.x, self.y = self.x + dx, self.y + dy
       self.shape:moveTo(self.x, self.y)
     end,
+    teamwall = function(self, other, dx, dy)
+      if other.team ~= self.team then
+        self.x, self.y = self.x + dx, self.y + dy
+        self.shape:moveTo(self.x, self.y)
+      end
+    end,
     player = function(self, other, dx, dy)
       if other.team ~= self.team then
         dx, dy = dx / 2, dy / 2