maxdoss wrote:
Can anyone tell me how to detect which blocks are which and how placing block's would work.
I think what most people use is an array of the blocks...or a list that can be displayed in two dimensions. This can be done using either letters or a little math. Then, depending on your block size, wherever your player is, divide both the x and the y by the block dimensions and round it...you might also have to offset it by a number so that it gets the right placement for the blocks...hope that at least helps some...if not, let me know.
Offline
AtomicBawm3 wrote:
maxdoss wrote:
Can anyone tell me how to detect which blocks are which and how placing block's would work.
I think what most people use is an array of the blocks...or a list that can be displayed in two dimensions. This can be done using either letters or a little math. Then, depending on your block size, wherever your player is, divide both the x and the y by the block dimensions and round it...you might also have to offset it by a number so that it gets the right placement for the blocks...hope that at least helps some...if not, let me know.
what about how to detect which blocks are which
Offline
The list. You create a list as the world generates (yours does right?) and use the grid snap thing to determine which list item to use to determine what block it is, and it's midnight time and whatnot
Offline
zubblewu wrote:
The list. You create a list as the world generates (yours does right?) and use the grid snap thing to determine which list item to use to determine what block it is, and it's midnight time and whatnot
That doesn't make sense to me.
Offline
1s1sKing wrote:
well, as a world is generated add the block yo a lis (air counts yo). Use the mouse coordinates on the grid to find which item youd be editing.
That doesn't make sense.
Offline
maxdoss wrote:
1s1sKing wrote:
well, as a world is generated add the block yo a lis (air counts yo). Use the mouse coordinates on the grid to find which item youd be editing.
That doesn't make sense.
1. Use a variable list to label block IDs.
2. Use your imagination to cycle through blocks
3. Click on air (0 ID)
4. ???
5. Profit
Offline
You store the world as a long list of numbers. Each blocktype is a different number. For example, air might be 0, mud might be 1, stone might be 2. When the mouse is clicked, you use a grid snap to determine which square it is touching. Then, you use some math to locate the item in the list that corresponds to that location onscreen. You check the value of that item to determine what the value of the block is.
Hope that helps.
EDIT: I just remembered that I made a long post about something like this awhile ago. Here's the link to the the post.
Last edited by amcerbu (2012-07-15 03:15:59)
Offline
amcerbu wrote:
You store the world as a long list of numbers. Each blocktype is a different number. For example, air might be 0, mud might be 1, stone might be 2. When the mouse is clicked, you use a grid snap to determine which square it is touching. Then, you use some math to locate the item in the list that corresponds to that location onscreen. You check the value of that item to determine what the value of the block is.
Hope that helps.
EDIT: I just remembered that I made a long post about something like this awhile ago. Here's the link to the the post.
That doesn't make any sense to me at all.
@DonutCannon that doesn't make sense either.
Last edited by maxdoss (2012-07-17 00:10:37)
Offline
I'll try to explain again. You store the data for the world in a list. Each item of the list stores a number that represents a block. The value of each item is the type of the block. You can imagine it this way: if the world grid was 15 x 20 blocks, you would label each block with a number, going from top left to bottom right. That number would be the item number of the list that corresponded with the appropriate block on the screen.
Numbers represent the location of each tile type in the LevelData list. For example, "127" means that item 127 of list LevelData would occupy the spot at the 9th column and 7th row. 001 016 031 046 061 076 091 106 121 136 151 166 181 196 211 226 241 256 271 286 002 017 032 047 062 077 092 107 122 137 152 167 182 197 212 227 242 257 272 287 003 018 033 048 063 078 093 108 123 138 153 168 183 198 213 228 243 258 273 288 004 019 034 049 064 079 094 109 124 139 154 169 184 199 214 229 244 259 274 289 005 020 035 050 065 080 095 110 125 140 155 170 185 200 215 230 245 260 275 290 006 021 036 051 066 081 096 111 126 141 156 171 186 201 216 231 246 261 276 291 007 022 037 052 067 082 097 112 127 142 157 172 187 202 217 232 247 262 277 292 008 023 038 053 068 083 098 113 128 143 158 173 188 203 218 233 248 263 278 293 009 024 039 054 069 084 099 114 129 144 159 174 189 204 219 234 249 264 279 294 010 025 040 055 070 085 100 115 130 145 160 175 190 205 220 235 250 265 280 295 011 026 042 056 071 086 101 116 131 146 161 176 191 206 221 236 251 266 281 296 012 027 042 057 072 087 102 117 132 147 162 177 192 207 222 237 252 267 282 297 013 028 043 058 073 088 103 118 133 148 163 178 193 208 223 238 253 268 283 298 014 029 044 059 074 089 104 119 134 149 164 179 194 209 224 239 254 269 284 299 015 030 045 060 075 090 105 120 135 150 165 180 195 210 225 240 255 270 285 300
EDIT: Here' s a project Hardmath123, applejack, and I made where the level is stored in a list. All the physics/sensing is done with math, by checking the player's position and the values of the items in the list (no color/sprite "touching" blocks were used). Hope that helps. http://scratch.mit.edu/projects/amcerbu/2437350
Last edited by amcerbu (2012-07-17 01:33:57)
Offline
amcerbu wrote:
I'll try to explain again. You store the data for the world in a list. Each item of the list stores a number that represents a block. The value of each item is the type of the block. You can imagine it this way: if the world grid was 15 x 20 blocks, you would label each block with a number, going from top left to bottom right. That number would be the item number of the list that corresponded with the appropriate block on the screen.
Code:
Numbers represent the location of each tile type in the LevelData list. For example, "127" means that item 127 of list LevelData would occupy the spot at the 9th column and 7th row. 001 016 031 046 061 076 091 106 121 136 151 166 181 196 211 226 241 256 271 286 002 017 032 047 062 077 092 107 122 137 152 167 182 197 212 227 242 257 272 287 003 018 033 048 063 078 093 108 123 138 153 168 183 198 213 228 243 258 273 288 004 019 034 049 064 079 094 109 124 139 154 169 184 199 214 229 244 259 274 289 005 020 035 050 065 080 095 110 125 140 155 170 185 200 215 230 245 260 275 290 006 021 036 051 066 081 096 111 126 141 156 171 186 201 216 231 246 261 276 291 007 022 037 052 067 082 097 112 127 142 157 172 187 202 217 232 247 262 277 292 008 023 038 053 068 083 098 113 128 143 158 173 188 203 218 233 248 263 278 293 009 024 039 054 069 084 099 114 129 144 159 174 189 204 219 234 249 264 279 294 010 025 040 055 070 085 100 115 130 145 160 175 190 205 220 235 250 265 280 295 011 026 042 056 071 086 101 116 131 146 161 176 191 206 221 236 251 266 281 296 012 027 042 057 072 087 102 117 132 147 162 177 192 207 222 237 252 267 282 297 013 028 043 058 073 088 103 118 133 148 163 178 193 208 223 238 253 268 283 298 014 029 044 059 074 089 104 119 134 149 164 179 194 209 224 239 254 269 284 299 015 030 045 060 075 090 105 120 135 150 165 180 195 210 225 240 255 270 285 300EDIT: Here' s a project Hardmath123, applejack, and I made where the level is stored in a list. All the physics/sensing is done with math, by checking the player's position and the values of the items in the list (no color/sprite "touching" blocks were used). Hope that helps. http://scratch.mit.edu/projects/amcerbu/2437350
Yeah.... I don't get that at all..........
Offline
Ok, lets think this through again.
Say we have a 3x3 grid for our minecraft game. This is what our first variable list would see it as:
0 1 2
3 4 5
6 7 8
We, of course will end up seeing these numbers as blocks.
The numbers are kinda arranged like the buttons on a phone, except 9 keys, and starting with 0.
0 is set to, for example, x-1 y1. 1 is set to x0 y1 and so on.
So, we have our data set, but nothing is happening to it. All it's doing is saying that those blocks are in a specific location. Nothing is saying what block it is. It is all air. This is where our second list comes in:
0 0 0
0 0 0
0 0 0
Pretty bland, eh? It's all air blocks. Let's set our blocks to stone(1) and grass(2).
2 2 2
1 1 1
1 1 1
The way this is done is by clicking on an air block. This broadcasts a signal (whatever block you clicked on) to the blocks. The blocks then take our selected material to it and replaces the block you choose with that.
2 2 2
1 3 1
1 1 1
Okay, but now all we see is air, still. So we set it so that the second list displays to the selected locations specified by the first list.
Now we can see our creation! But where are we getting the blocks? Our third list:
air
stone
grass
diamond ore
This is used to switch the costumes of the blocks and so it knows the names of the costume. Order it the way you want your blocks ordered. Also, make it so when the blocks signal for a costume, add 1. Why? Air is 0. But there is no costume 0. So air is costume one. Stone is 2 instead of 1, etc.
That's about it.
Offline
What parts don't make sense to you? That might help us explain.
Offline
AtomicBawm3 wrote:
What parts don't make sense to you? That might help us explain.
Just about everything I don't understand.
@DonutCannon How would you do that with a randomly generated world, and I still don't get it.
COULD SOMEONE POST THE SCRIPTS?
Offline