Page 1 of 1

[NOOB] My image won't appear [NOOB]

Posted: Sat Sep 01, 2012 12:22 pm
by lulztrooper
Sorry, I'm a bit of a noob at this, so can someone tell me what's going on? My .love is attached,
please notify me if it isn't a noob problem, thanks for reading.

Re: [NOOB] My image won't appear [NOOB]

Posted: Sat Sep 01, 2012 5:33 pm
by dreadkillz
That's because you have to tell LOVE how to draw the image after loading it. Santos is right. I need sleep...

Take a look at this first: https://love2d.org/wiki/Tutorial:Hamster_Ball
You should probably spend some time in here too before asking: https://love2d.org/wiki/Category:Tutorials

Re: [NOOB] My image won't appear [NOOB]

Posted: Sat Sep 01, 2012 5:49 pm
by Santos
The first argument to love.graphics.draw is the actual image variable, not a string, so:
love.graphics.draw("player_1_img", player_X, player_Y, player_angle)
should be
love.graphics.draw(player_1_img, player_X, player_Y, player_angle)

I think in this case the love.draw in main.lua is actually being "overwritten" by the love.draw in player.lua. Replacing the functions in main.lua with the ones in player.lua should make things work.

If you want to divide your code up into separate files, each file can have it's own loading and updating and drawing functions, but instead of calling them love.load/love.update/love.draw, you can call them something else and then call them from the love.load/love.update/love.draw functions in main.lua.

So, you could rename the functions in player.lua to something like player_load, player_update, and player_draw, and then have main.lua look like this:

Code: Select all

require "player"

function love.load()
	player_load()
end

function love.update()
	player_update()
end

function love.draw()
	player_draw()
end
Something you might notice is the player doesn't seem to move. That's because player_X = player_X - dt in will move the player left 1 pixel in 1 second. You'll probably want to have a variable for the player speed too, and multiply dt by this speed variable.

I hope this helps! :)