images in p2d

edited January 2018 in Programming Questions

So I'm making a game and it is starting to get very laggy. I switched the renderer to P2D and the frame rate has doubled so that's good. The only problem is that now I can't see the image I was using for a background, and the points I was using as stars are very hard to see.

Answers

  • Can you show a small example / program version of the background problem?

  • PImage sky;
    
    void setup(){  
      size(1080,720,P2D);
      colorMode(HSB);
      sky = createImage(width,height,HSB);
      for(int y = 0; y < sky.height; y++){ 
        for(int x = 0; x < sky.width; x++){
          sky.set(x,y,color(255,0,0));  
        }
      }
    }
    
    void draw(){
      image(sky,0,0);
    }
    
  • edited January 2018 Answer ✓

    https://Docs.Oracle.com/javase/9/docs/api/java/util/Arrays.html#fill-int:A-int-

    // Forum.Processing.org/two/discussion/25795/images-in-p2d#Item_3
    
    PImage sky;
    
    void setup() {  
      size(800, 600);
      noLoop();
    
      colorMode(HSB);
      final color c = color(255, 255, 127);
    
      sky = createImage(width, height, ARGB);
      java.util.Arrays.fill(sky.pixels, c);
      sky.updatePixels();
    }
    
    void draw() {
      background(sky);
    }
    
Sign In or Register to comment.