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

mjrb4's Comments

Back to mjrb4's profile

mjrb4mjrb4

2009/5/24

There's two things I'd suggest changing: - It doesn't fit on my laptop screen (height wise) which generally means it won't fit on a lot of laptop screens - what about reducing the height a bit so that it does? - Sometimes the blue arrows appear right on top of you which kills you instantly. What about checking before you add them to make sure that they're not on top of you? Good game though :) Michael
Ignore the System.out.println statement in the above code by the way, you can get rid of that - I had it in for debugging purposes to find out what silly mistake I'd made ;)
Well I've just got a chance to download and look at the source :-) Firstly - very well done on this front! It's good to see things commented nicely all the way through, proper indendation, and all fields set to private, and as a result I could easily navigate my way through your source. These things do make a big difference! Now onto the method of jumping, these are the changes I made to include "smooth" jumping rather than just up and down: - Firstly, make jumpFall a double and initialise it to 0. This will be the amount that we're travelling by vertically. - Next, I changed your checkJump method to: | public void checkJump() | { | if ( Greenfoot.isKeyDown("up") && onGround() ) | { | Greenfoot.playSound ("jump.wav"); | setLocation(getX(), getY()-1); | jumpFall = -5; | } | } This just sets jumpFall to (you can change this depending on how far you want to jump, or put it as a field.) - Finally, I modified your descend method thus: | if ( !onGround() ) | { | Ground g = (Ground)getWorld().getObjects(Ground.class).get(0); | int maxFall = g.getY()-getY()-g.getImage().getHeight()/2-getImage().getHeight()/2; | System.out.println(maxFall); | if(maxFall<jumpFall) { | jumpFall = maxFall; | } | setLocation ( getX(), (int)(getY() + jumpFall)); | } | jumpFall+=0.1; This is probably some of what you tried before - it increments jumpFall by a value (0.1), and if we're not on the ground it moves the tank in the Y axis with the value of jumpFall. However, to stop the Tank sinking into the ground it has an extra bit. We first get the distance between the bottom of the tank and the top of the ground: int maxFall = g.getY()-getY()-g.getImage().getHeight()/2-getImage().getHeight()/2; As you can see, this just involves getting the y position of the ground, then taking away the tank's y position, then taking away half the height of the image's of each of the ground and tank. After we've got this, we can then test to see if jumpFall is greater than maxFall, and if it is we can just set it to maxFall, preventing the tank from sinking into the ground :-) Michael
Another (picky) thing - your timer seems to count down from 60 seconds which is fine, but if you look at the decimal that's actually counting upwards (not down!)
I'm sure I'm attracting bugs today or something similar. Anyway, the scenario is chucking out the following error: java.lang.IllegalArgumentException: Format of sound file not supported: ChompNoise.wav at greenfoot.Greenfoot.playSound(Greenfoot.java:141) at Boy.eatFood(Boy.java:109) at Boy.act(Boy.java:73) at greenfoot.core.Simulation.runOneLoop(Simulation.java:288) at greenfoot.core.Simulation.run(Simulation.java:158) ...basically, it's moaning because the wav file you're using isn't a type supported by java. The easiest way of solving this that I've found is to go into audacity (google for it if you haven't got it already, great free audio editing program), import the sound and then export it to wav using the default settings. I've always managed to get sounds working this way, though some people have reported it hasn't worked. Either way, it's worth a try :-)
I seem to be on bug-moan central today, but if you select a song and start it, then press 4, the instructions appear at the top of the screen. If you then press to go back to the menu you get: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at Beat2.act(Beat2.java:23) at greenfoot.core.Simulation.runOneLoop(Simulation.java:288) at greenfoot.core.Simulation.run(Simulation.java:158) Nice game idea though - when Greenfoot gets better sound support you'll be able to include better quality sound clips :-)
Sure - as an aside, Paint.NET, the gimp and a number of free alternatives work just as well for that - basically anything other than MS Paint ;)
Well, I think I get the problem chinc's describing, sometimes it is difficult to jump when there's lots of holes that have been formed in a row. But every time I've died so far, while that problem was due to too many holes, I'm pretty sure with better positioning on my part I could've overcome the problem and made it across. There MIGHT be situations where it is actually impossible, but I would've thought that could be classed more as a feature than a bug, and it'd probably require a lot of code reworking to fix if it was there at all (note: probably not worth it.) I'll grab the source and have a look at it when I get round to it to see if I can see anything that's wrong and perhaps demonstrate how to include "normal" jumping - I'll post back when I've poked around a bit. While I'm at it, to point out a couple of comments I noticed: "maybe it was a one time glitch? your computer? maybe the scenar just doesn't like you :S" Logical deduction perhaps, but it's very unlikely that it'll work slightly differently on one computer to another due to how Java works - generally the scenario will either work or it won't. You can generally rule that out unless it's a big undisputable thing that's clearly different (like a non-working applet with a huge error message for example!) "I assure you, there are no glitches with the jump or jump distance okay? promise i've tested it so many times. (:" However many times you test something, this never really guarantees that it's completely fault free! One of my friends coded a web mashup the other day, and was absolutely sure it always worked and validated. I loaded it 2 times and there was a big tag floating in the middle of the page, and yup, the HTML that the php script stuck out was indeed invalid. Just one example, and I'm not saying there ARE glitches in your code at all - just be aware that that's quite a bold statement to make!
mjrb4mjrb4

2009/5/23

Bizarre concept yet somehow amusing as well! There's a few glitches with the jumping and the whole game could be smoothed out a bit, but overall not bad at all.