Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
There are three kinds of actuaries: those who can count, and those who can't.
Thanks but I worry that this seems like a really complex way of doing what I want. I'll freely admit my current solution is too slow on low powered laptops but, if I could build an image using setColor and fillRect, then that wouldn't be an issue - can I not do this in Java?Piet Souris wrote:Indeed, have a look at the Paint-interface and the Gradient- and TexturePaint classes. And there is also the MultipleGradientPaint class, in the forms of a Linear and Radial version.
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
There are three kinds of actuaries: those who can count, and those who can't.
In the example code I gave there's an array of colours called SkyColours. These are adjusted each time the sky colour changes (if the health is low, if the weather is bad, if a something bad is about to happen). The array goes from 0 to 80 as the rectangles of colour are 5 y pixels wide and the sky is drawn down to about 2/3 of the screen.Carey Brown wrote:You'd have to explain for us how you determine your starting and finishing colors and the colors in between, and the Y distance between the start and end rows.
Do you compute them or use a look up table?
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Piet Souris wrote:Apart from that, it is possible to create several BufferedImages that you can draw to, so that in a repaint you only have to draw the correct BI, and do some custom painting over that. Whether that is suitable, I don't know. Another possibility is that you do the drawing in another thread, so that a repaint only requires drawing that BI. If you repaint every 20 ms, say, than this will give you 20 ms to get that drawing done. Just some thoughts.
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
This worked great when using a single buffered image and fixed the performance issue. I then figured why not create an array of 25 bufferedImages and initialise them all before play and that would fix things completely. I couldn't work out how to change the declaration of the buffered image into an array. I tried various ways but couldn't work out the syntax. I tried the following plus variations and also trying things in a loop but no luck. Any suggestions for the correct syntax?Carey Brown wrote:
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Rob Camick wrote:1) Don't override paint(). Custom painting should be done by overriding paintComponent().
2) Invoke super.paintComponent(...) first to make sure background is cleared before you do custom painting
There are three kinds of actuaries: those who can count, and those who can't.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |