Using sprites from a tileset

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using sprites from a tileset

Post by Robin »

Evrim wrote:Thanks Robin for explaining that, will that dot trick work on images too because I started adding loads of sprites and the folder is getting filled by images
No, that is just to remain compatible with modules. For images, you need to give the full relative path.
Evrim wrote:and a new problem, I found a tricky way for making a main - by re-moving (not remove) the images, I took them to very far away off the screen and screen gets cleared
You can also just not draw them.
Evrim wrote:But after I press S, screen clears supposedly but after I press Q, it quits the game even I set onMainMenu to false in S
That's because you set onMainMenu to true every time a key is pressed. You need to keep track of the state and use that.
Help us help you: attach a .love.
Evrim
Prole
Posts: 20
Joined: Fri Apr 01, 2011 4:22 pm

Re: Using sprites from a tileset

Post by Evrim »

Robin wrote:
Evrim wrote:Thanks Robin for explaining that, will that dot trick work on images too because I started adding loads of sprites and the folder is getting filled by images
No, that is just to remain compatible with modules. For images, you need to give the full relative path.
Example?
Robin wrote:
Evrim wrote:and a new problem, I found a tricky way for making a main - by re-moving (not remove) the images, I took them to very far away off the screen and screen gets cleared
You can also just not draw them.
How not draw them?
Robin wrote:
Evrim wrote:But after I press S, screen clears supposedly but after I press Q, it quits the game even I set onMainMenu to false in S
That's because you set onMainMenu to true every time a key is pressed. You need to keep track of the state and use that.
Okay
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using sprites from a tileset

Post by Robin »

Evrim wrote:
Robin wrote:No, that is just to remain compatible with modules. For images, you need to give the full relative path.
Example?
If you have an image of a tree in "images/tree.png", use:

Code: Select all

love.graphics.newImage("images/tree.png")
Evrim wrote:
Robin wrote:You can also just not draw them.
How not draw them?

Code: Select all

function love.draw()
    if state == 'menu' then -- or however you keep track of state
        -- draw menu things
    else
        -- draw game things
    end
end
Help us help you: attach a .love.
Evrim
Prole
Posts: 20
Joined: Fri Apr 01, 2011 4:22 pm

Re: Using sprites from a tileset

Post by Evrim »

In case state changes, will draw entities will disappear?

EDIT: Yes they do, thanks for the help again
Last edited by Evrim on Sun Apr 03, 2011 8:49 am, edited 1 time in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using sprites from a tileset

Post by Robin »

Evrim wrote:In case state changes, will draw entities will disappear?
Jup.

LÖVE doesn't have entities, actually. All love.graphics.draw does is copy the pixels from the image to the screen, and the screen is cleared between frames. (Actually there is more to it than that, but I think this explains it well enough.)
Help us help you: attach a .love.
Evrim
Prole
Posts: 20
Joined: Fri Apr 01, 2011 4:22 pm

Re: Using sprites from a tileset

Post by Evrim »

Now, I included another lua file for movement but it 'expects' user data

draw

Code: Select all

love.graphics.drawq(dwarves, char, x1, y1)
load

Code: Select all

char = love.graphics.newQuad(0, 0, 24, 24, 360, 24)
dwarves = love.graphics.newImage("dwarves.png")
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using sprites from a tileset

Post by Robin »

Could you make a .love of your game so we can take a look at it? We need more information to be able to help you.
Help us help you: attach a .love.
Evrim
Prole
Posts: 20
Joined: Fri Apr 01, 2011 4:22 pm

Re: Using sprites from a tileset

Post by Evrim »

http://ul.to/wphqziif

Hoping that I uploaded correctly
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Using sprites from a tileset

Post by Robin »

  1. Please upload .loves as attachments next time, it's easier for all of us.
  2. Ditch onMainMenu. You already have state.
  3. You need to require movement.lua if you want LÖVE to use it.
Help us help you: attach a .love.
Evrim
Prole
Posts: 20
Joined: Fri Apr 01, 2011 4:22 pm

Re: Using sprites from a tileset

Post by Evrim »

I was to say that problem was caused after I require movement


EDIT: Fixed it, I just took newImage and newQuad to love.draw...
Attachments
Underound.love
(44.29 KiB) Downloaded 55 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests