? Make maps with DATA! ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Migrating to a new website for SmileBASIC 4

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! Finally... To render the map, we will use this code: DEF MAPRENDER FOR I#=0 TO LEN(MAP$)-1 FOR J#=0 TO LEN(MAP$[I#])-1 BGPUT 0,J#,I#,BGTABLE[(ASC(MID$(MAP$[I#],J#,1)))-48] NEXT NEXT END This is used to recompile the ASCII map and translate them to BG tiles. And, as the (pre-)final step, we will write the custom functions after we made the scripts. MAPREAD [number of the map to read] MAPRENDER Now, you will want to make your ASCII map, now, how the format is used? @MAP_0X'Label of the map to read and translate. NOTE: the “X” shown is a number of the map to use. DATA X'The ”X” is for the BG definition number to use. EXAMPLE: DATA 9'1 DATA "XXXXXXXXXXXXXXX"'Same as the DATA number to use. Read example above. I actually don’t know if you (the reader) understood what I wanted to mean on the example above. Credit to rando!
Author
the_squat1115
Updated
Rating
0 votes
Categories
Keywords
  • Maps
  • DATA
  • Tutorials
  • Arrays
10 Comment(s) hakke hakke RNG Hidden Easter Eggs QSP Contest 2 Contest Participant I participated in the second SmileBASIC Source QSP Contest! 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 rando rando 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 Avatar Taboo I didn't change my avatar for 180 days Website Nice hakke hakke RNG Hidden Easter Eggs QSP Contest 2 Contest Participant I participated in the second SmileBASIC Source QSP Contest! 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. hakke hakke RNG Hidden Easter Eggs QSP Contest 2 Contest Participant I participated in the second SmileBASIC Source QSP Contest! 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. rando rando 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 Avatar Taboo I didn't change my avatar for 180 days Website 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 Taboo I didn't change my avatar for 180 days Website First Year My account is over 1 year old 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 ) rando rando 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 Avatar Taboo I didn't change my avatar for 180 days Website yes CyberYoshi64 CyberYoshi64 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 Night Person I like the quiet night and sleep late. Express Yourself 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... rando rando 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 Avatar Taboo I didn't change my avatar for 180 days Website yeah, like FOR I=0 TO LEN(BGTABLE)-1 READ BGTABLE[I] NEXT rando rando 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 Avatar Taboo I didn't change my avatar for 180 days Website umm ok thas cool