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

Comments for Metroid NES

Return to Metroid NES

mjrb4mjrb4

2009/4/30

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.
BlackholeGFBlackholeGF

2009/4/30

You move a bit slowly don't you?
MuZiKMuZiK

2009/4/30

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?
linish22linish22

2009/4/30

Sorry I haven't been updating. I've been working on stopmotion and I'm working on this now.
linish22linish22

2009/4/30

I was also reading up yesterday but I haven't mastered it yet.
linish22linish22

2009/4/30

Um... can I have your source code organizer? Psst... I'm only 12 years old.
mjrb4mjrb4

2009/4/30

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.
linish22linish22

2009/4/30

I know, I just want to use it to fix Samus' indentation.
MuZiKMuZiK

2009/4/30

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.
mjrb4mjrb4

2009/4/30

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)!
MuZiKMuZiK

2009/5/1

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 ^.^
Shun the spammer :P
mjrb4mjrb4

2009/5/1

Should I ask? :P
MuZiKMuZiK

2009/5/1

Just play portal, you'll get the joke...hopefully.
BlackholeGFBlackholeGF

2009/5/2

Apature science pwns
linish22linish22

2009/5/2

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.
mjrb4mjrb4

2009/5/2

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.
linish22linish22

2009/5/2

Thank you! I have a problem so I'll be updating in just a second. I can't explain very well. I get a terminal.
A new version of this scenario was uploaded on Sat May 02 22:21:48 UTC 2009
A new version of this scenario was uploaded on Sat May 02 22:28:01 UTC 2009
spacebluespaceblue

2009/5/2

I get exceptions when the person walks off the left side
linish22linish22

2009/5/2

I don't know how to fix.
bmyersbmyers

2009/5/2

mjrb4 is correct: should be i*40 for your x-value. I'm confused about whether you are in the actor class; shouldn't it be getWorld().addObject(etc)?
mjrb4mjrb4

2009/5/2

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!
linish22linish22

2009/5/2

duh....
A new version of this scenario was uploaded on Sat May 02 23:45:08 UTC 2009
mjrb4mjrb4

2009/5/3

"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
NintoNinto

2009/5/3

Shouldn't you make it possible to jump while running?
mjrb4mjrb4

2009/5/3

Probably - you only can't at the moment because of a stray "else" that should probably be removed ;)
A new version of this scenario was uploaded on Sun May 03 13:29:59 UTC 2009
A new version of this scenario was uploaded on Sun May 03 13:55:25 UTC 2009
A new version of this scenario was uploaded on Sun May 03 14:00:03 UTC 2009
mjrb4mjrb4

2009/5/3

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.
linish22linish22

2009/5/3

Yes I tryed to do that. But how would I make a bullet create where Samus is when she shoots?
linish22linish22

2009/5/3

I figured out how to do the main positions while not running.
A new version of this scenario was uploaded on Sun May 03 16:54:44 UTC 2009
mjrb4mjrb4

2009/5/3

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!
linish22linish22

2009/5/3

How would I make a method that can be used by my bullet and samus class? For direction?
mjrb4mjrb4

2009/5/4

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.
mjrb4mjrb4

2009/5/4

...or alternatively if that's not what you want, then you'll have to be a bit more specific on what you're trying to achieve!
MuZiKMuZiK

2009/5/4

Uh, I believe the vector support class works for that.
mjrb4mjrb4

2009/5/4

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.
MuZiKMuZiK

2009/5/4

Just speculating here, I haven't actually ever used the vector class :)
A new version of this scenario was uploaded on Sat May 16 17:35:52 UTC 2009
A new version of this scenario was uploaded on Sat May 16 17:36:16 UTC 2009
A new version of this scenario was uploaded on Sat May 16 17:36:41 UTC 2009
A new version of this scenario was uploaded on Sat May 16 19:11:51 UTC 2009
BlackholeGFBlackholeGF

2009/5/16

Now we just need ammo, a slower jump, a firing delay, more enemies, hp, damage, scrolling, items, more levels and it's complete!
mjrb4mjrb4

2009/5/16

Not that much to do then :P