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

2014/11/26

Maze with colour intersection

AlimMiah1 AlimMiah1

2014/11/26

#
I am working on a project which requires me to create a game that includes a maze. Rather than constructing a maze by creating walls individually, I was wondering, is there a way to create a sub class with the image set as a maze picture which does not allow a character to move across the maze if it intersects with a colour?
danpost danpost

2014/11/26

#
You can create a subclass of World that has the image of the maze; but, for your character to not move across a specific color -- that you would have to program yourself. It would involve a lot of image and color methods..
AlimMiah1 AlimMiah1

2014/11/26

#
Is there anyway you can give some advise on how to code this. Its what I am finding difficult at the moment.
danpost danpost

2014/11/26

#
First, I suggest you review the GreenfootImage and Color class documentations to get an idea of what they have to offer as far as fields and methods (I do not believe you will be dealing with the constructors; but, I it be good to get an idea of what is available as far as them while you are there). Occasionally, you might find a method that returns an Object reference instead of a primitive type (int, boolean, etc.). If you think you might be using one of those methods, you should review the class of the object it returns, as well. For example, in the GreenfootImage class, there is a method 'getColorAt' which returns a Color object reference, which would lead you to the Color class (which you already know you should look at). The only thing other than the images and colors will be locations -- that is, the location of your actor and its image size will determine what area of the background would be in question as far as the colors in the background at any one time.
You need to login to post a reply.