main.lua
Code: Select all
require ("character.lua")--Not needed, it's currently empty
require ("platformPhysics.lua")
function love.load()
char = love.graphics.newImage("character.png")
end
AddObject(char,300,300,0,"No Status","Character")
function love.draw()
count=0
for i, v in pairs(objects) do
love.graphics.draw(v.object,v.x,v.y)--THIS IS THE ERROR. it won't accept v.object, I get the error:
--Incorrect parameter type: expected userdata
end
end
function love.update()
PlatformGravityHandler()
end
Code: Select all
platforms = {}--Stationary platforms that are bound to a spot unless moved by editing the x/y values (will auto update)
objects = {}--Objects that are unbound and will move as affected by gravity
--PLEASE NOTE: WHEN ADDING PLATFORMS THE CHARACTER COLLIDES WITH THE TOP OF THE IMAGE, MAKE DRAWING TOUCH THE TOP OF IMAGE
--[[
--I've set this up for when it's done and I redistribute it
xval = x position of object
yval = y position of object
gravForce = the object gravity, make 0 for floating. Gravity is in 'pixel/ms. Make negative for floating.
Gravity Notice: As of V0.1, gravity does not change speed when falling, it will fall at a constant pace.
status = apply a string to it, use for whatever, to check stuff, good as a property.
name = apply a name to it, should you want to find it later!
sx = size x(in pixels) --THIS DOES NOT SET SIZE-IT IS A REFFERENCE FOR CALCULATIONS
sy = size y(in pixels) --THIS DOES NOT SET SIZE-IT IS A REFFERENCE FOR CALCULATIONS
Note: Rotated platforms won't be accepted.
Note: Changing a property of a platform inside the table will affect it, automatically.
]]
function AddPlatform(platform,xval,yval,status,name)
local ptable = {}
local x = xval
local y = yval
local stats = status
local pname = name
table.insert(ptable,x,"x")
table.insert(ptable,y,"y")
table.insert(ptable,stats,"status")
table.insert(ptable,pname,"name")
table.insert(ptable,platform,"platform")
table.insert(platforms,ptable)
end
function AddObject(object,xval,yval,sx,sy,gravForce,status,name)
local ptable = {object = object,x = xval,y = yval}
table.insert(objects,ptable)
end
function PlatformGravityHandler()
--This function isn't done, it just adds to the x value as a test. No errors here.
for i, v in pairs(objects) do
v.x = v.x + 1
end
end