im currently working on my first game, and i have a way to brute force a functionality thats good enough for this project, but with significantly more lines of code than id likely need if i could figure out how to call an array.
Counter = 0
function love.load ()
require "enemy"
enemy = Enemy()
enemy2 = Enemy()
enemy3 = Enemy()
enemy4 = Enemy()
--[[ect...
function love.update(dt)
Counter = Counter + dt
if counter >= 0 then
enemy:update(dt)
end
if Counter >= 3 then
enemy2:update(dt)
end
if Counter >= 6 then
enemy3:update(dt)
end
if Counter >= 8.6 then
enemy4:update(dt)
end
--[[ ect...
and than doing the same thing in love. draw() with the same numbers but draw instead of update.
i know how to set up an array to draw something every time a key is pressed, but im not sure how to call it once my counter variable reaches certain numbers
additionally, how would i increase the required counter number each time the array draws a new object?
viviavi wrote: ↑Sat Oct 28, 2023 2:49 am
im currently working on my first game, and i have a way to brute force a functionality thats good enough for this project, but with significantly more lines of code than id likely need if i could figure out how to call an array.
Counter = 0
function love.load ()
require "enemy"
enemy = Enemy()
enemy2 = Enemy()
enemy3 = Enemy()
enemy4 = Enemy()
--[[ect...
function love.update(dt)
Counter = Counter + dt
if counter >= 0 then
enemy:update(dt)
end
if Counter >= 3 then
enemy2:update(dt)
end
if Counter >= 6 then
enemy3:update(dt)
end
if Counter >= 8.6 then
enemy4:update(dt)
end
--[[ ect...
and than doing the same thing in love. draw() with the same numbers but draw instead of update.
i know how to set up an array to draw something every time a key is pressed, but im not sure how to call it once my counter variable reaches certain numbers
additionally, how would i increase the required counter number each time the array draws a new object?
Welcome to the forums!
Do what you need inside the objects:
I mean what's difficult about arrays? They work similarly in each language (that has them). In Lua it's even easier, because Lua has tables. And tables can be anything you need, objects, arrays, you choose.