Gridworld Case Study for AP question

How to change image of rocks/flowers and such

Page 1 of 1

5 Replies - 10298 Views - Last Post: 29 May 2010 - 07:13 PM Rate Topic: -----

#1 Guest_Mike*


Reputation:

Gridworld Case Study for AP question

Posted 21 May 2010 - 01:34 PM

Hi,

In my AP class, we are working on writing our own games. I am using Gridworld (the Case Study for AP classes) as my basis for the game. My game is going to be a mix of the classic arcade game "snake" and the popular online game "BMTron". I have the game pretty much working and it's all going great.

What I need help with is this:

In gridworld, I've found that you can change the image of actors and such by puting a .GIF image with the same name as the class you want it for in the same location.

EXAMPLE:

I wrote a class called SnakeBug. It is located in .../units/AP Comp Sci/Gridworld/SnakeTron
I then made a picture of the snake and called it "SnakeBug.GIF" and put it in the same spot. When I run my game, the snakebug looks like my image.

NOW...
I figured it would be the same deal with rocks and flowers. I know where the classes for those are and where the images are located. I made my own images that I want the rocks and flowers to look like and replaced the Gridworld images with these. They are named "Rock.GIF" and "Flower.GIF" respectively and are in the same spot as the classes.

BUT, it doesn't work. It somehow still has the original images showing despite the fact that I got rid of the originals.


Finally to my question: How do you change the images of Rocks and Flowers? Is it possible?


many thanks in advance,
Mike

Is This A Good Question/Topic? 0

Replies To: Gridworld Case Study for AP question

#2 cmh0114   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 143
  • Joined: 03-January 10

Re: Gridworld Case Study for AP question

Posted 21 May 2010 - 04:33 PM

I had a similar problem when I was working on modifying a part of GridWorld a few weeks ago. I'd modified the class files, but the program was importing the methods from the .jar file that I'd downloaded, not from my modified classes that I'd saved in the same directory. If you haven't already, try recompiling the .jar file that you used, with your modified picture files included.
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12335
  • View blog
  • Posts: 45,443
  • Joined: 27-December 08

Re: Gridworld Case Study for AP question

Posted 21 May 2010 - 04:39 PM

If you save a 48x48 GIF file in the same directory as your class, it should be used as the default image.
Was This Post Helpful? 0
  • +
  • -

#4 mikeLC   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 17
  • Joined: 21-May 10

Re: Gridworld Case Study for AP question

Posted 21 May 2010 - 07:51 PM

(This is me... I didn't sign up before posting my question )



View Postcmh0114, on 21 May 2010 - 03:33 PM, said:

I had a similar problem when I was working on modifying a part of GridWorld a few weeks ago. I'd modified the class files, but the program was importing the methods from the .jar file that I'd downloaded, not from my modified classes that I'd saved in the same directory. If you haven't already, try recompiling the .jar file that you used, with your modified picture files included.


Ok, thanks. I'll try that.

**EDIT**

Ok, when you say "recompile the .jar file", does that mean go into the PATH/CLASSPATH section and re-choose the .jar file? (this didn't work if that's what you ment.)

How do I recompile the .jar? (sorry if this is a stupid question.)


View Postmacosxnerd101, on 21 May 2010 - 03:39 PM, said:

If you save a 48x48 GIF file in the same directory as your class, it should be used as the default image.


thank you, but that's what I've been doing. For some reason it still uses the old images that I deleted.

This post has been edited by mikeLC: 21 May 2010 - 07:55 PM

Was This Post Helpful? 0
  • +
  • -

#5 mikeLC   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 17
  • Joined: 21-May 10

Re: Gridworld Case Study for AP question

Posted 23 May 2010 - 01:58 PM

Don't mean to be impacient or anything, but can anyone answer my question about recompiling the .jar file?

thanks.
Was This Post Helpful? 0
  • +
  • -

#6 mikeLC   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 17
  • Joined: 21-May 10

Re: Gridworld Case Study for AP question

Posted 29 May 2010 - 07:13 PM

Nevermind, I fixed it.

To change the images of rocks and flowers and such, I just created another class outside of the Framework folder and extended it from the source.

i.e.
public class Body extends Rock
{
  private static final Color DEFAULT_COLOR = Color.BLACK;

  public Rock()
  {
    setColor(DEFAULT_COLOR);
  }

  public Rock(Color color)
  {
    setColor(color);
  }
}



then just name the image the same as the class (i.e. Body.gif). It has to be a .gif.

thanks for the help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1