convert from float to int
in
Programming Questions
•
3 years ago
Hi guys, I’m quite a newbie with processing. I’m trying to make a cat chase mouse game with pixel collision and pvector. I came up with this error says the method get in the type PImage is not applicable for the arguments. If anyone can help me with this error I’ll be very appreciated, thank!
Cat C;
Cheese E;
PImage cheese;
PImage cat;
PImage mouse;
cat= loadImage("Cat.JPG");
cheese = loadImage("Cheese.JPG");
mouse = loadImage("Mouse.JPG");
C = new Cat(width/4, height/4, 0, 1);
E = new Cheese();
smooth();
stroke(210,200,180);
fill(210,200,180);
cursor(CROSS);
}
fill(210,200,180);
cursor(CROSS);
}
void draw() {
// background(0);
E.display();
M.display();
C.display();
}
M.display();
C.display();
}
void drawVector(PVector p, PVector d, float rad) {
pushMatrix();
translate(p.x, p.y);
strokeWeight(1);
ellipse(0, 0, rad, rad);
ellipse(0, 0, rad, rad);
popMatrix();
}
}
class Cat {
PImage C;
PVector pos;
PVector dir;
PImage C;
PVector pos;
PVector dir;
Cat(float x, float y, float mx, float my) {
C = loadImage("Cat.JPG");
pos = new PVector(x,y);
dir = new PVector(mx, my);
}
dir = new PVector(mx, my);
}
void display() {
smooth();
stroke(255,255,0);
fill(255,255,0);
cursor(CROSS);
dir.x = mouseX - pos.x;
dir.y = mouseY - pos.y;
dir.normalize();
pos.add(dir);
// drawVector( pos, dir, 20);
image(cat,pos.x,pos.y);
}
}
dir.y = mouseY - pos.y;
dir.normalize();
pos.add(dir);
// drawVector( pos, dir, 20);
image(cat,pos.x,pos.y);
}
}
class Mouse {
PVector dir;
PVector pos;
PImage img;
PVector pos;
PImage img;
Mouse(PImage _img, int _x, int _y) {
img = _img;
PImage img;
}
}
private void moveIfClear()
{
{
pos = pos.get( );
if( checkForWhitePixel() ) {
pos.add(dir);
}
}
}
}
private boolean checkForWhitePixel() {
if(img.get(pos.x, pos.y) == color(255)) {
return true;
}
}
return false;
}
}
Mouse(float x, float y, float mx, float my) {
pos = new PVector(x,y);
dir = new PVector(mx, my);
}
dir = new PVector(mx, my);
}
void display() {
smooth();
stroke(210,200,180);
fill(210,200,180);
cursor(CROSS);
stroke(210,200,180);
fill(210,200,180);
cursor(CROSS);
dir.x = mouseX - pos.x;
dir.y = mouseY - pos.y;
dir.normalize();
pos.add(dir);
dir.y = mouseY - pos.y;
dir.normalize();
pos.add(dir);
image(mouse,pos.x,pos.y);
image(img, 50,100,400,400);
fill(255,0,0);
noStroke();
}
}
}
}
1