Drawing Images

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
User avatar
Nickmaster24
Prole
Posts: 27
Joined: Sun Jul 03, 2011 5:46 pm

Drawing Images

Post by Nickmaster24 »

I have a .png image I am trying to use for my game but it wont display when I use: "love.graphics.draw". I can make the image the application icon logo thing but every time I try to draw it, it just makes a square with the current color set by "love.graphics.setColor". Any help? :P

Here is some of my code:

Code: Select all

if GameMode == "playing" then 
		for i = 1, 40 do
			for o = 1, 15 do
			Color = CellRender(TheGrid[i][o])
				if Color == 0 then
				love.graphics.setColor( 150, 150, 150, 255 )
				love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )
				elseif Color == 1 then
				love.graphics.reset( )
				love.graphics.draw(GoalImage, (i-1)*40, (o-1)*40)
				else
				love.graphics.setColor( 0, 0, 200, 255 )
				love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )
			end
			love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )
			end
		end
	end
TheNickmaster21
AKA nickmaster24
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Drawing Images

Post by TechnoCat »

My guess is

Code: Select all

love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )
User avatar
rhezalouis
Party member
Posts: 100
Joined: Mon Dec 07, 2009 10:27 am
Location: Indonesia
Contact:

[Response]Your Image is Overdrawn

Post by rhezalouis »

Hi Nickmaster24,

You overdraw both your image and your rectangle with the rectangle at the commented line below:

Code: Select all

  if GameMode == "playing" then
      for i = 1, 40 do
         for o = 1, 15 do
         local t = TheGrid[i] or {}
         Color = CellRender(t[o])
            if Color == 0 then
            love.graphics.setColor( 150, 150, 150, 255 )
            love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )  --overdrawn
            elseif Color == 1 then
            love.graphics.setColor(255, 150, 150, 255)
            love.graphics.draw(GoalImage, (i-1)*40, (o-1)*40)             --overdrawn
            else
            love.graphics.setColor( 0, 0, 200, 255 )
            love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )  --overdrawn
         end
         --love.graphics.rectangle("fill", (i-1)*40, (o-1)*40, 40, 40 )   --with this rectangle ..
         end
      end
   end
N.B. Next time, please attach the *.love file that encases what you are asking so that other people could help you with ease; if your code is top-secret, just pick the relevant parts ^^.
Aargh, I am wasting my posts! My citizenshiiiip... :o
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: [Response]Your Image is Overdrawn

Post by Robin »

rhezalouis wrote:Next time, please attach the *.love file that encases what you are asking so that other people could help you with ease;
This. And don't make any changes, because that'll just make things harder for us and you.
rhezalouis wrote:if your code is top-secret, you shouldn't be asking for help anyway.
FTFY.
Help us help you: attach a .love.
User avatar
Nickmaster24
Prole
Posts: 27
Joined: Sun Jul 03, 2011 5:46 pm

Re: [Response]Your Image is Overdrawn

Post by Nickmaster24 »

rhezalouis wrote:Next time, please attach the *.love file that encases what you are asking so that other people could help you with ease;

How do I do that? Sorry, I am new to this...
TheNickmaster21
AKA nickmaster24
CodeDemon
Prole
Posts: 8
Joined: Tue Nov 22, 2011 4:09 pm
Location: UK

Re: Drawing Images

Post by CodeDemon »

There is a handy topic here http://love2d.org/forums/viewtopic.php?f=4&t=451 which shows how to make a love file.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Drawing Images

Post by thelinx »

First, create a .love file using the knowledge from the article Game_Distribution.

Next, when posting, click the "Upload attachment" button below the Submit button, select your .love file, and post away.
User avatar
Nickmaster24
Prole
Posts: 27
Joined: Sun Jul 03, 2011 5:46 pm

Re: Drawing Images

Post by Nickmaster24 »

I already know how to make a love file...

I just didn't know that it was possible to upload an attachment and that you could...
TheNickmaster21
AKA nickmaster24
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 11 guests