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

hkrhässleholm's Comments

Back to hkrhässleholm's profile

Dear Malmötri, I just wanna give u a random number of thanks for ur post with code opening!! But let me understand something more details of a part of your program in the "Star" class I'm gonna mention down: public Star(int speed, Color color) { radius = 1 + Greenfoot.getRandomNumber(4); GreenfootImage image = new GreenfootImage (radius, radius); image.setColor (color); image.fillOval (0, 0, radius, radius); setImage (image); this.speed=speed; x = Greenfoot.getRandomNumber(800); y = Greenfoot.getRandomNumber(600); } public void move() { x = speed + x; setLocation(x + speed, y); if(x<1){ x=600;} } } Questions: 1. Why do we need radius and what is actually happening in the line "radius = 1 + Greenfoot.getRandomNumber(4);"? 2. What is the perpose of the codes "{ x = speed + x; setLocation(x + speed, y); if(x<1){ x=600;} } "?? 3. And tell me a little bit more about these two lines: " x = Greenfoot.getRandomNumber(800); y = Greenfoot.getRandomNumber(600);"
Hi, My questions: Why your stars move without pressing they "play" button and why I can't "Reset" that?
Hey Mr. Can I look at the codes please??