? Collision detection and data grouping. Help (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Contest results!

Collision detection and data grouping. Help

  • #1 ✎ 76 Tiger2 I have several questions for one thread. First of all, how do I make my sprite stop when it hits bg tiles? Two, how do I use arrays to pack data? For example, in a a dictionary program, the words would be filed with data, but so how do I put it to an array without a being set? That is, in the program if I want to add a word to the dictionary, I don't have to change a million things. Also, how do I make it so the computer automatically puts the words into alphabetical order. And if someone adds a word into the dictionary as they play the program, how can I make it so another data line is added without the person having to mess with the code and find it? Posted
  • #2 ✎ 60 seggiepants Physics, you need to simulate physics one way or another. In basic terms check where you will be after moving. If there is a wall there either stay put in the old position, or clip the movement to the intersecting block. It may help to check the x and y movements separately. SmileBasic doesn't have user defined types. That makes me sad. If it did I would suggest using them for your dictionary. But it doesn't. Instead we will need two arrays one for the key (word) and another for the value (definition). Match them up on index. Fortunately there is a sort command in smileBasic. If you pass a second array to sort it will arrange the second array too keeping them in sync. You can add new data to the arrays with push. If you want to save or modify/add to the dictionary, you don't want to use read/data anymore. You want to load and save to file instead. This means using the LOAD & SAVE commands. Don't forget the TXT: prefix on the filename. This also means saving your dictionary arrays to and from a large string. I would recommend something like a comma separated value file. In fact I might have a delimiter between key and value and a different delimiter between pairs. Just make sure your delimiters are never part of the key or value, maybe filter them out before saving. There is a split function in Lost My Ball if you want to take a look, it should prove useful. Posted
  • #3 ✎ 76 Tiger2 I'm not really familiar with those. I know basics about arrays, but I'm pretty shaky on it. And I don't know how to use TXT files. Neither do I know how to use Push or Pop Posted
  • #4 ✎ 327 random_guy Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies
    I'm not really familiar with those. I know basics about arrays, but I'm pretty shaky on it. And I don't know how to use TXT files. Neither do I know how to use Push or Pop
    with push and pop probably like inc and dec, you increase the number of elements of an array variable, by putting the command and then the variable you want to increase/decrease then comma and the ammount but if you dont put it will assume 1.
    Posted
  • #5 ✎ 76 Tiger2 Oh, thanks Posted
  • #6 ✎ 327 random_guy Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies
    Oh, thanks
    welcs!
    Posted
  • #7 ✎ 1507 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS OSP Contest 2 Winner I won the second SmileBASIC Source OSP Contest! Programming Contest Second Year My account is over 2 years old Website PUSH adds an element to the end of an array, POP removes one element from the end. UNSHIFT and SHIFT do the same but at the beginning of the array instead. Posted
  • #8 ✎ 327 random_guy Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies
    PUSH adds an element to the end of an array, POP removes one element from the end. UNSHIFT and SHIFT do the same but at the beginning of the array instead.
    that too.
    Posted
  • #9 ✎ 76 Tiger2 Got it Posted