? How does DATA work? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

How does DATA work?

  • #1 ✎ 71 GreedyGoat8 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Avatar Block I didn't change my avatar for 30 days. Website Disguised Hidden Website I’m currently having trouble understanding some areas of the DATA command. I know how title DATA and map DATA works but I don’t know how it works whenever it just a bunch of numbers. I guess it would be easier if I knew the entire definition of DATA(maybe someone could tell me.) Anyway, here’s an example of what I’m not understanding. SPDEF “@SPDATA” @SPDATA DATA 256,80,16,16,8,8,1 DATA 304,80,16,16,8,8,1 DATA 0,256,16,16,8,8,1 DATA ... DATA ... It’s something like that. I was wondering how this worked and was trying to understand it so I could maybe use it in the future. Help is greatly appreciated, thank you. Posted
  • #2 ✎ 98 niconii Video Games I like to play video games! Hobbies Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Drawing I like to draw! Hobbies DATA itself is very simple, it's just a way to specify number or string data that can be read using a variety of commands (READ, COPY, SPDEF, etc.). DATA doesn't care about the format of the data you give it, what the data actually means depends on whatever happens to be reading the data. In other words, if you want to know how SPDEF uses DATA, you need to look at SPDEF's help info. Here's an example of using DATA: RESTORE @MYDATA 'Start reading from @MYDATA READ X 'Read a number from data and set X to it PRINT X 'Prints 123 READ X 'Read the next number PRINT X 'Prints 456 @MYDATA DATA 123,456,789 Note that DATA doesn't care if it's on separate lines or not. These are equivalent: DATA 123,456,789 DATA 123 DATA 456 DATA 789 Posted
  • #3 ✎ 76 kitesinpowerlines Avatar Block I didn't change my avatar for 30 days. Website Avatar Embargo I didn't change my avatar for 90 days Website Avatar Taboo I didn't change my avatar for 180 days Website
    I’m currently having trouble understanding some areas of the DATA command. I know how title DATA and map DATA works but I don’t know how it works whenever it just a bunch of numbers. I guess it would be easier if I knew the entire definition of DATA(maybe someone could tell me.) Anyway, here’s an example of what I’m not understanding. SPDEF “@SPDATA” @SPDATA DATA 256,80,16,16,8,8,1 DATA 304,80,16,16,8,8,1 DATA 0,256,16,16,8,8,1 DATA ... DATA ...
    It looks like you have the correct way to call the @SPDATA label for definitions, but the DATA commands themselves looks like they don't hold enough information for the sprite definitions. SPDEFs need the sprite number, U coordinate, V coordinate, width, height, origin X, origin Y, attribute (optional). You are missing a number. Try this: @SPDATA DATA 0,256,80,16,16,8,8,1 DATA 1,304,80,16,16,8,8,1 DATA 2,0,256,16,16,8,8,1 DATA ... DATA ... The code above adds the sprite number at the beginning (starting with 0). Note that this will override the default sprite template so the default sprites for 0, 1, 2, etc will be whatever sprite you've defined it to be.
    Posted Edited by kitesinpowerlines
  • #4 ✎ 71 GreedyGoat8 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Avatar Block I didn't change my avatar for 30 days. Website Disguised Hidden Website Wow, thanks for the great information you guys! I now have a greater understanding of DATA. I mainly was confused with the “how do you know what to put and where to put it,” but now I pretty much understand. Thanks for the great information. Posted
  • #5 ✎ 1619 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself The correct way to use DATA for SPDEF is: SPDEF @SPDATA @SPDATA DATA 3 'number of definitions DATA 256,80,16,16,8,8,1 'definition 0 DATA 304,80,16,16,8,8,1 'definition 1 DATA 0,256,16,16,8,8,1 'definition 2 Also, don't listen to the manual when it says to use "@SPDATA" rather than @SPDATA, because they're exactly the same thing (In early versions of SmileBASIC, this didn't work) Posted