Jump to content

Processing CSGO Case Sim Problem

DuelShott

So I am trying to make a csgo case sim in processing and every time i try launching it will give me the message "The method image(PImage,float,float) in the type PApplet is not applicable for the arguments (PImage,double,floats)" I tried changing the double to floats but it just crashes.

Code:

PImage img;
boolean picture = false;
int m;
int sec = 0;
int rectX = 285;
int rectY = 275;
int siz;
int siz1;
double x = 100;
double x1 = x+=120;
double x2 = x1+=120;
double x3 = x2+=120;
double x4 = x3+=120;
double x5 = x4+=120;
double x6 = x5+=120;
double x7 = x6+=120;
double x8 = x7+=120;
double x9 = x8+=120;
double x10 = x9+=120;
double x11 = x10+=120;
double x12 = x11+=120;
double x13 = x12+=120;
double x14 = x13+=120;
double x15 = x14+=120;
double x16 = x15+=120;
double x17 = x16+=120;
double x18 = x17+=120;
double x19 = x18+=120;
double x20 = x19+=120;
double x21 = x20+=120;
double x22 =  x21+=120;
double x23 =  x22+=120;
double x24 =  x23+=120;
double x25 =  x24+=120;
double x26 =  x25+=120;
double x27 =  x26+=120;
double x28 =  x27+=120;
double x29 =  x28+=120;
double x30 = x29+=120;
PImage gun;
// PImage AK;
PImage[] gunArray = new PImage[31];
PImage[] imageArray = new PImage[30];
public PImage randomgen(){
  int number = int (random(0,9970));
  if(number<920){
    //image(imageArray[0], 362.5, 64.5);
    return imageArray[0];
  }
  else if(number>=920&&number<=2350){
    // image(imageArray[1], 362.5, 64.5);
    return imageArray[1];
  }
  else if(number>2350&&number<=3970){
    // image(imageArray[2], 362.5, 64.5);
    return imageArray[2];
  }
  else if(number>3970&&number<=5081){
    //   image(imageArray[3], 362.5, 64.5);
    return imageArray[3];
  }
  else if(number>5081&&number<=6889){
    // image(imageArray[4], 362.5, 64.5);
    return imageArray[4];
  }
  else if(number>6889&&number<=7889){
    //   image(imageArray[5], 362.5, 64.5);
    return imageArray[5];
  }
  else if(number>7889&&number<=8269){
    //    image(imageArray[6], 362.5, 64.5);
    return imageArray[6];
  }
  else if(number>8269&&number<=8598){
    //  image(imageArray[7], 362.5, 64.5);
    return imageArray[7];
  }
  else if(number>8598&&number<=8978){
    //   image(imageArray[8], 362.5, 64.5);
    return imageArray[8];
  }
  else if(number>8978&&number<=9278){
    //   image(imageArray[9], 362.5, 64.5);
    return imageArray[9];
  }
  else if(number>9278&&number<=9588){
    //   image(imageArray[10], 362.5, 64.5);
    return imageArray[10];
  }
  else if(number>9588&&number<=9688){
    //  image(imageArray[11], 362.5, 64.5);
    return imageArray[11];
  }
  else if(number>9688&&number<=9786){
    // image(imageArray[12], 362.5, 64.5);
    return imageArray[12];
  }
  else if(number>9786&&number<=9866){
    // image(imageArray[13], 362.5, 64.5);
    return imageArray[13];
  }
  else if(number>9866&&number<=9929){
    // image(imageArray[14], 362.5, 64.5);
    return imageArray[14];
  }
  else if(number>9929&&number<=9966){
    // image(imageArray[15], 362.5, 64.5);
    return imageArray[15];
  }
  else if(number>9966&&number<=9969){
    //image(imageArray[16], 362.5, 64.5);
    return imageArray[16];
  }
  else if(number>9969&&number<=9970){
    // image(imageArray[17], 362.5, 64.5);
    return imageArray[17];
  }
  return imageArray[5];
}
void setup(){
  frameRate(60);
  size(725,500);
  strokeWeight(3);
  img = loadImage("Line.png");
  imageArray[0] = loadImage("Galil.png");
  imageArray[1] = loadImage("Glock.png");
  imageArray[2] = loadImage("Nova.png");
  imageArray[3] = loadImage("P90.png");
  imageArray[4]  = loadImage("UMP.png");
  imageArray[5] = loadImage("USP.png");
  imageArray[6] = loadImage("FAMAS.png");
  imageArray[7] = loadImage("M4.png");
  imageArray[8] = loadImage("MP9.png");
  imageArray[9] = loadImage("Negev.png");
  imageArray[10] = loadImage("P2000.png");
  imageArray[11] = loadImage("CZ.png");
  imageArray[12] = loadImage("MP7.png");
  imageArray[13] = loadImage("SG.png");
  imageArray[14] = loadImage("AK.png");
  imageArray[15] = loadImage("AWP.png");
  imageArray[16] = loadImage("Knife.png");
  imageArray[17] = loadImage("buffalo.png");
  /////////////////////////////////////////////////////
  gunArray[0] = randomgen();
  gunArray[1] = randomgen();
  gunArray[2] = randomgen();
  gunArray[3] = randomgen();
  gunArray[4] = randomgen();
  gunArray[5] = randomgen();
  gunArray[6] = randomgen();
  gunArray[7] = randomgen();
  gunArray[8] = randomgen();
  gunArray[9] = randomgen();
  gunArray[10] = randomgen();
  gunArray[11] = randomgen();
  gunArray[12] = randomgen();
  gunArray[13] = randomgen();
  gunArray[14] = randomgen();
  gunArray[15] = randomgen();
  gunArray[16] = randomgen();
  gunArray[17] = randomgen();
  gunArray[18] = randomgen();
  gunArray[19] = randomgen();
  gunArray[20] = randomgen();
  gunArray[21] = randomgen();
  gunArray[22] = randomgen();
  gunArray[23] = randomgen();
  gunArray[24] = randomgen();
  gunArray[25] = randomgen();
  gunArray[26] = randomgen();
  gunArray[27] = randomgen();
  gunArray[28] = randomgen();
  gunArray[29] = randomgen();
  gunArray[30] = randomgen();
  gun = randomgen();
}
void draw(){
  loop();
  //       while(!mousePressed){
  strokeWeight(0);
  fill(15, 31, 46);
  rect(0, 0, 725, 250);

  fill(0, 61, 92);
  rect(0, 250, 725, 300);
  strokeWeight(4);
  stroke(87, 110, 3);
  fill(121, 153, 5);
  siz = 150;
  siz1 = 35;
  rect(rectX, rectY, 150, 35);
  fill(0, 0, 0);
  // image(imageArray[17], x, 64.7);
  strokeWeight(5.5);
  stroke(0, 0, 0);
  rect(50, 40, 625, 155);
  sec +=1;
  System.out.println(sec);
  //  image(AK, 362.5, 64.5);
  //image(imageArray[17], x, 64.7);

  ////////////////////////////////////////
  //   image(gunArray[0], x, 64.7);
  //       image(gunArray[1], x1, 64.7);
  //     image(gunArray[2], x2, 64.7);
  //   image(gunArray[3], x3, 64.7);
  //             image(gunArray[4], x4, 64.7);
  //         image(gunArray[5], x5, 64.7);
  //                image(gunArray[6], x6, 64.7);
  //         image(gunArray[7], x7, 64.7);
  //     image(gunArray[8], x8, 64.7);
  //                    image(gunArray[9], x9, 64.7);
  //                      image(gunArray[10], x10, 64.7);
  //                   image(gunArray[11], x11, 64.7);
  //              image(gunArray[12], x12, 64.7);
  //          image(gunArray[13], x13, 64.7);
  //      image(gunArray[14], x14, 64.7);
  //           image(gunArray[15], x15, 64.7);
  //        image(gunArray[16], x16, 64.7);
  //     image(gunArray[17], x17, 64.7);
  /////////////////////////////
  if( picture == true){
    if(millis()>m && (millis()<m+500)){
      x -=17;
      x1 -=17;
      x2 -=17;
      x3 -=17;
      x4 -=17;
      x5 -=17;
      x6 -=17;
      x7 -=17;
      x8 -=17;
      x9 -=17;
      x10 -=17;
      x11 -=17;
      x12 -=17;
      x13 -=17;
      x14 -=17;
      x15 -=17;
      x16 -=17;
      x17 -=17;
      x18 -=17;
      x19 -=17;
      x20 -=17;
      x21 -=17;
      x22 -=17;
      x23 -=17;
      x24 -=17;
      x25 -=17;
      x26 -=17;
      x27 -=17;
      x28 -=17;
      x29 -=17;
      x30 -=17;
    }
    if(millis()>m+500 && (millis()<m+1500)){
      x -=13;
      x1 -=13;
      x2 -=13;
      x3 -=13;
      x4 -=13;
      x5 -=13;
      x6 -=13;
      x7 -=13;
      x8 -=13;
      x9 -=13;
      x10 -=13;
      x11 -=13;
      x12 -=13;
      x13 -=13;
      x14 -=13;
      x15 -=13;
      x16 -=13;
      x17 -=13;
      x18 -=13;
      x19 -=13;
      x20 -=13;
      x21 -=13;
      x22 -=13;
      x23 -=13;
      x24 -=13;
      x25 -=13;
      x26-=13;
      x27 -=13;
      x28 -=13;
      x29 -=13;
      x30 -=13;
    }
    if(millis()>m+1500 && (millis()<m+2000)){
      x -=9;
      x1 -=9;
      x2 -=9;
      x3 -=9;
      x4 -=9;
      x5 -=9;
      x6 -=9;
      x7 -=9;
      x8 -=9;
      x9 -=9;
      x10 -=9;
      x11 -=9;
      x12 -=9;
      x13 -=9;
      x14 -=9;
      x15 -=9;
      x16 -=9;
      x17 -=9;
      x18 -=9;
      x19 -=9;
      x20 -=9;
      x21 -=9;
      x22 -=9;
      x23 -=9;
      x24 -=9;
      x25 -=9;
      x26 -=9;
      x27 -=9;
      x28 -=9;
      x29 -=9;
      x30 -=9;
    }
     if(millis()>m+2000 && (millis()<m+3000)){
      x -=7;
      x1 -=7;
      x2 -=7;
      x3 -=7;
      x4 -=7;
      x5 -=7;
      x6 -=7;
      x7 -=7;
      x8 -=7;
      x9 -=7;
      x10 -=7;
      x11 -=7;
      x12 -=7;
      x13 -=7;
      x14 -=7;
      x15 -=7;
      x16 -=7;
      x17 -=7;
      x18 -=7;
      x19 -=7;
      x20 -=7;
      x21 -=7;
      x22 -=7;
      x23 -=7;
      x24 -=7;
      x25 -=7;
      x26 -=7;
      x27 -=7;
      x28 -=7;
      x29 -=7;
      x30 -=7;
    }
    if(millis()>m+3000 && (millis()<m+4000)){
      x -=5;
      x1 -=5;
      x2 -=5;
      x3 -=5;
      x4 -=5;
      x5 -=5;
      x6 -=5;
      x7 -=5;
      x8 -=5;
      x9 -=5;
      x10 -=5;
      x11 -=5;
      x12 -=5;
      x13 -=5;
      x14 -=5;
      x15 -=5;
      x16 -=5;
      x17 -=5;
      x18 -=5;
      x19 -=5;
      x20 -=5;
      x21 -=5;
      x22 -=5;
      x23 -=5;
      x24 -=5;
      x25 -=5;
      x26 -=5;
      x27 -=5;
      x28 -=5;
      x29 -=5;
      x30 -=5;
    }
    if(millis()>m+4000 && (millis()<m+4500)){
         x -=4;
      x1 -=4;
      x2 -=4;
      x3 -=4;
      x4 -=4;
      x5 -=4;
      x6 -=4;
      x7 -=4;
      x8 -=4;
      x9 -=4;
      x10 -=4;
      x11 -=4;
      x12 -=4;
      x13 -=4;
      x14 -=4;
      x15 -=4;
      x16 -=4;
      x17 -=4;
      x18 -=4;
      x19 -=4;
      x20 -=4;
      x21 -=4;
      x22 -=4;
      x23 -=4;
      x24 -=4;
      x25 -=4;
      x26 -=4;
      x27 -=4;
      x28 -=4;
      x29 -=4;
      x30 -=4;
    }
    if(millis()>m+4500 && (millis()<m+5000)){
              x -=3;
      x1 -=3;
      x2 -=3;
      x3 -=3;
      x4 -=3;
      x5 -=3;
      x6 -=3;
      x7 -=3;
      x8 -=3;
      x9 -=3;
      x10 -=3;
      x11 -=3;
      x12 -=3;
      x13 -=3;
      x14 -=3;
      x15 -=3;
      x16 -=3;
      x17 -=3;
      x18 -=3;
      x19 -=3;
      x20 -=3;
      x21 -=3;
      x22 -=3;
      x23 -=3;
      x24 -=3;
      x25 -=3;
      x26 -=3;
      x27 -=3;
      x28 -=3;
      x29 -=3;
      x30 -=3;
    }
     if(millis()>m+5000 && (millis()<m+5500)){
          x1 -=2;
      x2 -=2;
      x3 -=2;
      x4 -=2;
      x5 -=2;
      x6 -=2;
      x7 -=2;
      x8 -=2;
      x9 -=2;
      x10 -=2;
      x11 -=2;
      x12 -=2;
      x13 -=2;
      x14 -=2;
      x15 -=2;
      x16 -=2;
      x17 -=2;
      x18 -=2;
      x19 -=2;
      x20 -=2;
      x21 -=2;
      x22 -=2;
      x23 -=2;
      x24 -=2;
      x25 -=2;
      x26 -=2;
      x27 -=2;
      x28 -=2;
      x29 -=2;
      x30 -=2;
     }
     if(millis()>m+5500 && (millis()<m+6000)){
             x1 -=1;
      x2 -=1;
      x3 -=1;
      x4 -=1;
      x5 -=1;
      x6 -=1;
      x7 -=1;
      x8 -=1;
      x9 -=1;
      x10 -=1;
      x11 -=1;
      x12 -=1;
      x13 -=1;
      x14 -=1;
      x15 -=1;
      x16 -=1;
      x17 -=1;
      x18 -=1;
      x19 -=1;
      x20 -=1;
      x21 -=1;
      x22 -=1;
      x23 -=1;
      x24 -=1;
      x25 -=1;
      x26 -=1;
      x27 -=1;
      x28 -=1;
      x29 -=1;
      x30 -=1;
     }
          if(millis()>m+5500 && (millis()<m+6000)){
                         x1 -=1;
      x2 -=0.5;
      x3 -=0.5;
      x4 -=1;
      x5 -=1;
      x6 -=1;
      x7 -=1;
      x8 -=1;
      x9 -=1;
      x10 -=1;
      x11 -=1;
      x12 -=1;
      x13 -=1;
      x14 -=1;
      x15 -=1;
      x16 -=1;
      x17 -=1;
      x18 -=1;
      x19 -=1;
      x20 -=1;
      x21 -=1;
      x22 -=1;
      x23 -=1;
      x24 -=1;
      x25 -=1;
      x26 -=1;
      x27 -=1;
      x28 -=1;
      x29 -=1;
          }
    image(gunArray[0], x, 64.7);
    image(gunArray[1], x1, 64.7);
    image(gunArray[2], x2, 64.7);
    image(gunArray[3], x3, 64.7);
    image(gunArray[4], x4, 64.7);
    image(gunArray[5], x5, 64.7);
    image(gunArray[6], x6, 64.7);
    image(gunArray[7], x7, 64.7);
    image(gunArray[8], x8, 64.7);
    image(gunArray[9], x9, 64.7);
    image(gunArray[10], x10, 64.7);
    image(gunArray[11], x11, 64.7);
    image(gunArray[12], x12, 64.7);
    image(gunArray[13], x13, 64.7);
    image(gunArray[14], x14, 64.7);
    image(gunArray[15], x15, 64.7);
    image(gunArray[16], x16, 64.7);
    image(gunArray[17], x17, 64.7);
    image(gunArray[18], x18, 64.7);
    image(gunArray[19], x19, 64.7);
    image(gunArray[20], x20, 64.7);
    image(gunArray[22], x21, 64.7);
    image(gunArray[23], x22, 64.7);
    image(gunArray[24], x23, 64.7);
    image(gunArray[25], x24, 64.7);
    image(gunArray[26], x25, 64.7);
    image(gunArray[27], x26, 64.7);
    image(gunArray[28], x27, 64.7);
    image(gunArray[29], x28, 64.7);
    image(gunArray[30], x29, 64.7);
    image(img, 362.5, 33);
    stroke(15, 31, 46);
    strokeWeight(0);
    fill(15, 31, 46);
    rect(0, 0, 47, 250);
    rect(675, 0, 50, 250);
  }
  // if(m>4000){
  //    noLoop();
  //
  //    }
}
void mousePressed(){
  if(mouseX>=rectX&&mouseX<=rectX +siz &&mouseY>=rectY&&mouseY<=rectY + siz1 ){
    m = millis();
    picture = true; 
  }
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

The message is pretty clear & your gut instinct to change the double types to floats was correct.

 

Please elaborate on "I tried changing the double to floats but it just crashes" - have you tried stepping through the code & what happens exactly? It would also help us, as mentioned above, if you posted the image() method here.

 

Just as an extra observation, you can massively cut down the amount of code lines and at the same time have this more maintainable should your amount of variables &/or arrays elements need to shrink or grow in the future, if you learn looping.

Link to comment
Share on other sites

Link to post
Share on other sites

The reason you are getting a NullPointerException is because gunArray[0] is null. The only way that could be null is if one (or more) of the images in imageArray is equal to null. Do all of your images load correctly? When you start up your application do you get any errors like the following
 

Quote

The file "Line.png" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.

 

EDIT: I added images to my project and was able to run the application without any exceptions. Where are the images you are referencing? Because of how you are referencing the images, they need to be present on your classpath.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×