? Make maps with DATA! ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Make maps with DATA!

Hi, guys. I know some people had asked a lot about draw maps WITH DATA. If you want to do that, well, YOU are in the right place! Let's get started! First, you'll need to put some arrays. Think like this. DIM BGTABLE[5]'Depending on the number of tiles you want, you will need to put the exact number as the number of tiles you have, but you will need to jump 1 number, otherwise will cause a type mismatch. And we'll need the MAP$ variable. Why? Here is shown. DIM MAP$[6]'You will want to put this, because it stores the number of DATA arrays you want. Then, the AMAZING part is coming out. FOR I=0 TO LEN(BGTABLE) READ BGTABLE[I] NEXT For what use is this? It reads the tiles you have asignned to your map. FOR I=0 TO LEN(MAP$) READ MAP$[I] NEXT And this is for reading the complete map. The complex part is coming out. Get ready! Srry, I'm writing that part, I forgot it, I will edit it soon... Credit to random_god!
Author
the_squat1115
Updated
Rating
0 votes
Categories
Keywords
  • Maps
  • DATA
  • Tutorials
  • Arrays
10 Comment(s) banana banana RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength You can copy DATA to arrays using COPY, with the caveat that if the numbers of elements don't match, it will throw an error. DIM BGTABLE[5] COPY @BGTABLE, BGTABLE END @BGTABLE DATA 1,2,3,4,5 random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements Nice banana banana RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Something worth noting, even if resource is old: 1. I messed up. It's COPY BGTABLE, @BGTABLE 2. You can get away with the caveat by doing something like this: RESTORE @DATA READ ASIZE DIM A[ASIZE] COPY A,@DATA @DATA DATA 3 DATA 1,2,3 3. This obviously won't work with 2D arrays. So you can either use a 1D array and index it linearly like [X,Y]→[X+Y*DIM_Y], or implement your own 2D array reading routine. banana banana RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength [N3NJP3H3] Here's what I said in the comment above but in code and working. random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements Yeah basically my problem with that method is that it's a bit harder to visually see the map in the code, with all of the commas, but that's just a theory me. I like the string array method the most, out of the methods I know. Just my opinion. Anyway yeah, that works. S_DE_Solutions S_DE_Solutions Avatar Block I didn't change my avatar for 30 days. Website Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Please note: Smilebasic create up to 3 different DATA-typ before the Code is execute (like Variable $,%,#). If you type first time %-Values and second time $-values, you only can read this by typing the READ - code(s) in the same order or you get a Error. Of course you have to set the value of DATA after DIM and before you try to read. (Dont forget the Value-limits of $ and % typ ) random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements yes CyberYoshi64 CyberYoshi64 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Great Page Hidden Achievements Thank you for this base, the_squat1115! Maybe I'll be able to revise this so you could have massive maps beyond the 128x127 restriction. I'd need this for my jump'n'run game so I can make massive levels. ———————————————————————— There is a mistake I saw however but I don't blame you as I do this mistake over and over again lol. This would result in Subscript out of range errors because these FOR instructions count beyond the length of the arrays. You need to append -1 to the LEN functions so no crashes will occur. EDIT: My sentence structure goes wring sometimes... random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements yeah, like FOR I=0 TO LEN(BGTABLE)-1 READ BGTABLE[I] NEXT random_god random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements umm ok thas cool