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

2014/4/27

Creating a grid in a non-grid world

1
2
3
4
Zzimon Zzimon

2014/4/27

#
I am trying to create a grid like in the "Wombat" game while keeping a background for it. I am creating a bejeweled like game where-in I'm planning on having a menu on the left side and a little ''Adventure'' style thing running in the top, a lot like the game "10,000,000". My problem is that i cannot find a way to create both of these things. My plan so far is to create a subclass on my primary world so that i can just load the actors in the grid for the bejeweled effect and then have separate worlds for each instance in the game. My idea is to create a world using the 'super(600, 400, 1);' command followed by a 'super(8, 8, 60); ' command, though i can't figure out how to properly implement this.
Zzimon Zzimon

2014/4/27

#
It should look something like this Picture
danpost danpost

2014/4/27

#
You could just create a superclass for the actors that go into the grid (call it 'GridActor') and override the Actor methods to work within the gridded area whose dimensions can be held by static fields within the class (the dimensions of your (8, 8, 60) area. The gridded area could be anywhere within the real world (provided it fits within it) using static fields for the top-left corner real-world x and y values. I will see what I can do as far as a demo for this.
Zzimon Zzimon

2014/4/27

#
A demo sounds awesome. what do you mean with the superclass thing, just making the grid an actor and then making subclasses for the grid? will they then be confined to the grid or does it need something else? Thanks for the response ;)
danpost danpost

2014/4/27

#
Zzimon wrote...
A demo sounds awesome. what do you mean with the superclass thing, just making the grid an actor and then making subclasses for the grid? will they then be confined to the grid or does it need something else?
After a little looking into it, it appears that (1) yes. the grid will be an actor, but (2) the actors will not be subclasses of the grid -- they will be part of a list that the grid will keep track of. (3) the grid will keep its actors confined to it. The actors will be subclasses of a class called 'GridActor' which will be the type of actors the grid will accept in it and it will override the Actor classes methods to transform the pixelated world into a gridded world. The Grid actor will act as a world class for those actors.
danpost danpost

2014/4/28

#
You know what -- I just thought of something! What you are trying to do sounds very much like what my PIP Actor Class support class does. You may want to check it out. BTW, there is even a gridded world in the demo.
Zzimon Zzimon

2014/4/28

#
danpost wrote...
The actors will be subclasses of a class called 'GridActor' which will be the type of actors the grid will accept in it and it will override the Actor classes methods to transform the pixelated world into a gridded world. The Grid actor will act as a world class for those actors.
uhm I don't quite understand this i must say, so the grid is an actor and all the actors that are supposed to be in the grid should just be separate actors? Or how is this supposed to be?
danpost danpost

2014/4/28

#
Zzimon wrote...
I don't quite understand this i must say, so the grid is an actor and all the actors that are supposed to be in the grid should just be separate actors? Or how is this supposed to be?
I would ignore everything I had said before and utilize the PIP Actor class. It takes an inactive world and portrays its visual state in its image. So, actually you are viewing a separate world but through the image of an Actor. Take a look at the demo. It has two separate PIP Actor object showing two different 'inactive' worlds within the active world. I had used one non-gridded world and one gridded world for my demos for the purpose of demonstrating both ways.
Zzimon Zzimon

2014/4/28

#
Haven't really checked it out much yet but this seems to be EXACTLY what i need! :D thank you oh so very much!
Zzimon Zzimon

2014/4/29

#
Ok, so I hit a bump.. my game keeps saying this "at Main_Control.<init>(Main_Control.java:30)" and I simply cannot figure out why, so far I've copied your PIP actor to the letter and I started putting in one of my PIP worlds, the error occurs when I try to compile this script.
danpost danpost

2014/4/29

#
Zzimon wrote...
my game keeps saying this "at Main_Control.<init>(Main_Control.java:30)" and I simply cannot figure out why, so far I've copied your PIP actor to the letter and I started putting in one of my PIP worlds, the error occurs when I try to compile this script.
Looks like you have declared to PIP fields -- 'pip' and 'pip2'. In your code, you assign a value to one of them and then try to add the OTHER one (which is still 'null') to the world. Check your variable names.
Zzimon Zzimon

2014/4/29

#
yep.. just found it myself xD... stupid mistake ^^' I'll make sure to check better next time
Zzimon Zzimon

2014/4/29

#
Another thing, is there a way to undo the mouse-control thingy so i just spawn it fixed in the world? I know the spawn point code section but i can't quite figure out which part does so one can move around the PIP
danpost danpost

2014/4/29

#
Zzimon wrote...
is there a way to undo the mouse-control thingy so i just spawn it fixed in the world? I know the spawn point code section but i can't quite figure out which part does so one can move around the PIP
The code for dragging a PIP object is in the 'act' method of the Major class. The last three 'if' blocks are included and should be headed with a comment saying it controls the dragging of the PIP objects. Just remove that code from your project. You should also be able to remove the three fields that are used for dragging control They are the 'Actor mouseActor', 'int mouseOffX' and 'int mouseOffY' fields.
Zzimon Zzimon

2014/4/29

#
Ok, so now I've gotten to the part of populating the board, I'm intending to put one kind of actor in that will run a random number generator (1-4) or something like that which will in turn spawn some other actors that will then act as the tiles. Do you have any way to stop the first actor from keep spawning tiles when they are occupied?
There are more replies on the next page.
1
2
3
4