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

Report as inappropriate.

kamegani
kamegani presents ...

2008/10/5

Spelling Game

Game made as class project.
The goal was to make an educational game, I tried to make something that was fun and educational at the same time: with this game you can even learn some vocab in other languages!

I hope you enjoy =)

6417 views / 20 in the last 7 days

5 votes | 0 in the last 7 days

Tags: game with-source

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

A new version of this scenario was uploaded on Sun Oct 05 04:39:43 UTC 2008
zoviskzovisk

2008/10/7

Pretty good game girl... Makes mine look terribly bad...
kameganikamegani

2008/10/9

Thanks =) It's a pitty its lagging so badly, tho..
mikmik

2008/10/9

Hi kamegani! This is really great work. The problem with the lagging can be fixed. It comes from repeatedly loading images from files, which you should try to avoid. In your 'Letter' class, instead of assigning the images from the file for every new letter, like this image = new GreenfootImage(name+".gif"); try loading the image files only once, and then re-using them. For example, define a static array for all 26 images: private static final GreenfootImage[] images; Then use a static initializer block to load the images: static { images = new GreenfootImage[26]; for (int i=0; i<26; i++) { String name = new String(""+alphabet[i]); name = name.toLowerCase(); images[i] = new GreenfootImage(name+".gif"); } } A static initialiser block is a little unusual: You write it exactly as above before the constructor. It really has no method header. It will be executed exactly once when the class is loaded. You will then have an array with all the letter images. In your constructor, you can then write image = images[i]; thus reusing the images, without loading them from file every time. Another few tips: - for the special items, such as the LargerCatcherItem, which never change the image at all, you do not need to set the images programmatically.In other words: you can get rid of the two lines image = new GreenfootImage("larger.gif"); this.setImage(image); If the class has that image assigned, the objects will just use the class image by default. - Your scenario is slow to load because it is very big. You have two files in your image folder and subfolder which you can delete, named 'thumbs.db'. These may come from your graphics program, or Windows, and they are very big and not needed. - You also have some very large image files. Some images are over 100k, 200k, or even 300k big. You should scale them down before including them, rather than scaling them inside your program. That will save some time up- and downloading your game. Nice work, though. I played it without the lag now, and I like it! Michael
A new version of this scenario was uploaded on Sat Oct 11 06:02:08 UTC 2008
kameganikamegani

2008/10/11

Thanks for all the tips.. =D I implemented the static initializer block as you said, but it's still lagging, just a bit less... Also deleted those thumbs.db. I didn't really know they were there, and they were quite hard to find, actually. About the images that never change, I included that code because when I exported the game, they all changed their pictures to their superclasses' images. I didn't know why, but tried to fix it that way. And I also scaled the largest pictures, but since there are so many of them I couldn't change them all. But it's a big change already, I hope it helps. Thank you again for all the help! Kamila
mikmik

2008/10/11

You're right - the lag is still there. That's strange. When I tried modifying your code, it was also still there at first, but then I exported again, and then it was gone. It was perfectly fine. I am not quite sure why that is right now, but I'll look into it and will try to find out. Your code look fine -- maybe it is a very subtle Greenfoot problem.
mikmik

2008/10/13

Okay, we figured out what the problem is that causes the lag in the game. It is capitalisation of image files. Some of your classes have images names assigned with capitals (e.g. "A.gif") while your image file name on disk uses lowercase ("a.gif"). Sometimes the problem is in the suffix ("smaller.GIF" vs "smaller.gif"). Maybe this happened because you changed the names of the image files after they were set as class images for a class. The Windows file system is case-insensitive, so there it all works. But Java, when reading from jar files (which happens when running in a browser) is case sensitive, so it causes various problems. The fix: Right-click on every one of your classes, select 'Set image', and assign the class image again. This should fix the mis-spelling of the stored class images. Then export again and -- fingers crossed -- it should all work. Michael
qnanqingqnanqing

2008/11/11

nice !!
HermanHerman

2009/5/27

Thank you kamegani, your game is super! And even more attractive because it has some Dutch inside :)

Want to leave a comment? You must first log in.

Who likes this?

tika Herman qnanqing zovisk mjrb4