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

mjrb4's Comments

Back to mjrb4's profile

mjrb4mjrb4

2008/12/24

Chances are you probably are getting that error then, but you haven't got the java terminal window enabled ;)
mjrb4mjrb4

2008/12/24

...but the Debris objects don't have setImage("images/beeper.png"); in their constructor, they rely on the image having been set in the Greenfoot IDE. This is static - it's the same for all Debris objects, so it's only loaded once. If the setImage method were being used, then it would be loaded for EACH AND EVERY Debris object that was created. If you had that line at the beginning of the constructor (as in mik's example that you point to) then yes, there would be a huge pause while all the images were loaded. If you don't believe me, download the source and give it a try ;)
I would guess that BOMBEN is an int variable - the -- at the end of it is equivalent to doing BOMBEN = BOMBEN-1; It's certainly not a comment! It takes one from the value of BOMBEN and it's just a shorthand way of writing the above. Incidentally, you can do the same thing with ++ to add 1. Similarly, you could also do things like BOMBEN += 2; or BOMBEN -= 2; which would add and take 2 from the value of BOMBEN respectively.
mjrb4mjrb4

2008/12/23

Enter should work... That's all I've done anyway. There's two main "blocks" of code that have to be edited in the short scenario. One block is the key assignment, which it sounds like you've done and is specific to the player. The second is then controlling what the rocket does when each of these keys is pressed - and this is common to both rockets. It should show you where each of these bits of code are in the tutorial, or at least give you enough pointers to find them - but no from memory they're not in the same place.
mjrb4mjrb4

2008/12/23

As well as the arrow keys, if you follow the tutorial through you'll see that you have to tell the game what to do when the assigned keys have been pressed - this was something I deliberately kept in. The methods are all provided in the superclass so it's literally just a case of plugging the right ones in the right places, and (I hope!) it should be pretty clear from the worksheet what methods to use. As for why I didn't just use seperate Greenfoot.isKeyDown() statements in two completely seperate objects - in retrospect it would've been easier and therefore perahps better in the tutorial aspect, but the lack of a common superclass would've meant many many lines of duplicated code, which is almost always a bad thing.
Reminds me of bomberman... :)
mjrb4mjrb4

2008/12/22

That's odd, does anyone else get it? The error I get is: java.lang.IndexOutOfBoundsException: X is out of bounds. It was: 1000 and it should have been smaller than: 1000 at greenfoot.GreenfootImage.getRGBAt(GreenfootImage.java:393) at greenfoot.GreenfootImage.getColorAt(GreenfootImage.java:380) at OtherTank.onGround(OtherTank.java:98) at OtherTank.checkFall(OtherTank.java:43) at OtherTank.act(OtherTank.java:21) at greenfoot.core.Simulation.runOneLoop(Simulation.java:200) at greenfoot.core.Simulation.run(Simulation.java:129)
I thought the difficultly of the original was just about right actually, managed to get through it fine after a couple of tries - the jumping was the thing that caught me out initially. Still, good example of how scenarios can be modified to make them a lot easier!
mjrb4mjrb4

2008/12/21

There's always a way ;) I'm not sure it'd be best however - though I guess that's mainly down to personal preference. delmar's suggestions would be good - the green at the bottom seems a bit excess at the moment and (seemingly my most common gripe) because of that it doesn't fit on my laptop screen! Also, if I attempt to move whilst the bullet's moving an error arises - might be something you want to look at!