In my "Snake" class, in the constructor, my cods look like this:
And in my world class, inside the constructor, my codes look like this:
public SnakeEarth()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(900, 550, 1);
Greenfoot.setSpeed(35);
snake=new Snake;
snake=new Snake("head",color1);
snake=new Snake();
snake=new Snake();
addObject(snake, 70, 60);
addObject(snake, 49, 60);
addObject(snake, 29, 60);
addObject(new SnakeHunter(),81,227);
addObject(new SnakeHunter(), 500, 230);
addObject(new SnakeHunter(), 818, 435);
}
Okay my questions are about these 2 lines respectively in world and snake class:
World(SnakeEarth) class:
Greenfoot.setSpeed(35);
Snake class:
speedX=speed=15;
I understand that the setSpeed method set the speed(35) of snake which will be the actual speed of snake.
But, in the snake class, I have an another speed value (15).
(1) . What does it do?
I tried by changing that value, but it does nothing with the speed, where it just increases or decreases the distance between two body segments.
public Snake(String segment, Color color) { this.segment=segment; direction= "right"; speedX=speed=15; speedY=0; length=3; GreenfootImage image=new GreenfootImage(22,22); image.setColor(color); image.fillOval(0,0,22,22); setImage(image); }