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

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.
Post Reply
lulztrooper
Prole
Posts: 1
Joined: Sat Sep 01, 2012 12:15 pm

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

Post 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.
Attachments
My Game.love
My Game with the Problem.
(234.37 KiB) Downloaded 130 times
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

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

Post 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
Last edited by dreadkillz on Sat Sep 01, 2012 5:57 pm, edited 1 time in total.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

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

Post 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! :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests