2D Zelda Scrolling - Please Help

BlitzMax Forums/BlitzMax Programming/2D Zelda Scrolling - Please Help

FBEpyon(Posted 2016) [#1]
Hello,

I'm trying to see if anyone can help me with something?

I'm trying to create a game similar to LTTP, but I'm having a hard time with the level scrolling when going from one zone to another.

My levels are use the standard 2d Array setup with 32x32 tiles per zone with is 512x512 pixels with 16x16 tiles. Some zones can be as big as 64x64 which of course is 1024x1024 pixels with 16x16 tiles of course.

Anyways I have no problems with the smooth scrolling, and things. I just have an issues with unloading first zone well loading and scroll into the next zone (like LTTP zone to zone scrolling).

I have tried loading both zones at once when you hit the trigger, and then scrolling off zone 1 into zone 2, but this isn't working very well or I'm doing something wrong.

I was just hoping that maybe someone can point me in the right direction so I can get this project further than I'm currently at as this is causing a stand still..

Thanks,

FBEpyon


Derron(Posted 2016) [#2]
but this isn't working very well or I'm doing something wrong.


I do not get it: what is your exact problem?


- either have two "levels" updated simultaneously (one scrolling of, one scrolling in)
- or have bigger maps and append one zone to the other, removing the other one as you go

- adjust scrolling speed (eg. with some of the well known "ease in, ease out" etc formulas).


bye
Ron


Midimaster(Posted 2016) [#3]
here is an idea how it can be done. I use 3 zones:
- last zone
- current zone
- coming zone

in my simulation you see a "screen" between 100/100 and 400/400. All 3 zones are drawn, but a check prevents from drawing fields "out of screen". And it checks whether the "last zone" is still visible. In the moment when it is not visible anymore, zone2 becomes zone1, zone3 becomes zone2 and a new zone will be loaded into zone3.

all zones use the same array size, even when they do not use it. An offset defines the distance between the zones.


use the arrow key to scroll to left top, you will see zone1 ("1") leaving, zone3 ("3") coming and when zone1 gets out of screen it will be replaced. now zone 1 contains "2" and zone2 contains "3", zone 3 is free for loading new zone


TomToad(Posted 2016) [#4]
Why even bother with zones? The largest SNES games were only about 6MB in size, you could load the entire cartridge into memory at once on even the lowest end PC system. Unless you intend on making a massively huge world, you might as well load the entire level into memory at once. Even if you do intend on creating a much larger game, you could still probably get away with loading logical areas instead of zones. i.e. load the overworld at start, load castle when character enters gate, load the caves when character enters cave entrance, etc...


FBEpyon(Posted 2016) [#5]
Thanks for the help MidiMaster, it still not perfect, not what I was looking for but it's a good example of loading multiple areas at once.

I had to tweak it a bit because it kept saying load when going back to a zone after you had already left it, but still works as an example.

What I'm trying to do is load one zone and scroll into the other zone well removing the old zone from memory. I know that with modern computers having such large amount of memory it would just be easier to just create one large map with all the zoning on it, but I'm doing procedure generated maps, and would like to just load them in when needed.

Scrolling is also another concern, and thanks Ron for giving me the terms I was looking for..

For those of you that are confused here is a video showing off what I'm trying to do...

https://youtu.be/Z6hjG6MCcZ8?t=1390


Midimaster(Posted 2016) [#6]
My example shows you a way to destroy the old zone! In my sample I connected it with loosing the visibility, but you can also choose any condition to change the zones.

What my sample wants to show is how to delete the old zone and how to add a new zone. I suggested not to delete the old zone immediately, but always keeping 3 zones in memory: old - current - new.


Derron(Posted 2016) [#7]
There is no need to keep "old" in memory.

Once you scroll from "current" to "new", (with "new" being one of 4 options/directions) the old (2 screens away then) could get removed without much worries.

Keep in mind: if enemies can follow you over multiple screens above's thoughts are useless: you then need to keep all zones having "active units" alive (so they can follow your track). Of course you could cheat there too (storing the "time to appear in the current zone" and then displace that unit in the current zone etc.).


Back to your code:

Type TZoneManager - handles all zones (updates the current, switches to next etc)

Type TZone - contains tiles / units whatever


Within TZoneManager.Update() you would update the "current zone": currentZone.Update(). Afterwards you check if the zone has to get left and in which direction the "scroll" has to happen (no direction = fade out / fade In).

ZTone.Update() - checks if the player moves trough a door or so ... and sets "scrollToDirection" and "scrollToZone" accordingly.



Scrolling then happens in a TZoneManager.Draw(): as during "scrolling" no interaction of the user with the world happens (it is like "pausing the controls and movement) you should be able to just adjust "offsets": currentZone.Draw(offsetX, offsetY) - and in that Draw(offsetX:int, offsetY:int) method you draw everything offset by these values.
Of course this is possible for a zone's "Update()"-call too (allowing for "ScreenShakes" or interaction while scrolling.


Do not get above's suggestion as the "perfect one and only" one... there are plenty of approaches to your problem.


bye
Ron


FBEpyon(Posted 2016) [#8]
Thanks Ron - We must be on the same wave length because this is what I named all my types, and had already setup a zonemanager type.

I think my only problem is that I forgot to make it so that Zones control there own scrolling (camera).

I will give that a try and let you all know what happens..

Thanks!


Derron(Posted 2016) [#9]
of course zones do not control the camera/view... they just send the controller (zonemanager) the info that they are getting left by the player...or getting joined by the player (and the location ot the join/leave).

It is up to the boss (zonemanager) what has to be done with that information. That way you could even display 4 little zones on one screen... ans as they fit into the screen, the manager is able to skip "scrolling" at all... if desired so.


The zones only take care of what happens in them. They blindly accept the screenoffset given by the managee. It is a chain of trust.

And the zonemanager eg could again receive limits by the screen or a camera object.


Bye
Ron


Fielder(Posted 2016) [#10]
on 2016 you can build a 65000x65000 world .. without any issue... if you want to change light.. music... sounds.. weather based on a certain area.. just add a second matrix 65000x65000 with some wheater/light/sound flags... .. player.. walk.. and the second matrix can do some changes on visual effects.... or everything you want.,..

(same thing with camera position... or other things)

these thing can't be done 20 years ago.. (too less memory) but TODAY... the only limit... is the IMAGINATION.