Thanks, I've done that, though the person is still going through the cobblestone images. What part of the code shall I post to you?
Printable View
Thanks, I've done that, though the person is still going through the cobblestone images. What part of the code shall I post to you?
Time for some debugging. Print the values of the variables that control where and when the person moves. Be sure to indicate the place and time when the person should stop moving. If the person's position continues to change after that point, look at the code that is changing the position and see why it is doing it.
hey im new but i been working on collision too.. id like to show you have i do collision detection an see if it helps you....
really hope this helps and any questions just ask p.s i just typed this in so if i missed anything let me now i will look over it in a secQuote:
// so i write my collision detection in my paint method..... i dont know if that a bad thing but it works perfect for me...
Image sprite();
Rectangle SpriteRect = new Rectangle(X,Y,100,100);
Rectangle Two = new Rectangle(100,100,100,100);
public void loadImage(){
sprite = new ImageIcon("C:\\place on HD").getImage;
}
public void paint(Graphics g){
super.paint(g);
Graphics2D g2 =(Graphics2D)g;
g2d.drawRect(sprite,SpriteRect.x, SpriteRect.y, SpriteRect.width, SpriteRect.height);
g2d.drawRect(Two, 50,50,200,200);
if(SpriteRect.intersects(Two)){CODE YOU WANT IS INTERSECT = TRUE};
}
hey im new but i been working on collision too.. id like to show you have i do collision detection an see if it helps you....
really hope this helps and any questions just ask p.s i just typed this in so if i missed anything let me now i will look over it in a secQuote:
// so i write my collision detection in my paint method..... i dont know if that a bad thing but it works perfect for me...
Image sprite();
Rectangle SpriteRect = new Rectangle(X,Y,100,100);
Rectangle Two = new Rectangle(100,100,100,100);
public void loadImage(){
sprite = new ImageIcon("C:\\place on HD").getImage;
}
public void paint(Graphics g){
super.paint(g);
Graphics2D g2 =(Graphics2D)g;
g2.drawRect(sprite,SpriteRect.x, SpriteRect.y, SpriteRect.width, SpriteRect.height);
g2.drawRect(Two, Two.x,Two.y,Two.width,Two.height);
if(SpriteRect.intersects(Two)){CODE YOU WANT IF INTERSECT = TRUE};
loadImage();
}
sorry for double post this post is correct first one i made one or two little mistakes
why don't you write a collision metod in entites class???
you should use a superclass for sprite where you will write all the common methods so you can override them if it will be necessary
example :
class player extends Sprite{
@Override
public void collide(){
dx = 0;
dy = 0;
}
}
class enemy extends Sprite{
@Override
public void collide(){
dx = 0;
dy = 0;
}
}
and in your collision manager method....
if(isCollided(sprite1,sprite2){
sprite1.collide;
sprite2.collide;
}
"isCollided is the hypothetical method that checks collisions but i will not write it but if you need it i will XD"