What awesomeNameGuy said will work, but it will require you to keep track of floating point coordinates separately, which can be kind of a pain, especially when you're going to deal with collisions. You could also put a timer in your world class (a public int) that increments every time the act function for the world is called, then you can implement delays in movement for any actor you want easily.
So for the act function of Jumpman, you could have:
public void act(){
if( ((NameOfYourWorld)getWorld()).timer % delay != 0 ){return;}
// your act code
}
Then you can increase the "delay" value to slow the movement speed down and still use the int coordinates built into the actor class.
a) red
b) blue
c) yellow
d) green
Also, to be able to read in dynamic equations, there are several routes you could go. One is to build a simple parser for the the input (which would not be very simple to code probably). The other that I can think of is to implement a drag and drop interface for math operations so that you know for certain what has been entered. For example, to add two expressions, you could have a icon to drag in that has two placeholders for the expressions on either side of the "+" symbol, kind of like so:
2x == () * () -> (2) * (x)
2(x+1) == () * (() + ()) -> (2) * ((x)+(1))
That way, you know what the equation parses to in advance because you force it to behave that way.
The other way I can think of, and probably the easiest is to implement is a parser that uses prefix, function notation. So your equation c for example could be written like so:
subtract( sqrt( abs( mult(x,10) ) ) , 10 );
Of course, that looks a bit messier, but it's one of the easier ways to do it. I hope this was helpful.
Yeah I fixed it. Actually, I had a file not found exception that somehow did not pop up before (I think it was a matter of case sensitivity). Also, calling Greenfoot.setSpeed() in the constructor made it die, but only in the .jar and browser versions.
Is this working for anyone else? It works fine for me when I'm working on it in greenfoot, but it's not showing up on the webpage for some reason. I'm trying to track down the issue.
Nah. I imagine it would probably take under 100 lines to add most of the other levels. Some of them have special behavior though, which would take some extra stuff to get working, but another level in the fashion of the first one would only take the amount of code needed to define the images and enemy locations. It's the enemies that require the most work, since just about every level introduces 1 or 2 new ones, not including the boss.
Does that happen for you when you die in a specific place? The music is supposed to restart, and it does for me, but it might be the format of the sound files that is causing the problem (maybe the bit rate?). I know that a similar thing happens on a friend of mine's computer, but I just attributed it to the fact that he was running linux.
My first greenfoot game. I had to do it for a game design class, but I put a lot of extra effort into it, and would like to improve on it in the future. Any comments or suggestions would be appreciated.
2011/8/30
Donkey Kong Remake
2011/8/26
Grapher
2011/8/12
Lemmings Demo
2011/8/12
Lemmings Demo
2011/5/5
Metal Storm
2011/5/2
Metal Storm
2011/3/30
Evade
2011/2/16
Dolphin Chainsaw Massacre
2011/2/16
HiddenWorld