any ideas? thanks!
Code: Select all
function love.load()
world:add(red, red.x, red.y, red.w, red.h)
end
Code: Select all
function love.keypressed(key)
if key == 'q' then
world:remove(red)
end
end
Code: Select all
function love.load()
world:add(red, red.x, red.y, red.w, red.h)
end
Code: Select all
function love.keypressed(key)
if key == 'q' then
world:remove(red)
end
end
Code: Select all
local red = {x=120, y=300, w=30, h=50, vx=0, vy=0, jump=false}
Code: Select all
test = {x=0,y=0,w=10,h=10}
if key == "c" then
world:add(test,test.x,test.y,test.w,test.h)
end
if key == "d" then
world:remove(test)
end
Code: Select all
local test = { x = 0, y... } -- outside the function!
function love.keypressed(key)
if key == "c" then
world:add(test,test.x,test.y,test.w,test.h)
end
if key == "d" then
world:remove(test)
end
end
Code: Select all
local tirs = {liste={}}
-- TIRS --
function tirs.create(player)
local tir = {x=player.x+40, y=player.y+player.h/3, w=10, h=3}
table.insert(tirs.liste, tir)
world:add(tir,tir.x,tir.y,tir.w,tir.h)
return tir
end
function tirs.delete(tir)
local delete = false
for i = 1, len do
local col = cols[i]
if col.normal.x == -1 or col.normal.x == 1 or col.normal.y == -1 or col.normal.y == 1 then
world:remove(tir)
end
end
end
function tirs.update(dt)
for i = #tirs.liste, 1, -1 do
local tir = tirs.liste[i]
local vx = 0
vx = vx + 500*dt
tir.x, tir.y, cols, len = world:move(tir, tir.x + vx, tir.y)
tirs.delete(tir)
end
end
function tirs.draw()
for i = #tirs.liste, 1, -1 do
local tir = tirs.liste[i]
love.graphics.rectangle("line", tir.x, tir.y, tir.w, tir.h)
end
end
---
function game.keypressed(key)
if key == 'space' then
tirs.create(red)
end
end
Code: Select all
function tirs.delete(tir, cols, len)
local delete = false
for i = 1, len do
local col = cols[i]
if col.normal.x == -1 or col.normal.x == 1 or col.normal.y == -1 or col.normal.y == 1 then
world:remove(tir)
return true -- return a value on successful removal, and break the loop
end
end
end
function tirs.update(dt)
for i = #tirs.liste, 1, -1 do
local tir = tirs.liste[i]
local vx = 0
vx = vx + 500*dt
tir.x, tir.y, cols, len = world:move(tir, tir.x + vx, tir.y)
if tirs.delete(tir, cols, len) then -- check for successful removal
table.remove(tirs.liste, i ) -- remove the bullet from the list
end
end
end
Users browsing this forum: Ahrefs [Bot], Bing [Bot], danieljt and 10 guests