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...
Oh ok, thank you! I managed to fix it, for some reason I needed to create the project again with the same name? I don't know why but it worked, all my classes are restored. Eclipse must have lost the...
Thanks for the reply,
I can't even find the parent folder/package in eclipse, I've tried the package explorer and navigators, there is no directory for me to find it. The files are not...
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.
Hello everyone, I have been using Eclipse as a Java IDE for a while now and came to my first big problem. I have been creating a game for a few months now with no problems, now when I run eclipse and...
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...
Thank you Norm, the problem was I kept on mixing up my x and y values which returned a result I did not want. I also declared the variables holding the x and y value changes after the loop was...
Pretty much all the code I posted you is working at the moment as it is only considering the left and bottom lines. I do not know how to do the top or right lines as each time I try it never works...
currentX= 115, currentY = 157 are the values printed out. Let me show you the whole current code so you can see what I am actually talking about.
private void drawMaze(Graphics2D g){
...
For testing purposes, I wanted the first column to start at y = 10, x = 10 and print 7 times to end up at y = 115, x = 10. The same principal would work for the next column and row. The problem came...
That is in fact what the print looks like when the images printed are not where I want them to be. To see my actual visual problem with the images, look here: 1269
The images are at the moment...
I get an infinite pattern of this:
currentX= 31, currentY = 115, xOffset = 21yOffset = 21 and length = 7
currentX= 52, currentY = 115, xOffset = 21yOffset = 21 and length = 7
currentX= 73,...
I am a bit confused as to what is going on here, what are all the '=' and quotes at different places for?
I don't understand what you mean by println statements? Aren't those only for strings? Sorry, i'm still getting used to java!