Hello all, I've been trying to make a Bejeweled clone with Scratch. I've gotten a little bit stuck, so I thought I'd come here where people think more technically than they do in scratch's "Help with Scripts" forum.

There is actually one already out, called Bescratched, but it was made with an old version of scratch and isnt nearly as extensible as I want mine to be.

By changing variables, almost every aspect of the game should be variable. I've already programmed variable board dimensions of 1x1 to 60x60. Its not reasonable to play with less than 5x5, and 60x60 isnt so reasonable either, so those are theoretical limits. The amount of gems that you have to line up and how many gem-types are used should also be variable. I've managed to program that part fairly accurately, although it might be possible to fine-tune it.



Notice the slight difference in whitespace around the edges with different sizes. I'm not sure how to fix that, but its not that important at the moment.

So now that I've programmed the resize-able gem-board and selector, I need to start working no the actual game.

I'm trying to script efficiently and effectively - to do as little as possible but do what needs to be done.

The way bescratched works is by checking all possible locations of a row of 3 using 10 different sprites. My goal is to do it with one sprite, only checking the locations that might have a set:



How should I script checking for rows of 3, 4, 5, when applicable or only 3?
I'm not quite sure how to do that.

I would like the same script to be useable for the other checks that need to be done after the gems fall, but how? I would need to keep track of the origin of checking and the direction, and do them one by one, but this could quickly get redundant. I would also need a lot of different lists for that, because scratch doesn't have 2d arrays.

The game board is a list of the gems in order from top left to bottom right, with each type of gem labeled as a number 1, 2, 3 etc;.

What would be the best way to script this? Please post any comments, questions, suggestions, or the like.

I'm sorry if I didnt explain something enough. If something is unclear, let me know and I'll try to explain it.

Also I would like suggestions for themes other than gems.

Thanks!
I think your best bet is just a brute-force approach. Count how many gems there are in a row, and if it's more than three, remove them.

You say it doesn't support 2d arrays, but it does support lists--can the list elements be lists? Because then you'd have a 2D array!
There are mods that can have lists as list elements, but scratch itself cant. I actually did a bit of hacking to get custom list blocks to emulate a 2d list, but it goes a bit out of the way and might be slower than any other method.

You really suggest checking all of the entire board every time anything changes?
No, not the entire board, just the parts touching where you're swapping, and parts touching that if they have the pieces.
How should I keep track of that before removing anything from the main board list?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement