This is indeed quite impressive! I think turning (and possibly movement) could be a bit faster; you could then consider adding a small "skid" as in many 3D games (i.e. pressing forward accelerates, and you decelerate quickly after releasing the key but not immediately).
Very impressive indeed!
I was curious, so I had a look at the source code. One small tip: You can avoid creating a new GreenfootImage in every act cycle, by just reusing and painting over the previous one. That is, instead of
GreenfootImage im = new GreenfootImage(width, height);
do this:
GreenfootImage im = getImage();
im.clear();
You can then also remove the 'setImage(im);' a bit further down, since you are painting directly on the object's image. This speeds up execution by almost 20% on my machine.
Theoretically, you should also move the declaration of your maze array (int[] arr) out of the act method, and make it an instance field. This way, it does not get recreated every time. (In actual fact, this makes little difference because the Java VM optimises this very well and does the same by itself internally. But it's still the right thing to do.) And you can get rid of the setLocation(150, 150); in the act method if you just place it there once initially in the setup.
Great stuff!
I see everybody likes this one,
I'm new to this, so there is a lot that could be optimized, I'm sure. (Those are some good tips Mik)
I'll keep working!
After reviewing the code, I must say: Well done!
Unfortunately, the way you draw 3d means:
-probably no textures
-no looking up
-probably no enemies
In other words: no first person shooters. Still great as a maze game though
If you want, I could give you code to have a mouse-look for left and right looking.
Very nice! The red sphere coed definitely means possibilities for enemies.
A suggestion: if you want to expand this, move the drawing enemy code into a sub function. It would be helpful as well to give your variables meaningful names.
I tried modifying the code to create a mouse-look script. It mostly works, but to perfect it I need to get the Greenfoot window position on the whole screen. Just let me know if you want the code for it.
Perhaps the heading on the front page needs to be changed? :P
"Greenfoot Gallery is a showcase of two-dimensional Greenfoot scenarios (and one three-dimensional scenario) in Java."
Doesn't have quite the same ring though...
Technicaly it is 2d, as there is no dimension in the up/down direction. there is no way to look up or down, and all the information is in a 2d array.
(technicaly its in a 1d array)
I got an image working in your code by replacing this:
im.setColor(new Color(50,50,50));
im.fillOval((int)(x1-l),(int)(150-l),(int)(2*l),(int)(2*l));//only draw if close enough and on screen
im.setColor(Color.white);
im.drawOval((int)(x1-l),(int)(150-l),(int)(2*l),(int)(2*l));
im.setColor(Color.black);
im.fillOval((int)(x1-.5*l),(int)(150-.5*l),(int)l,(int)l);//draw sphere
with this:
GreenfootImage enemy_img_draw=new GreenfootImage("image_name.png");
enemy_img_draw.scale((int)(2*l),(int)(2*l));
im.drawImage(enemy_img_draw,(int)(x1-l),(int)(150-l));
The only problem seems to be that when you get close to it, it crawls, and then eventually errors out. It could be an artifact of the scale method, but I'm not sure. Interested to see how you can use this!
2008/11/9
2008/11/9
2008/11/9
2008/11/9
2008/11/9
2008/11/9
2008/11/10
2008/11/10
2008/11/10
2008/11/11
2008/11/12
2008/11/12
2008/11/12
2008/11/12
2008/11/13