Image load? [SOLVED]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Image load? [SOLVED]
Hey there! I have a problem with an image file. My code is still at the beginning:
function love.load()
player = love.graphics.newImage"Player.png"
player = {}
player.x = 70
player.y = 70
end
function love.draw()
love.graphics.draw(player)
end
the compiler says: "could not find love.image!" Why that? Is the png file format not supported? Or do i do something wrong?
function love.load()
player = love.graphics.newImage"Player.png"
player = {}
player.x = 70
player.y = 70
end
function love.draw()
love.graphics.draw(player)
end
the compiler says: "could not find love.image!" Why that? Is the png file format not supported? Or do i do something wrong?
Last edited by Todespreis on Mon Jun 19, 2023 10:11 am, edited 1 time in total.
Re: Image load?
you are overwriting
variable by assigning empty table to it.
PS: Also use the full editor to format your code rather than the mess you provided.
Code: Select all
player
PS: Also use the full editor to format your code rather than the mess you provided.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Image load?
Todespreis wrote: ↑Thu Jun 15, 2023 8:56 pm Hey there! I have a problem with an image file. My code is still at the beginning:
function love.load()
player = love.graphics.newImage"Player.png"
player = {}
player.x = 70
player.y = 70
end
function love.draw()
love.graphics.draw(player)
end
the compiler says: "could not find love.image!" Why that? Is the png file format not supported? Or do i do something wrong?
Code: Select all
function love.load()
player = {}
player.x = 70
player.y = 70
player.image = love.graphics.newImage ("player.png") -- be sure that the file is near the main.lua
end
function love.draw()
love.graphics.draw(player.image, player.x, player.y)
end
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Re: Image load?
Hey there! Thank you for the fast reply, so i tried it out and this is, what worked at the end:
I tried to implement the image in different ways - with brackets and without, within the same directory as main or in a Folder "Assets/Graphics". Nothing worked, but then i saw, that the image implementation was "false" in the config file O.O" I'm sorry L(^ - ^)I
Code: Select all
local player
function love.load()
player = {}
player.x = 70
player.y = 70
player = love.graphics.newImage( "Player.png" )
end
Down={}
function love.joystickpressed( joystick, button )
Down[button]=true
end
function love.joystickreleased( joystick, button )
Down[button]=nil
end
love.update=function (dt)
if Down[06] then
player.x = player.x + 1
end
if Down[04] then
player.y = player.y + 1
end
if Down[02] then
player.x = player.x - 1
end
if Down[00] then
player.y = player.y - 1
end
end
function love.draw()
love.graphics.draw( player, player.x, player.y )
end
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Re: Image load?
I still have 2 questions to it - is it necessary to implement the vector(?)
before
?
Does it have any differences?
And @dusoft can you recommend any? I have the problem, that i'm trying to write the code for an old device named GP2X. @SCIENCE, a user here on the forum ported it backdays on Caanoo and another player ported it on my device. The version of the Love2d is 0.7, i think. So i can't use such things like visual studio code, where the Love2d core is just not compatible due to its version
Code: Select all
player = { }
Code: Select all
player = love.graphics.newImage
Does it have any differences?
And @dusoft can you recommend any? I have the problem, that i'm trying to write the code for an old device named GP2X. @SCIENCE, a user here on the forum ported it backdays on Caanoo and another player ported it on my device. The version of the Love2d is 0.7, i think. So i can't use such things like visual studio code, where the Love2d core is just not compatible due to its version
Re: Image load?
Wrong:Todespreis wrote: ↑Fri Jun 16, 2023 12:18 pm
I tried to implement the image in different ways - with brackets and without, within the same directory as main or in a Folder "Assets/Graphics". Nothing worked, but then i saw, that the image implementation was "false" in the config file O.O" I'm sorry L(^ - ^)I
Code: Select all
player = love.graphics.newImage ("player.png")
Code: Select all
player.image = love.graphics.newImage ("player.png")
Code: Select all
player = {
x = 70,
y = 70,
image = love.graphics.newImage ("player.png"),
}
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Re: Image load?
But it worked. And like i said, my version of Love2d is 12 years old
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Re: Image load?
And thanks for replying :-)
Re: Image load?
Yes, it worked, but on this assignment you loose your x and y variables.Todespreis wrote: ↑Fri Jun 16, 2023 1:18 pm But it worked. And like i said, my version of Love2d is 12 years old
-
- Prole
- Posts: 40
- Joined: Sat Apr 01, 2023 9:30 pm
Re: Image load?
If i change player to player.image, the compiler says: "Incorrect parameter type: expected userdata." in love.graphics.draw.
Sorry, it's just as hard as learning a new language - i have to look up every single word, function and character
Sorry, it's just as hard as learning a new language - i have to look up every single word, function and character
Who is online
Users browsing this forum: Amazon [Bot] and 4 guests