Images turn into white squares after time

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.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Images turn into white squares after time

Post by MadByte »

yes you are. I posted you the solution and you reposted it - maybe you just overlooked it.

Code: Select all

local image    = love.graphics.newImage("assets/asteroid.png")

function Asteroid:new(x, y)
  self.image    = image
  ...
 
It's just importent that you don't call love.graphics.newImage inside your constructor (Asteroid:new()).
If you prefer it you can also load the image inside another file or in your main, just refer it to your object and dont load the image inside it.

EDIT
Another way to do it:

Code: Select all

-- assets.lua
return {
["playerImage"] = love.graphics.newImage(path),
["enemyImage"] = love.graphics.newImage(otherpath),
}

-- main.lua
assets = require("assets")
...
-- player.lua
...
function Asteroid:new(x, y)
  self.image    = assets.playerImage -- or you draw this image directly from the assets table without assigning it to the player object.
 ...
Last edited by MadByte on Sat Mar 26, 2016 6:41 pm, edited 1 time in total.
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Images turn into white squares after time

Post by Vimm »

Sulunia wrote:From what i see, you create a new image..

Code: Select all

playerImg = love.graphics.newImage("assets/player.png")
everytime you instantiate a "Player". So, if you create 300 players, you will also load the same file 300 times.

Try adding to your main love.load()

Code: Select all

function love.load()
	player = Player(0,0)
	playerImg = love.graphics.newImage("assets/player.png")
end
and when you draw the player, just use playerImg as you would.

Tl, dr: Make sure you load a texture just once (newImage) and then use the loaded texture everywhere you need it again.

Also, shouldnt this..

Code: Select all

function Player:new(x, y)
	speed = 500
end
be self.speed = 500? So each player has it's own individual speed?

I put the img in love.load and it still happens, I'm convinced my computer is just broken.

and i would use self.speed if there was gonna be more than 1 player. since theres only one i left it like that
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: Images turn into white squares after time

Post by Sulunia »

It's weird. You say you have a problem with white square, but the example you posted here works just fine.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Images turn into white squares after time

Post by Vimm »

Sulunia wrote:It's weird. You say you have a problem with white square, but the example you posted here works just fine.
thats why im saying its a problem with my computer, its been having loads of issues lately so this must just be one of them
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: Images turn into white squares after time

Post by Sulunia »

Welp, in that case, it's the general stuff.. Update video drivers, remove internal dust, maybe even reinstall the OS you're currently using.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Images turn into white squares after time

Post by Vimm »

Sulunia wrote:Welp, in that case, it's the general stuff.. Update video drivers, remove internal dust, maybe even reinstall the OS you're currently using.
believe me ive tried all that, just gotta wait till i have money then ill stop using terrible AMD graphics cards lol
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Images turn into white squares after time

Post by MadByte »

just out of curiosity .. do you use the latest LÖVE version (0.10.0)? If so - try another one (0.9.2 e.g), if not - try 0.10.0.
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Images turn into white squares after time

Post by Vimm »

MadByte wrote:just out of curiosity .. do you use the latest LÖVE version (0.10.0)? If so - try another one (0.9.2 e.g), if not - try 0.10.0.
I use 0.9.2, I had even more troubles with the latest version where the window would just randomly clear itself of any graphics after a few seconds of running.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Images turn into white squares after time

Post by MadByte »

Alright. What about other OpenGL based games on your system (e.g Minecraft), do they work as intended? What about other games? Do you have graphical glitches in most of them? Because if the problem is a damaged GPU you should notice more problems like that. If not then it's more likely that there is a problem with your drivers / OS.
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Images turn into white squares after time

Post by Vimm »

MadByte wrote:Alright. What about other OpenGL based games on your system (e.g Minecraft), do they work as intended? What about other games? Do you have graphical glitches in most of them? Because if the problem is a damaged GPU you should notice more problems like that. If not then it's more likely that there is a problem with your drivers / OS.
My graphics drivers crash frequently lol, the only game i play that crashes is CS:GO, most games like minecraft, league, ect run fine
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest