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

2014/7/19

creating a tileable map

1
2
davemib123 davemib123

2014/7/22

#
When I get the Hero to the 'exit' point of the map - how do I get it to read the next portion of the map?
lordhershey lordhershey

2014/7/22

#
I would just keep tabs of where the user was and when the room change happens then I would seek to that portion of the map - or you can set up each room as it's own map and then just read that specific room. Doing it that way make it easier to modify a room.
davemib123 davemib123

2014/7/22

#
This is what I have so far in the Hero class:
private void moveMap()
    {
        CreateMap C = (CreateMap)getWorld();
        if (C.MapLevel == 0 && getX() >= 200 && getY() <= 0)
        {
            C.MapLevel = (C.MapLevel+1); 
            Greenfoot.setWorld(new CreateMap(C.MapLevel));   
        }
        else if (C.MapLevel == 1 && getX() >= 211 && getY() >= 328)
        {
            C.MapLevel = (C.MapLevel-1); 
            Greenfoot.setWorld(new CreateMap(C.MapLevel));   
        }

    }
This is in my World class:
public void addMapSpecificObjects()
    {
        Hero = new Hero();
        if (MapLevel == 0)
        {
            addObject(Hero, 206, 87);
        }
        if (MapLevel == 2)
        {
            addObject(Hero, 211, 312);
        }
    }
How can I get it such that if the player enters from map 1 they get added to the top of map 0 instead of the defined location of 206, 87
lordhershey lordhershey

2014/7/22

#
In the Bezerk game I use a flag that would say which door I was entering from and there would be some defined points. So take the actors exit point, put it on the other side of the screen and add the actor there. You will have to keep the hero's exit point to calculate the entry point of the next room.
danpost danpost

2014/7/22

#
Replace line 12 of the 'moveMap' method with something like this:
CreateMap C2 = new CreateMap(C.MapLevel); // gets reference to new world
C2.Hero.setLocation(/* wherever */); // relocates hero in new world
Greenfoot.setWorld(C2); // sets new world active
davemib123 davemib123

2014/7/22

#
thanks for the suggestions. I've got it done using boolean values :)
davemib123 davemib123

2014/7/28

#
the current array has 22 rows, if I add another 10 lines to it in the second map, how would the hero be able to view them i.e. in the sense of scrolling towards them? Is it even possible? Or do I create a separate map for just the additional 10 lines?
danpost danpost

2014/7/28

#
It would probably be easiest to create a separate map that would include the original 22 rows plus the additional 10.
davemib123 davemib123

2014/7/28

#
Ok that's what I was thinking as well. Thanks for the quick reply.
You need to login to post a reply.
1
2