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

mjrb4's Comments

Back to mjrb4's profile

Should I ask? :P
There is, but you don't need it for this - just use a foreach loop: for(Enemy enemy : enemies) { //Do what you like with enemy } That will loop through each enemy in enemies so you can do what you like with each of them. It's basically an easier way of writing: for(in i=0 ; i<enemies.size() ; i++) { Enemy enemy = enemies.get(i); } You CAN use iterators if you like, but they're more commonly used for looping through things like sets and maps (collections that have no defined order). Foreach loops are a nice quick easy way to loop through an entire collection if you don't need to modify its contents (and most of the time, you generally don't.) When you do need to modify an element then you'll have to either use a for loop or an iterator.
I don't think so, but I did throw it together in less than 5 minutes. What is it?
"This is honestly the easiest game I've ever played on Greenfoot." Not any more... http://www.greenfootgallery.org/scenarios/685 :P OK, yes that's rather sad, I admit it!
The editor actually indents most things for you nicely by default - it's not the nicest thing in the world by any stretch, but for basic indentation rules it works well. So generally speaking, pay attention to it when it makes an indentation. If you're constantly fighting it then chances are you're doing something wrong (or at least non conventional)!
It would - personally I'm not a huge fan of it scattering a thousand windows left right and centre (unless it's changed these days? long time since I've used it.) But yup, any decent image editing program should do the trick (just not MS paint!)
When you get your list, try casting it like the following: List<Enemy> enemies = (List<Enemy>)getWorld().getObjects(Enemy.class); ...and you'll also need to import java.util.List. If that doesn't help then just post the code you get the error for and I'll tell you what's wrong with it!
Hmm, I can't find my Greenfoot one now. You can grab the source for an early version of it at http://mikkle.co.uk/content/auto-indent, but that works for individual text files and not Greenfoot projects. I'll try and dig it out and throw it up somewhere. Use strange variable names? You're not joking :P As for hints, to strip all the old indentation you can use the string.trim() method (removes all whitespace either side of a string.) You can then read it all in with no indentation and spit it out to any file you like with indentation you like :) All I really did was went through the file monitoring various conditions where the indentation should be changed (i.e. looking for { and } and suchlike). I kept a counter of the number of spaces to indent each line, and changed it accordingly when I found a respective line. To do it for a Greenfoot project instead of a Java source file, just loop through all the .java files in the folder and then apply your indentation rule to them individually. I should say though that it's definitely NOT a replacement for learning how to indent properly, merely a tool for making code with ugly or no indentation easier to read through.
It is rather difficult yes, and the problem with the sounds doesn't help because you can't use the laser without an exception being thrown.