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?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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.
If you don't understand my answer, don't ignore it, ask a question.
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 sec// 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 sec// 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"