This site requires JavaScript, please enable it in your browser!
Greenfoot back
game_salajan
game_salajan wrote ...

2018/2/25

Making object return to starting position when touching a color

1
2
3
4
game_salajan game_salajan

2018/2/25

#
import greenfoot.*; import java.awt.Color; /** * Write a description of class masinutza here. * @author (your name) @version (a version number or a date) */ public class masinutza extends Actor { /** * Act - do whatever the masinutza wants to do. This method is called whenever the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if ( Greenfoot.isKeyDown("up") ) { move(3); } if ( Greenfoot.isKeyDown("down") ) { move(-3); } if ( Greenfoot.isKeyDown("right") ) { turn(3); } if ( Greenfoot.isKeyDown("left") ) { turn(-3); } Color color1 = new Color(34,177,76); // Culoarea ierbii Color color2 = new Color(239,228,176); // Culoarea drumului if (color1.equals(getWorld().getBackground().getColorAt(getX(),getY()))) {setLocation(106,448);} if (Greenfoot.isKeyDown("g")) { Color color = getWorld().getBackground().getColorAt(getX(), getY()); System.out.println("Color: "+color); Greenfoot.stop(); } } }
danpost danpost

2018/2/25

#
Why is it the second line from the top? :</
game_salajan game_salajan

2018/2/25

#
what do you mean ?
game_salajan game_salajan

2018/2/25

#
can we discuss this on facebook , where i can send you images so we can figure it out in time , just if you want :P :-??
Super_Hippo Super_Hippo

2018/2/25

#
Remove the second line. How does it even compile?
game_salajan game_salajan

2018/2/25

#
YES
game_salajan game_salajan

2018/2/25

#
DAMN
game_salajan game_salajan

2018/2/25

#
THANK YOU SO MUCH GUYS <3
danpost danpost

2018/2/25

#
game_salajan wrote...
danpost wrote...
Why is it the second line from the top? :</
what do you mean ?
I mean, follow the discussion from here which says:
Remove any line similar to the following from any and all classes:
import java.awt.Color;
Your next post says you did remove said lines. Then, the following one shows code with exactly that same line still in it.
danpost danpost

2018/2/25

#
Super_Hippo wrote...
Remove the second line. How does it even compile?
Oh -- it will compile. Making use of it (java.awt.Color) might be quite a trick, however; and it will not covert to HTML5 javascript on the site.
game_salajan game_salajan

2018/2/25

#
yea , so the problem actually was that (java.awt.Color) , when u said why is that on my 2nd line up i thought u mean it should be on the first line , not to erase it :))) but it s cool , thank you and everyone who replied !!! Respect
game_salajan game_salajan

2018/2/25

#
Just now when u lastly replied i saw that u actually said to remove it :)) sory , i am so damn tired ...
You need to login to post a reply.
1
2
3
4