Help with making .love file
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Tue Aug 11, 2009 10:49 pm
Help with making .love file
Hello just found out about this engine and am excited to use it! Anyways I was going through the first tutorial and am having trouble with making a .love file work. Whenever I drag and drop onto the love icon I get the outlines for a new window and then nothing. I do not understand where the graphics go as well. Thank you in advance.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Help with making .love file
A .love file is actually a .zip file, which contains main.lua, other lua files, game.conf and your images etc. The beautiful thing about LÖVE is you can use folders as .love files as well.
See http://love2d.org/forum/viewtopic.php?f=4&t=451 for more details.
See http://love2d.org/forum/viewtopic.php?f=4&t=451 for more details.
Help us help you: attach a .love.
-
- Prole
- Posts: 5
- Joined: Tue Aug 11, 2009 10:49 pm
Re: Help with making .love file
Have another question will just keep it in this thread so as to avoid clutter. I just made two .gifs for directions in which the person is facing based on left or right. Now does anyone have any idea on how to make it so that pressing left would remove the right facing picture and put in the left facing picture and vice versa? Sorry, am very new, thanks in advance.
Re: Help with making .love file
There is no need to remove the old picture, every time Löve runs your code, it erases the picture currently drawn on the screen. So when you write...
love.graphics.draw( mypic, 0, 0 )
in your draw() function, all it really is doing is drawing the mypic many times a second, so it looks like one continuous picture.
In order to change what picture is drawn to the screen you need to check what is happening with the keyboard. The Löve documentation has a great call back for the keyboard, see it here.
http://love2d.org/docs/keypressed.html
Check for whether or not the left or right arrow key is pressed in the update(dt) function and change a variable to show this change. An example would be if the left arrow key is pressed...
function keypressed(key)
if key == love.key_left then
lastkey = "left"
end
end
Then check in the draw() function what the last key was and draw accordingly..
if lastkey == "left" then
love.graphics.draw( mypicleft, 0, 0 )
end
I'll leave how to figure out the right key up to you but it's pretty straightforward.
Have fun!
love.graphics.draw( mypic, 0, 0 )
in your draw() function, all it really is doing is drawing the mypic many times a second, so it looks like one continuous picture.
In order to change what picture is drawn to the screen you need to check what is happening with the keyboard. The Löve documentation has a great call back for the keyboard, see it here.
http://love2d.org/docs/keypressed.html
Check for whether or not the left or right arrow key is pressed in the update(dt) function and change a variable to show this change. An example would be if the left arrow key is pressed...
function keypressed(key)
if key == love.key_left then
lastkey = "left"
end
end
Then check in the draw() function what the last key was and draw accordingly..
if lastkey == "left" then
love.graphics.draw( mypicleft, 0, 0 )
end
I'll leave how to figure out the right key up to you but it's pretty straightforward.
Have fun!
"Here's another curse for you, may all your bacon burn."
-
- Prole
- Posts: 5
- Joined: Tue Aug 11, 2009 10:49 pm
Re: Help with making .love file
Thx man will check into that, I'm looking in from a graphics perspective and have never done coding before so it takes me a little bit
-
- Prole
- Posts: 5
- Joined: Tue Aug 11, 2009 10:49 pm
Re: Help with making .love file
I guess my question is how to have two images loaded into it, but only have one come out when a key pressed. Sorry I am really struggling with this.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Help with making .love file
Here are two ways to do it.
This changes the horizontal scale from 1 to -1. If you turn the image into an animation it actually flips it about the center.
This loads two separate images for left and right.
This changes the horizontal scale from 1 to -1. If you turn the image into an animation it actually flips it about the center.
Code: Select all
function load()
megaman=love.graphics.newImage("mmstand.png")
x=200
dir=1
end
function update(dt)
if love.keyboard.isDown(love.key_right) then
x=x+100*dt
dir=-1
elseif love.keyboard.isDown(love.key_left) then
x=x-100*dt
dir=1
end
end
function draw()
love.graphics.draw(megaman,x,100,0,dir,1)
end
Code: Select all
function load()
megamanl=love.graphics.newImage("mmstandl.png")
megamanr=love.graphics.newImage("mmstandr.png")
megamandir=megamanl
x=200
end
function update(dt)
if love.keyboard.isDown(love.key_right) then
x=x+100*dt
megamandir=megamanr
elseif love.keyboard.isDown(love.key_left) then
x=x-100*dt
megamandir=megamanl
end
end
function draw()
love.graphics.draw(megamandir,x,100)
end
- Attachments
-
- leftright_2.love
- This has two separate images for left and right.
- (4.61 KiB) Downloaded 165 times
-
- leftright.love
- This changes the image horizontal scale.
- (3.84 KiB) Downloaded 156 times
-
- Prole
- Posts: 5
- Joined: Tue Aug 11, 2009 10:49 pm
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests