Fixing An Incorrectly Coded Drawing Function

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.
Rehnrald
Prole
Posts: 29
Joined: Fri Jul 19, 2013 6:11 am

Fixing An Incorrectly Coded Drawing Function

Post by Rehnrald »

This is my first post, sadly it must be one asking for help.... Anyway, my problem is that clicking the "New Game" button on the menu causes a problem with loading the background. I don't see a problem, as I defined the background correctly (background = love.graphics.newImage("<filename.extension>"), and called it correctly (to my knowledge) with:

function love.draw()
love.graphics.draw(background)
love.graphics.draw(Llama, x, y)
end
end

I would appreciate help, thanks in advance.
Attachments
TestMenu.love
Here is the .LOVE file.
(8.22 MiB) Downloaded 236 times
User avatar
Innocuous
Prole
Posts: 13
Joined: Thu Jul 11, 2013 12:09 pm

Re: Fixing An Incorrectly Coded Drawing Function

Post by Innocuous »

Hello and welcome! I very new myself but I took the liberty to look through your code. There is no problem with your draw function but it appears to break when your on-click event leads to the function TITLE.newGame(button) which is already running. Maybe if you change the on-click, you will fix the issues.
Rehnrald
Prole
Posts: 29
Joined: Fri Jul 19, 2013 6:11 am

Re: Fixing An Incorrectly Coded Drawing Function

Post by Rehnrald »

I couldn't exactly grasp what you were trying to say, but I moved the TITLE.newGame block to below the block that defines it as a variable. I also changed some variables and such, but doing that made it so the song plays, but the background and player character aren't drawn at all. It just stays at the main menu whilst playing the audio.
User avatar
Innocuous
Prole
Posts: 13
Joined: Thu Jul 11, 2013 12:09 pm

Re: Fixing An Incorrectly Coded Drawing Function

Post by Innocuous »

Could you post the current state of the project? Would like to have another look at it for you.
Rehnrald
Prole
Posts: 29
Joined: Fri Jul 19, 2013 6:11 am

Re: Fixing An Incorrectly Coded Drawing Function

Post by Rehnrald »

Sure, here it is:
Attachments
TestMenu2.love
(7.79 MiB) Downloaded 252 times
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Fixing An Incorrectly Coded Drawing Function

Post by Davidobot »

I looked at the OP, so I don't know if anything changed but:

Code: Select all

function love.draw()
     love.graphics.draw(background, 0, 0)
     love.graphics.draw(Llama, x, y)
end
I think that should fix it?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Fixing An Incorrectly Coded Drawing Function

Post by bartbes »

Davidobot wrote: I think that should fix it?
The X and Y coordinates default to 0, so that is equal.
User avatar
Innocuous
Prole
Posts: 13
Joined: Thu Jul 11, 2013 12:09 pm

Re: Fixing An Incorrectly Coded Drawing Function

Post by Innocuous »

Davidobot wrote:I looked at the OP, so I don't know if anything changed but:

Code: Select all

function love.draw()
     love.graphics.draw(background, 0, 0)
     love.graphics.draw(Llama, x, y)
end
I think that should fix it?
Well, his Load callback was in another function so the extra 'end' was not the problem.
Rehnrald
Prole
Posts: 29
Joined: Fri Jul 19, 2013 6:11 am

Re: Fixing An Incorrectly Coded Drawing Function

Post by Rehnrald »

I am driving on a large road trip, so my replies have been scarce... But, I tried using the code Davidobot sent (even though it seems redundant) and it caused no difference whatsoever. I still haven't found the source of the problem still, however.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Fixing An Incorrectly Coded Drawing Function

Post by Davidobot »

Rehnrald wrote:I am driving on a large road trip, so my replies have been scarce... But, I tried using the code Davidobot sent (even though it seems redundant) and it caused no difference whatsoever. I still haven't found the source of the problem still, however.
My coding style is very different from yours, so I might have not understood your code, but you can't have multiple love.loads, love.updates and love.draw.
Here is the fixed .love: https://dl.dropboxusercontent.com/u/354 ... Menu2.love
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
Post Reply

Who is online

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