Need help with drawing an image!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Happy5354
Prole
Posts: 6
Joined: Thu Jan 22, 2015 3:32 am

Need help with drawing an image!

Post by Happy5354 »

Hello... I'm trying to draw a simple image, I read the filesystem page on the wiki and trying to open an image and draw it but apparently, I can't...

Here's my code to open and draw the image:

Code: Select all

function love.load()
	picture = love.graphics.newImage("bg.jpg")
end

function love.update( dt )
end

function love.draw()
	love.graphics.draw(picture, 200, 200)
end
In my root folder(where the .love is located) there is:
  • main.lua
    conf.lua
    bg.jpg
    main.zip
    run.bat

PS: the "run.bat" file is only renaming the "main.zip" file into "main.love" and then I run it

Thanks for your time!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Need help with drawing an image!

Post by Robin »

Could you upload the .love?
Help us help you: attach a .love.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Need help with drawing an image!

Post by s-ol »

Happy5354 wrote:Hello... I'm trying to draw a simple image, I read the filesystem page on the wiki and trying to open an image and draw it but apparently, I can't...
1.) What happens?
2.) Upload your .love

3.) How did you try to run it?

the first two should always be covered when asking for help, we absolutely cannot help if you don't tell us what exactly is happening.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Happy5354
Prole
Posts: 6
Joined: Thu Jan 22, 2015 3:32 am

Re: Need help with drawing an image!

Post by Happy5354 »

When I rename the .zip into .love and run it, I get: ' main.lua:2: Could not open file bg.png. Cannot read file '

PS: I tried it at school, and it works, and uploaded it on mega and opened it at home, worked too... But I still want to know why.

By the way I attached my .love file
Attachments
DRAW.love
(818.28 KiB) Downloaded 119 times
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Need help with drawing an image!

Post by Positive07 »

You posted this:

Code: Select all

picture = love.graphics.newImage("bg.jpg")
Which does work...

But in your .love file you do this:

Code: Select all

picture = love.graphics.newImage(".\bg.jpg")
Which does not work...
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Happy5354
Prole
Posts: 6
Joined: Thu Jan 22, 2015 3:32 am

Re: Need help with drawing an image!

Post by Happy5354 »

Yeah, I checked on Google, and I guy wrote this, I forgot to remove it...
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests