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

2013/10/7

How to create a 4096x3072 Map?

1
2
Cyiaz10 Cyiaz10

2013/10/7

#
Hey guys, iam new here and iam currently trying to create a 4096x3072 Map, but im getting a error which is saying that the space is not enough. Any tips or thoughts ? Thanks in advance ! :-)
bourne bourne

2013/10/7

#
4096x3072 pixels? What are you needing this for? Do you need the entire map drawn? What I would do is have a smaller view size, which scrolls.
Cyiaz10 Cyiaz10

2013/10/7

#
Well, iam making a kind of a RPG with a top-view, known from games like pokemon or such games. I want to make some more Maps with the size of 4096x3072 where u can switch with portals from stage to stage. Whats the max. size you can insert for a background-map? PS: Thanks for your fast answer, very appreciate that :-)
Entity1037 Entity1037

2013/10/8

#
This isn't too terribly difficult... if you know exactly how to do it. First you need a scrolling engine. You can look up how to do that yourself, or take a look at the scrolling superworld scenario that danpost made (although I must admit, it is really laggy). Make sure to find this in the world constructor:
super(width,height,cell size);
and add false at the end:
super(width,height,cell size,false);
This will enable objects to leave the world boundaries and roam freely, which is essential for a scrolling engine. Next, you need to build the map itself. You can either build a level editor which saves the level in a data folder on your computer in the form of java statements that you can copy/paste into your world constructor (or can be in the form of a string which can be read by an algorithm, whichever you prefer), or you can manually type in where every objects goes. You can add objects in the negative range and they will end up to the left/above the world, allowing you to add more objects in the map. Or, if by map you mean an actual map that you use for location reference, you can just have one huge object with the map image that you can scroll around and view. So yeah, that's the basic idea.
Cyiaz10 Cyiaz10

2013/10/8

#
Yeah, if i would know how to do it .. :-) Great, that scrolling engine helped a lot, searched for it since ages but u dont find that much in german and i didnt thought about "scrolling"! What do mean with a level editor? I thought about just making a background-image designed with photoshop were i place every object i need in future, doesen't that work? Or is this exactly what u meant with "manually type in wehre every object goes" ? - I'll try now to get the scrolling working, wish me luck!
Entity1037 Entity1037

2013/10/8

#
You need a level editor to easily create your world. If you just create an image, you won't be able to add any collision detection anywhere, because your walking on top of only one object! Well... I guess you could manually create them with if statements, but that's just tedious (tedious means annoying).
Cyiaz10 Cyiaz10

2013/10/8

#
I never used a level editor(at least i think so), how can i create one? And why cant i detect collisions? - I would create collisionobjects or gameobjects in the actor-class, doesen't that work?
Entity1037 Entity1037

2013/10/9

#
Try using this:
Actor actor = getOneObjectAtOffset(x,y,[insert class name here].class);
with this, you can detect any class' image that intersects the specified offset of the actor this is put in. However, this would take a long time, and would be very tedious (I did this with my second scenario I've ever made, and it turned out too laggy. I would recommend looking up some collision scenarios. There are a lot of them out there (one of which is made by me) that should suffice.
Entity1037 Entity1037

2013/10/9

#
I would recommend making your own collision detection and scrolling engine when you get more experienced, so you can understand how they work. You shouldn't just copy/paste code all the time, because then you wouldn't learn anything! Just wanted to make sure you understand that.
Cyiaz10 Cyiaz10

2013/10/11

#
Collision detections are no problems, only thing is the scrolling part with my background-map/image. This is the main problem iam currently working on, trying to create a 4096x3072 Map with a 1024x768 Window where u can move till u'r atWorldEdge or at a collisions-objekt ill put there(walls). Any more tips how i can realise that ?
danpost danpost

2013/10/11

#
You will probably need a 4 x 4 array for your images. I cannot see this as being anything but laggy, but you will probably have to draw 4 of your images onto the background each frame (at least, while the character is moving).
Cyiaz10 Cyiaz10

2013/10/11

#
U mean splitting the background image in 4 pieces and safe them in an array?
danpost danpost

2013/10/11

#
I guess I was confusing myself with the window and the images. Forget what I said about the array. You just need to keep track of the amount of scrolling that is done. Have a 'scrolledX' and 'scrolledY' field to track the position in the image that goes in the top-right corner of the window and adjust them as scrolling occurs. Each act cycle that scrolling needs to take place, adjust the values and draw the image onto the background image at negative offsets of the scroll amounts. Limit the scroll amount to the size of the image minus the size of the world and zero in both directions (horizontally and vertically). All your actors (except the character that controls the scrolling) should move in the same negative offsets as the amount scrolled on that cycle.
Cyiaz10 Cyiaz10

2013/10/11

#
Oh, like you did in your scrolling-scenario? This is kinda difficult and iam honestly dont really get it how u did that. I just dont find the part where u declear the variables for the size of the seen area of the background-image. Iam rly trying to understand everything, bc copy&pasting is useless, maybe u can teach me how u did this or do u have any easier ways to get me the knowledge to learn this ? :-)
danpost danpost

2013/10/11

#
Well 'getWidth()' and 'getHeight()' gives us the size of the window. And, I believe I used the size of the image used for the scrolling background to determine the size of the 'universe' ('background.getWidth()' and 'background.getHeight()'). These values with the 'scrolledX' and 'scrolledY' values are all you need to determine where to draw the image onto the world background. Yeah, my scrolling scenario is a bit involved in what it does and could be difficult to understand (this is not helped by the fact that I introduce a smaller window for the actor to move within the window -- so more fields to deal with; and took the cellsize into account). I thought I broke the main parts down enough in my previous post, however.
There are more replies on the next page.
1
2