Commits

josefnpat committed 8b47a94

Cleanup

  • Participants
  • Parent commits 7003ad9

Comments (0)

Files changed (2)

File denom/entitylib/entitylib.lua

   for i,v in ipairs(entitylib.data) do
     local route = entitylib.routetoplayer(v)
     if route == "direct" then
-      v:run(dt,player.x-maplib.tx,player.y-maplib.ty)
+      v:run(dt,playerlib.x-maplib.tx,playerlib.y-maplib.ty)
     elseif route == "arc1" then
-      v:run(dt,player.x-maplib.tx,v.y)
+      v:run(dt,playerlib.x-maplib.tx,v.y)
     elseif route == "arc2" then
-      v:run(dt,v.x,player.y-maplib.ty)
+      v:run(dt,v.x,playerlib.y-maplib.ty)
     end
   end
 end
 
 function entitylib.routetoplayer(v)
-  if entitylib.dist(player.x-maplib.tx,player.y-maplib.ty,v.x,v.y) < v.range then
-    local x1,y1,x2,y2 = player.x,player.y,v.x+maplib.tx,v.y+maplib.ty
-    if entitylib.checkpath(v.range,player.x,player.y,v.x+maplib.tx,v.y+maplib.ty) then -- Direct
+  if entitylib.dist(playerlib.x-maplib.tx,playerlib.y-maplib.ty,v.x,v.y) < v.range then
+    local x1,y1,x2,y2 = playerlib.x,playerlib.y,v.x+maplib.tx,v.y+maplib.ty
+    if entitylib.checkpath(v.range,playerlib.x,playerlib.y,v.x+maplib.tx,v.y+maplib.ty) then -- Direct
       return "direct"
     elseif entitylib.checkpath(v.range,x1,y2,x2,y2) and entitylib.checkpath(v.range,x1,y1,x1,y2) then -- First Arc
       return "arc1"

File denom/magiclib/magiclib.lua

 
 function magiclib.load()
   magiclib.bolt = love.graphics.newImage("magiclib/firebolt.png")
-  boltSpeed = 300
-  bolts = {}
-  player = {x = playerlib.x, y = playerlib.y, width = 32, height = 32}
+  magiclib.boltSpeed = 300
+  magiclib.bolts = {}
   magiclib.bolt_cost = 5
 end
 
 function magiclib.draw()
-  for i,v in ipairs(bolts) do
+  for i,v in ipairs(magiclib.bolts) do
     love.graphics.draw(magiclib.bolt, v.x+maplib.tx, v.y+maplib.ty)
   end
 end
 
 function magiclib.update(dt)
-  for i,v in ipairs(bolts) do
+  for i,v in ipairs(magiclib.bolts) do
     v.x = v.x + (v.dx * dt)
     v.y = v.y + (v.dy * dt)
   end
 function magiclib.mousepressed(x, y, button)
     if button == "l" then
       if guilib.mana >= magiclib.bolt_cost then
-				local startX = -maplib.tx + player.x
-        local startY = -maplib.ty + player.y
+				local startX = -maplib.tx + playerlib.x
+        local startY = -maplib.ty + playerlib.y
         local mouseX = -maplib.tx + x
         local mouseY = -maplib.ty + y
        
         local angle = math.atan2((mouseY - startY), (mouseX - startX))
        
-        local bulletDx = boltSpeed * math.cos(angle)
-        local bulletDy = boltSpeed * math.sin(angle)
+        local bulletDx = magiclib.boltSpeed * math.cos(angle)
+        local bulletDy = magiclib.boltSpeed * math.sin(angle)
        	
-        table.insert(bolts, {x = startX, y = startY, dx = bulletDx, dy = bulletDy})
+        table.insert(magiclib.bolts, {x = startX, y = startY, dx = bulletDx, dy = bulletDy})
 			  guilib.mana = guilib.mana - magiclib.bolt_cost
 			end
     end