2D Map Scrolling

Blitz3D Forums/Blitz3D Programming/2D Map Scrolling

Guy Fawkes(Posted 2012) [#1]
Hi all, I have been working on a small demo on how to make a player stay within the bounds of a map, yet scroll him at the same time the map is scrolling.


I KNOW the map is horribly generated, but right now, I don't care...


Here is what I have so far:





What I need to do is keep the player in the middle of the map while scrolling.


Thanks to all who help! :)


mk2y10(Posted 2012) [#2]
If you wanted the player to remain stationary on your grid then this is what I got:



Guy Fawkes(Posted 2012) [#3]
The player is still not stationary o.o


mk2y10(Posted 2012) [#4]
Do you want the player to remain stationary on the map? or do you want the player to "float" above the grid and remain the the center of the screen?


mk2y10(Posted 2012) [#5]
Oh, it might be due to you having the Arrow keys both control the grid offset and the player's x location.

Try This:


Last edited 2012


Guy Fawkes(Posted 2012) [#6]
i need it for the player to remain stationary on the map, until he reaches the end of the map.


Something like Legend Of Zelda: A Link to the Past


This effect:


http://www.youtube.com/watch?v=FeJqjGE1AIk


Watch 2 minutes of this, and u'll see what I mean. :)


Guy Fawkes(Posted 2012) [#7]
Once he reaches the end of the map, he can't go past the map as well :)


mk2y10(Posted 2012) [#8]
Oh ok, I get it now. I will take a crack at it quick.


Guy Fawkes(Posted 2012) [#9]
Awesome! :) Thank you for helping me, and being patient with me! :) I appreciate it :)


Guy Fawkes(Posted 2012) [#10]
Any luck? :)


mk2y10(Posted 2012) [#11]
Alright, I got it! Had to add a few things, hope that doesn't cause too many problems, but other than that, it is like u wanted it!




Guy Fawkes(Posted 2012) [#12]
it's PERFECT! :) Thank you, MK2V10! =D


Also, is there a way u can get it to load save files, created by editor.bb?


http://www.mediafire.com/?b0i5dp9i3f9qbkb


Here's a link to the media, demo, and source :)


If you can get the game to load the .dat level file, created with editor.bb, then problem solved :)


Thanks again for being so patient with me, and for helping me :) It really means alot :)


mk2y10(Posted 2012) [#13]
Ok, I think this will work... you just need to edit the name of the file to load and make sure the LoadAnimImage is pointed to the right image. Let me know how it goes, it worked on my end.



Last edited 2012

Last edited 2012


Guy Fawkes(Posted 2012) [#14]
This line, it says: " Expecting )' " :


mapdat(X,Y)=ReadInt(FI)


mk2y10(Posted 2012) [#15]
I fixed it, it is up in the previous post!


Guy Fawkes(Posted 2012) [#16]
Ok, now it's saying "Array index out of bounds" even though I used the level editor o.o


Code:





lvl1.map:


http://www.mediafire.com/?8s6kcycu9757nla


line it's doing this at:







Thanks Mk2v10! :)


Guy Fawkes(Posted 2012) [#17]
I hope I'm not missing anything :) If I am, let me know! :) Thanks again! :)


mk2y10(Posted 2012) [#18]
Try this, if that doesn't help the something is up with the file?



Last edited 2012


Guy Fawkes(Posted 2012) [#19]
CRAP! I gave u the wrong level editor code... My bad! >< Here's the one I need it to read:


http://www.mediafire.com/download.php?wyvhe1cefejxnl8


Thanks, Mk2v10! :)


mk2y10(Posted 2012) [#20]
K, I adapted it, hope there are no errors!




Guy Fawkes(Posted 2012) [#21]
GAH! Crap! >< It's still saying index out of bounds... Is there any way to make it stop doing that particular error?





Thanks Mk2v10! :)


mk2y10(Posted 2012) [#22]
Wow, that i'm not sure. The sizes are fixed, and the maximum size of the values are 1000 by 1000! Idk what is causing that.


Guy Fawkes(Posted 2012) [#23]
Here, perhaps ripping the file open will help u to see its true format :)





Just draw a quick map, and press F1 to both save and SUPER save :)


the file saves as: map1_decrypted.map :)


Thanks again! :)

Last edited 2012


Guy Fawkes(Posted 2012) [#24]
The problem is in the Load() function


mk2y10(Posted 2012) [#25]
Oh, the other function I made only to support Save, not super save. You might want to use save because it takes up less memory and is allows a more simple read. Try loading just a saved map and not a super saved. That might be the problem.


Guy Fawkes(Posted 2012) [#26]
No. I added that function so YOU could see what's going on with the map :)


I'm not trying to load it with supersave(). I'm using regular save() & regular Load() :)


mk2y10(Posted 2012) [#27]
Oh lol, srry, i did not go to bed yet lol


Guy Fawkes(Posted 2012) [#28]
Lol, np :P


Guy Fawkes(Posted 2012) [#29]
Ok, so... If the array is out of bounds, obviously, some value that ur using, is greater than the max allowed value o.o with the map size being 1601, I wonder, I wonder o.o


Guy Fawkes(Posted 2012) [#30]
Can anyone help us out on this array out of bounds problem, please? It would be a GREAT help! :)


Thank You Mk2v10, & everyone for their help! :)


Guy Fawkes(Posted 2012) [#31]
Also, here's another small problem I noticed, I changed Dim Map$(1000,1000), to: "Dim Map(1000, 1000)", cuz it was trying to return a string, when it should be returning an integer :)





This is what I have so far :)


Guy Fawkes(Posted 2012) [#32]
Here's what it returns for both for loops & debug mode:




Last edited 2012


mk2y10(Posted 2012) [#33]
Did you find out the problem? And hey, you inspired me to start an API for grid control and drawing! I will post a link to it, but I will not post in on here (because I will be updating it as I go.)

Check it out here:
http://projectoutcast.forumup.com/viewtopic.php?p=24&mforum=projectoutcast#24

Oh, and don't mind the site being empty, I am just starting it, but feel free to join if you like.


Guy Fawkes(Posted 2012) [#34]
<3 U ROCK! I'm GLAD I could inspire u! =D In return for ur help, I will GLADLY join! :) Help me out some more, and lets see if I can't get u more members ^_~


And yes, I did.. But now it's buggy again ><


Midimaster helped me on it some, to reduce the amount of lines, but now it's just messed up ><


Here's the code:





It hates me


><

Last edited 2012