We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, I've just finished a simple bouncing ball/arkanoid game for University. I did it only with rect(),ellipse() and line(). Now it's time to replace them with images. When I put the images (over the blocks) the game slows down a lot. The images' size is only 3,07kb, PNG, 64x32 pixels.
Here I upload the game without images: link
And here with this first try of images (in class Bloques): link
I think the problem is that I'm using a for-loop to load them.
Thank you.
Answers
Well, I was using an array for loading each image. I delete the array and the for-loop, and the sketch works perfectly. I'm gonna keep trying with another images. If another error occurs I will comment.
you need to load all images in setup() to make sure it's done only once. don't do it in the class or in draw().
I can't open the code, can you post the code here?
;-)
after you've loaded them into an array, just work with index - should be fast.
Chrisir guessed right:
If dibujar() is called in draw(), it means you load images in a loop 60 times per second. No wonder the sketch is slowed down!
See also What are setup() and draw()? and the other articles of the Common Questions category.
thank you, philho!
Yes, I've noticed that and solved it. Now I'm gonna load it in setup as Chrisir said.
P.S: Chrisir I owe you my mark in the University haha
glad to hear that!
;-)