why is my code not working? (i am following sheepolution tutorial on how to make a game)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ender
Prole
Posts: 4
Joined: Fri Feb 02, 2024 10:27 am

why is my code not working? (i am following sheepolution tutorial on how to make a game)

Post by ender »

function Player:keyPressed(key)

if key == "space" then
--to test\/
print("player.x, player.y", self.x, self.y)
--to test/\
table.insert(listOfBullets, Bullet(self.x, self.y))
--also to test \/
for i,v in ipairs(listOfBullets) do
--v:update(dt)
print (i,v.x, v.y)
end
end
end

and if this helps:

function love.update(dt)
player:update(dt)
enemy:update(dt)

for i,v in ipairs(listOfBullets) do
--the thing causing the error
--\/
--v:update(dt)
end
end
ender
Prole
Posts: 4
Joined: Fri Feb 02, 2024 10:27 am

Re: why is my code not working? (i am following sheepolution tutorial on how to make a game)

Post by ender »

player.x, player.y nil nil
1 nil nil
when i press space/\
vilonis
Prole
Posts: 12
Joined: Sun Jan 14, 2024 10:52 pm

Re: why is my code not working? (i am following sheepolution tutorial on how to make a game)

Post by vilonis »

Is this all of the code? If not then you need to provide everything you’ve written. Right now I don’t see self.x and self.y being set anywhere.

Also, for context, what, if any, programming background do you have?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests