]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Added npc
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 9 May 2020 13:06:32 +0000 (09:06 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 9 May 2020 13:06:32 +0000 (09:06 -0400)
Scripts/init.lua

index ec9e35071460ba81a74c5432e03c9289711387f8..dc5093bb93e515b2853ca8e452af7e97fe1f60d2 100644 (file)
@@ -82,11 +82,44 @@ ball = {
     end,
 }
 
+npc = {
+    Position = {
+        x = 30,
+        y = 75
+    },
+    Velocity = {
+        x = 0.0,
+        y = 0.0
+    },
+    Physics = 0,
+    Name = "Paul",
+    Render = {
+        texture = "Assets/cat.png",
+        visible = true
+    },
+    Light = {
+        r = 1.0,
+        g = 1.0,
+        b = 1.0,
+        strength = 0.5
+    },
+    Idle = function(self)
+               if (self.visibleTick == 0) then
+                       self.visibleTick = math.random(40, 60)
+                       self.Velocity.x = math.random(-1, 1) * 1.0
+        else
+            self.visibleTick = self.visibleTick - 1
+        end
+    end,
+    visibleTick = 0
+}
+
 -- Create the world
 dofile("Scripts/world.lua")
 
 playerSpawn = game.spawn(player);
 game.spawn(ball);
+game.spawn(npc);
 
 -------------------
 --  SERIALIZING  --