Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How Do You Make A Merge Game
- CovidMaster
-
Scratcher
5 posts
How Do You Make A Merge Game
I Want To Make A Cool Merge Game But I Don't Know How To Make The Merging Part. I Will Credit You If You Help.
Last edited by CovidMaster (March 24, 2021 12:56:00)
- cs4207695
-
Scratcher
2 posts
How Do You Make A Merge Game
Can you be more specific? What part do you need help on?
- PizzaAddict4Life
-
Scratcher
1000+ posts
How Do You Make A Merge Game
I can't really help you with all the script, but I could probably help with the merging.
The first thing you will want to do is make sure your sprites are draggable so the player can drag them. If you want to have them drag them add this script into every mergeable block, if not just ignore this part:
The next thing you are going to want to do is make sure you can only merge like-items (like in 2048, you can merge 16 and 16 to make 32, but you can't merge 16 and 8). This part is a little trickier, especially if you are using clones. You need to somehow detect if the other block is the same type. I don't know what you're merging or how you are doing it, but a script like this might work.
I haven't tested it, but it should work. If it doesn't, just mess around with a few things.
Essentially, when the mouse is not clicked and it is touching another sprite, it will detect what level it is, and what it is touching it is. If they match, it will tell the one it is touching to go to the next phase, and then when it does, the original will delete.
You will also need a code that can move up to a new costume when it levels up. If you need that too just tell me.
Oh, one more thing, it is VERY important that the “foo” variable is set to this sprite only. That makes it so that all clones can have a variable.
Also, this really only works when it is 2048 style graphics, so intricate designs won't work as well with this code.
If it doesn't work, you might need to do some tinkering around with it, but I'm here if you need more help.
The first thing you will want to do is make sure your sprites are draggable so the player can drag them. If you want to have them drag them add this script into every mergeable block, if not just ignore this part:
when green flag clicked
set drag mode [draggable v] :: sensing // This makes it so the player can drag it in-game
The next thing you are going to want to do is make sure you can only merge like-items (like in 2048, you can merge 16 and 16 to make 32, but you can't merge 16 and 8). This part is a little trickier, especially if you are using clones. You need to somehow detect if the other block is the same type. I don't know what you're merging or how you are doing it, but a script like this might work.
when green flag clicked
forever
if <<<not <mouse down?>> and <touching color [#7b2613] ?>> and <(foo) = [1]>> then // You are going to need to change the color of each level
broadcast [something v] and wait // it is VERY important that it is "And wait"
delete this clone
end
if <<<not <mouse down?>> and <touching color [#1c2222] ?>> and <(foo) = [2]>> then // You will have to do this for every level you want
broadcast [something v] and wait // it is VERY important that it is "And wait"
delete this clone
end
end
when I receive [something v]
if <touching [mergeableitem v] ?> then
change [foo v] by (1) // This simply detects that it leveled up
end
I haven't tested it, but it should work. If it doesn't, just mess around with a few things.
Essentially, when the mouse is not clicked and it is touching another sprite, it will detect what level it is, and what it is touching it is. If they match, it will tell the one it is touching to go to the next phase, and then when it does, the original will delete.
You will also need a code that can move up to a new costume when it levels up. If you need that too just tell me.
Oh, one more thing, it is VERY important that the “foo” variable is set to this sprite only. That makes it so that all clones can have a variable.
Also, this really only works when it is 2048 style graphics, so intricate designs won't work as well with this code.
If it doesn't work, you might need to do some tinkering around with it, but I'm here if you need more help.

- -Mysticoder-
-
Scratcher
100+ posts
How Do You Make A Merge Game
Hi,
It depends on the graphics that you are trying to do. If you have the blocks all in a grid and you drag them around, then the best way is sorry for whoever has seen me help others before, my favourite array. Basically you could try to make a 2 dimensional array to contain all the values of each tile in the box. If you were to use that, then you can just draw it all out in pen, because it's much easier than cloning, seeing that you have a central database. Hope this helps! If you don't get it, feel free to ask on my PF!
It depends on the graphics that you are trying to do. If you have the blocks all in a grid and you drag them around, then the best way is sorry for whoever has seen me help others before, my favourite array. Basically you could try to make a 2 dimensional array to contain all the values of each tile in the box. If you were to use that, then you can just draw it all out in pen, because it's much easier than cloning, seeing that you have a central database. Hope this helps! If you don't get it, feel free to ask on my PF!
- goldenlion06
-
Scratcher
500+ posts
How Do You Make A Merge Game
I can't really help you with all the script, but I could probably help with the merging.you can change the variables in scratchblocks
The first thing you will want to do is make sure your sprites are draggable so the player can drag them. If you want to have them drag them add this script into every mergeable block, if not just ignore this part:when green flag clicked
set drag mode [draggable v] :: sensing // This makes it so the player can drag it in-game
The next thing you are going to want to do is make sure you can only merge like-items (like in 2048, you can merge 16 and 16 to make 32, but you can't merge 16 and 8). This part is a little trickier, especially if you are using clones. You need to somehow detect if the other block is the same type. I don't know what you're merging or how you are doing it, but a script like this might work.when green flag clicked
forever
if <<<not <mouse down?>> and <touching color [#7b2613] ?>> and <(foo) = [1]>> then // You are going to need to change the color of each level
broadcast [something v] and wait // it is VERY important that it is "And wait"
delete this clone
end
if <<<not <mouse down?>> and <touching color [#1c2222] ?>> and <(foo) = [2]>> then // You will have to do this for every level you want
broadcast [something v] and wait // it is VERY important that it is "And wait"
delete this clone
end
endwhen I receive [something v]
if <touching [mergeableitem v] ?> then
change [foo v] by (1) // This simply detects that it leveled up
end
I haven't tested it, but it should work. If it doesn't, just mess around with a few things.
Essentially, when the mouse is not clicked and it is touching another sprite, it will detect what level it is, and what it is touching it is. If they match, it will tell the one it is touching to go to the next phase, and then when it does, the original will delete.
You will also need a code that can move up to a new costume when it levels up. If you need that too just tell me.
Oh, one more thing, it is VERY important that the “foo” variable is set to this sprite only. That makes it so that all clones can have a variable.
Also, this really only works when it is 2048 style graphics, so intricate designs won't work as well with this code.
If it doesn't work, you might need to do some tinkering around with it, but I'm here if you need more help.
- CovidMaster
-
Scratcher
5 posts
How Do You Make A Merge Game
This Is What I Have So Far.

when green flag clicked
set [ Level] to [1]
create clone of [ Myself]
when I start as a clone
Set Mode To [ Draggable]
switch costume to [(Level)]
show

Last edited by CovidMaster (March 24, 2021 14:05:44)
- ZachTChess
-
Scratcher
33 posts
How Do You Make A Merge Game
Merging part:
when green flag clicked
set drag mode [draggable v]
repeat ()//Add the amount of clones here
add [(id)] to [listid v]//This is for the ID
add [(x)] to [listx v]//This is for the X position
add [(y)] to [listy v]//This is for the Y position
create clone of [myself v]
end
forever
if <<<(x position) = (item ((id)) of [listx v] :: list)> and <(y position) = (item ((id)) of [list v] :: list)>> and <(level) = [1]>> then//This will check if the sprite is touching a clone equal to its level (which is one for now, repeat this for all of your costumes)
switch costume to [ v]//Add the next costume here
end
end
say [Sorry if its wrong :(]
Last edited by ZachTChess (Dec. 11, 2022 12:25:35)
- LucasGamer159
-
Scratcher
1 post
How Do You Make A Merge Game
If this could all be clumped into one script, that would be great.
- Discussion Forums
- » Help with Scripts
-
» How Do You Make A Merge Game








