so i was experimenting with accessing script from another lua file and i got a weird result
this is just a ball with physics..
(snake.lua)
Code: Select all
function snake_load()
snake = {}
snake.body = love.physics.newBody(world, 375, 275, "dynamic")
snake.shape = love.physics.newCircleShape(0, 0, 20)
snake.fixture = love.physics.newFixture(snake.body, snake.shape, 1)
snake.fixture:setRestitution(1)
snake.body:setGravityScale(1)
table.insert(Nsnake, snake)
end
Code: Select all
require 'snake'
function love.load()
love.physics.setMeter(64)
world = love.physics.newWorld(0, 9.8 * 64, true)
Nsnake = {}
end
function love.update()
if love.keyboard.isDown("space") then
snake_load()
end
end
function love.draw()
for i,v in pairs(Nsnake) do
love.graphics.setColor(255,255,0)
love.graphics.circle("fill", v.body:getX(), v.body:getY(), 20)
end
end