Are you joking with the above method or do you really want me to comment on it? :P
The method will always return false at the moment because it's only used to walk into blocks. If you download it and shift one of the other blocks up a bit (so she walks into the side) then it'll return true and she won't progress any further. Ish. As pointed out earlier it's still a bit buggy when walking to the left!
In terms of indentation - well, yes code should be indented properly but if not, treat it as a challenge ;) Write a little utility that takes the Greenfoot project and rewrites all the source files with indentation of your choosing :) It shouldn't take long, I first wrote mine a few years back (for general source files though not Greenfoot projects) when various people kept throwing source files my way with hideous indentation and asking me what was wrong with them. It's probably been the quickest program to write that's saved me the most time! Yeah it doesn't manage things absolutely perfectly, if lines are split then it doesn't indent them any more than initially (and I'm sure there's other bugs in there somewhere) but it makes things more than readable.
You're welcome to mine if you want it, but it does make a nice little programming task.
oooooh, sorry haha. I thought the method was for the WALL, not the ground object. That method probably needs to be renamed then...
And also, when i write into someone else's code, I usually use odd variables or methods, so i can remember where I edited :)
ALSO, that sounds like a fun challenge. Any tips?
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.
Hey, I'm at school right now, but when I get home I'll do it for you so you can see what it's supposed to look like. Also, watch the Greenfoot tutorial videos for some small examples, OR download a support class and look through 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)!
The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.The cake is a lie.
Portal is awesome ^.^
Oh my gosh stop spamming.
I'm working on a loop for adding ground. But it's not going so well. I did:
for(int i=0; i < 12; i++)
{
addObject( new Ground(), getX() + 40, 442);
}
getX is not in the world class, it's in the actors class.
It's in the actor class because it wouldn't make sense to have it in the world class - getX() returns the x position of an actor when it's in the world. If it was implemented for world, how could it behave sensibly?
In the above loop you need to use the iterator that you've instantiated to set the location of the ground. So replace your getX() + 40 to i*40 and it should work as you planned.
It's not that hard to figure out ;)
The exception reads:
java.lang.IllegalArgumentException: Could not find file: runleft0
Now the last part of this should give you a pretty good idea what's happening, it's looking for a file that it can't find called runleft0. It even gives you a line number to look at in Samus ;) On this line you'll see:
setImage("runleft0");
Hint: You've forgotten to add something to the end of the file name!
"I'm confused about whether you are in the actor class; shouldn't it be getWorld().addObject(etc)?"
The code to initialise objects for the first time (i.e. adding ground and suchlike) will (usually) go in the world's constructor rather than an actor. If the ground was being added from an actor then yes, it'd be getWorld().addObject() - but since it's being created directly from a subclass of world, the addObject method is called directly :-)
A new version of this scenario was uploaded on Sun May 03 01:21:05 UTC 2009
Another suggestion if you're still looking to improve: at the moment when she stops her image (see, i'm getting used to this female thing :P) is often stuck as a "running" one. A simple check to reset the image if neither arrow key is pressed should sort that out easily.
Well, you can use the addObject() method in the world class to add the bullet at a specified location, and you can get Samus' location using getX() and getY()... Should be able to work it out from there!
It sounds like you're thinking about it the wrong way - you probably want to give the bullet an initial direction (which in this case is probably only left or right) and then have the bullet move depending on that initial direction. You could achieve this quite easily by setting a value in the bullet's constructor accordingly.
Well you could - but if you only need bullets to shoot left or right then I'd call that overkill! Unless you want the bullet's doing fairly complicated things then personally that's not how I'd implement it.
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/4/30
2009/5/1
2009/5/1
2009/5/1
2009/5/1
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/2
2009/5/3
2009/5/3
2009/5/3
2009/5/3
2009/5/3
2009/5/3
2009/5/3
2009/5/3
2009/5/4
2009/5/4
2009/5/4
2009/5/4
2009/5/4
2009/5/16
2009/5/16