LoginLogin

Collision detection and data grouping. Help

Root / Programming Questions / [.]

Tiger2Created:
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?

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.

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

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
optionalcomma and the ammount but if you dont put it will assume 1.

Oh, thanks

Oh, thanks
welcs!

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.

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.

Got it