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.
[NOOB] My image won't appear [NOOB]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 1
- Joined: Sat Sep 01, 2012 12:15 pm
[NOOB] My image won't appear [NOOB]
- Attachments
-
- My Game.love
- My Game with the Problem.
- (234.37 KiB) Downloaded 130 times
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: [NOOB] My image won't appear [NOOB]
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.
Re: [NOOB] My image won't appear [NOOB]
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:
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!
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
I hope this helps!
Who is online
Users browsing this forum: No registered users and 7 guests