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?
Type: Posts; User: Montario
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?
I know how to express 'dx = 0;', the problem is dx is not recognized as a variable in board.java. Do I do this? This is in board.class if that helps.
if (r1.intersects(r2)) {
}
...
Oh apologies, I posted the wrong code, the errors were already resolved, the interface never refreshed to reflect that yet. Here is my code using the methods:
public int getdx() {
return...
public Person(int dx, int dy) {
ImageIcon i = new ImageIcon(this.getClass().getResource(person));
image = i.getImage();
width = image.getWidth(null);
height = image.getHeight(null);...
I tried, but then I come up with many errors stating that the variable could not be resolved. Where in person.java shall I create the method?
I need to access them as I want to set dx and dy to zero if both the person and cobblestone intersect each other. How do I make that reference? I have tried person.dx though that does not work.
package outrun;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
public class Person {
What I meant by was if they both collide with each other, sorry, I wasn't to clear! I do not want to change the variables. I want to use the variable dx and dy from board.java in person.java though I...
I know what I want to happen, I just don't know how to show it. If they both collide, I want the variables dx and dy to be equal to zero. The trouble is those two variables are in the person class,...
Ok, so I have made rectangle classes for both cobblestone.java and person.java (the images I wish to intersect.) Now I am actually determining the collision in my board.java:
public void...
Ok I will work on that, Eclipse somehow does not want to open my files stating that the files do not exist. I will resume work once I get that sorted from someone.
The person has width and height, it is an image I created. Would I need to use getWidth() and getHeight() and assign them to two new variables?
Oh yes, but how would I go about creating a rectangle for the person, it moves? The parameters consist of x and y values. How would I be able to create one if the person is moving, hence constantly...
Hello everyone :)
I am creating a small game and have come to the point where I need to use collision detection. The problem is, I do not exactly know how to create basic collision with...