? 2 short questions, BGPUT 2, and DIM L0[0,0] (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

2 short questions, BGPUT 2, and DIM L0[0,0]

  • #1 ✎ 9 Jack_Akkiarto Hello, i have 2 short questions: 1.) Why can't i use BGPUT 2,0,0,5 to put a Tile in the second Layer? If i only write this line in a new program, i get an error, but if i replace the 2 with a 1 it works fine for the 1st layer. 2.) If i write DIM L0[0]:PUSH L0,7 ,the push function works fine, but if i use DIM L0[0,0]:PUSH L0[0],7 ,i get an error, can somebody tell me how to use push in a 2-dimensional array? Thanks for every help Posted Edited by Jack_Akkiarto
  • #2 ✎ 477 SquareFingers PUSH only works on one-dimensional arrays (and strings). 2D arrays in SmileBasic are rectangular, not 'jagged', so even in principle, there's no way (in general) to push a single value to a 2D SmileBasic array. I don't know BGPUT, I'll leave that question for someone else. Posted
  • #3 ✎ 9 Jack_Akkiarto Thanks for the fast answer, but can you also tell me if there is a way to make a 2-dimensional array bigger after i created it? Posted
  • #4 ✎ 1551 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website There is no way to resize 2/3/4-dimensional arrays, other than loading from a DAT file. You can't resize a 2/3/4-D array in place, but what you can do is something like: DIM ARRAY[10,10] 'make original array DIM NEW[11,10] 'create new array. You can only easily resize the FIRST index COPY NEW,ARRAY 'copy data to the new array ARRAY=NEW 'replace original array with new array. the BGPUT won't work because you're using XSCREEN mode 2 or 3, which assign BG layers 0 and 1 to the top screen, and 2 and 3 to the bottom screen. You have to use DISPLAY to switch to the lower screen, or you can change the number of layers on the upper screen with optional arguments to XSCREEN. Posted Edited by 12Me21
  • #5 ✎ 9 Jack_Akkiarto Thank you very much, that was really helpful and solved the problems. Posted
  • #6 ✎ 203 JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself
    1.) Why can't i use BGPUT 2,0,0,5 to put a Tile in the second Layer? If i only write this line in a new program, i get an error, but if i replace the 2 with a 1 it works fine for the 1st layer.
    If you have activated the bottom screen with XSCREEN, sprite and BG elements were divided amongst the two screens evenly. This means that BG layers 0 & 1 are on the top screen, and 2 & 3 are on the bottom screen. Check the help menu for XSCREEN to solve your issue. EDIT: lol 12Me21 already answered this
    Posted Edited by JustGreat