so now that I am using the computer at home with eclipse, I see the error "Can't read input file" should i try making a folder for the image or something else, cuz just putting in the image did not...
Type: Posts; User: godlynom
so now that I am using the computer at home with eclipse, I see the error "Can't read input file" should i try making a folder for the image or something else, cuz just putting in the image did not...
sorry was not near computer for while, and no it did not :/ still have the white frame screen
image = ImageIO.read(new File("ges.jpg"));
JLabel picLabel = new JLabel(new ImageIcon(image));
this adds the image to the label, oh, should i do a
add(picLabel); after that?
ah okay, will do that, thanks for that tip, and i am adding the Label when in the Frame class I say
BackgroundPanel panel = new BackgroundPanel();
frame.add(panel);
should I make a panel inside...
no, just the program wanted a try and catch
Hello all, I am making a 2D Scroller game, and I know how to accomplish it, however, having trouble setting an image to the background, no amount of videos or tutorials is helping. The image does not...
I have figured it out, the snake game is up and running, everything works, all the collides and all, now to customize it how i want, thanks so much for your help both times Norm and anyone else who...
yea, i tested it out, the problem is in my follow method, what i do is i set the x and y of the bodyparts to the x and y of the snake, so now i need to make it so that it appears behind the snake,...
I think it is this code
if(go)
{
int i=0;
for(SnakeBody s: snake)
{
if(snake.indexOf(s)>=1)
{
temp1=s;
they are drawn separately, with different x's and y's, but then the next time they move they all become the original snake's x and y and then are drawn upon each other, so it is all the bodyparts in...
okay, yea, my assumption was correct, they do draw, but then their x and y are changed to that of the original snake, thus merging back into one snake
no, they still disappear, are the coordinates getting changed to the first snake's, or is the SnakeBody not being actually drawn, it says it is, trying to figure this out now
well i put the debugger here
for(SnakeBody s: snake)
{
s.draw(g);
System.out.println(s);
}
and each time i got a food it created a new SnakeBody, and then also was drawing them...
well i debugged the paintComponent, and whenever i collide with a food, a new SnakeBody is created and read every single tick, however, it is not being drawn
as an update, i worked on my class and now the snake body parts get created and drawn, but only for a second, so you see the body part and then it disappears, any help?
Snake class:
import...
So if I were to make many snake objects, would i just create an:
ArrayList <SnakeBody> snake = new ArrayList <SnakeBody>();
and then call them one by one in a for loop based on that?
...
The food class did not copy all over, here is the code again
import java.awt.*;
public class Food
{
double x = 0, y = 0;
private double myX; // x and y coordinates of center
...
Hello all, this is godlynom again, thanks to those who helped me last time. Everything is working, now I just need the body parts to be added after I collide with the food. Essentially everytime you...
yea sorry, was at soccer practice
ugh dang small problems....thank you so much for your time, have now got it working and everything, thanks so much
well a fix to my response, now the coordinates of x and y change when keys are pressed, (questions 1 and 3) and the draw method is called also, but the shapes themselves are not drawing, it is not...
The timer printed out the values of the x and y coordinates, following the timer specified at the top, but it does not change the x or y coordinates
I did :
System.out.println(x + " " + y);
...
that was a dumb question, the KeyListener should be in the Snake class, still trying to figure out what is not working, it should be working, mep
I am having trouble with the debugging, it is not helping me. If i want to control the SnakeBody object, should i put the KeyListener in the SnakeBody class, or the Snake class?
yea, one of the end brackets did not copy over for some reason in the SnakeBody class, and it is not really a problem, I just cannot control the SnakeBody object that is created, like I need to. The...