プレイ日記
succ DemonCatursday
How do I setup Arrayds, and what can I use them for?
1そうだね
プレイ済み
返信[1]
親投稿
succ DemonCatursday
Arrays*
0そうだね
プレイ済み
返信[2]
親投稿
mystman12 mystman12
Arrays are basically multiple variables squeezed into one. For example, ARRAY[10,10] can store a value for ARRAY[0,0], another value for ARRAY [O,1], another value for ARRAY [3,7], etc. They can be useful for things like storing map data or lists, for example. You can create an array like this: DIM ARRAY[10,10,10] You can have from one to four elements. (Being the different numbers...
2そうだね
プレイ済み
返信[3]
親投稿
mystman12 mystman12
For example a three element array looks like the one above. A one element array looks like: ARRAY[45]) The numbers you put in each element when dimming determine how many different values will be stored for that element. So, DIM ARRAY [10] can hold 10 different values. Note, *0* counts as a number, so it only goes up to nine. That's still 10 values, but when programming you have...
2そうだね
プレイ済み
返信[4]
親投稿
mystman12 mystman12
to learn how to count starting from 0, instead of 1. So now you can say: ARRAY [0] = 5 ARRAY [1] = 3 ARRAY [2] = 8 ... ARRAY [9] = 9000 Each stores it's own value. The reason arrays are so useful is that you can put variables in place if the elements. So, for example: X=9 PRINT ARRAY[X] Will print "9000". Changing X will allow you to print any other value stored in the array...
2そうだね
プレイ済み
返信[5]
親投稿
mystman12 mystman12
This becomes extremely useful. For example, say you have a 2D, top down RPG. You could store the map data in a two-dimensional (2 element) array, like this: DIM MAP[256,256] Then, after loading each tile into the array, you could check to see what type of tile the player is standing on like this: IF MAP[X,Y]==... If the player was standing at, say, 34X,232Y, the the value stored in...
2そうだね
プレイ済み
返信[6]
親投稿
mystman12 mystman12
MAP[34,232] would be the result.
2そうだね
プレイ済み
返信[7]
親投稿
succ DemonCatursday
Awesome, thanks!
1そうだね
プレイ済み