I then have the image on the bottom where the player will draw their own pixel art using these little green sprites. What would the best way to check if the drawing on the bottom is the same as the image on the top?
Thanks!
Note: I have a lot of these patterns, so I need a way that is easily copyable for other patterns!
the basic problem is that i believe the sprite is drawn in continuous mode. am i rite?
therefore,ā¦
the problem is more difficult than it looks.
it would have been different if the sprite hook the boxes one by oneā¦
if you are in the first situation:
the most obvious thing that comes to mind is to use the marching squares extension, in order to flip the drawing of the sprites and check the match of the images. i believe itās possible⦠however, it requires well knowledge of the extension⦠which is not exactly within everyoneās reach.
instead,
the tile check sprite by sprite by coordinates should be simpler, but it would limit the freedom in drawing.
edit: or maybe you can check after drawing the grid snap (i mean the grid snap like 32x32) and check if the sprite is drawn by pointsā¦it could works ā¦like repeat for each boxes x times and check if the sprite matches the grid coordinate one by one in a loopā¦problem is that ,as above , it would limit the drawing.
Hi Snowy. You could use read pixel extension. Vars Picture (an array) and Vars checkx and checky and step. and then change Picture[step] to the colours at checkx,checky. with a repeat event for rows inside a repeat for columns which increases checkx and checky and sort.
Then to check if itās right use a ārepeat whileā with the read pixel colour at checkx,checky equal to the colour string in the array Picture[step] as the condition plus step not equal to number of cells in picture+1. This with a sub event repeating for rows and repeat for collumns adding 1 to step and adjusting checkx and checky. Also contains the condition step equals number of cells in picture then picture correct
what you said it surely works, I didnāt suggest it because the last time I tried that method it lagged on a 640x480 grid⦠but itās been a whileā¦maybe things changed
640 times 480 is 307,200 colour checks! - so that will probably still lag, but this looks like being 8 by 8 so 64 colour checks as you can just increase the checkx by the cell width
wellā¦he said heās using boxes so it should be easierā¦
I explained above howā¦or just use petlimpet method swapping the color method with the grid snap with sprite
There is a solution more easy.
If the two matrix have the same size and if you know the number of squares at the start, you can do that;
use a variable with the total number of cases (ex: āTotal Numberā)
then, at each try of the player, if the placement of this last is incorrect, decrease of 1 the variable above. If the placement is correct, donāt do nothing.
if the variable āTotal Numberā is egal to the number of squares then you can be sure that the 2 drawings are the same (you can verify that at every time)
The only difficulty will be to determine the correct (or incorrect) response of the player. For that, i propose to use 2 arrays: the one for the first drawing and the second for the second drawing.
Each array will have to contain by case, 1 number (ex: 1 for a green case, 2 for a black case, etc.)
You must think a little before diving into making your game.
Hi Snowy - Thatās the one! Store the colour value as a string in the array.
I think @Amigo54 is suggesting two arrays and store the object animation index number in the array. So you could use two arrays containing a structure with object x and y value and ani number and compare the two arrays. Storing and comparing the array in the right order is then the tricky bit.
Thereās a few ways to do it. Iām not quite sure what you mean by that. As for which is easiestā¦I donāt know enough about Marching Square to know how easy that is. The one i can picture clearly is the one i came up with ā¦but there might be easier ways to do it!
There are so many possibilities. It makes my head spin.
The top and bottom could be a tilemap. Theh both could be individual tiles. They could be a mix.
You could store the levels in external layouts or save the levels in arrays. Maybe an array of arrays convert to JSON strings.
If itās an array of structures of x, y or columns and rows then you could compare the players objects or grid locations if itās a tilemap.
The challenges are making sure there are enough matches plus the players tiles donāt overlap. Or some other way to make sure a tile is counted as good more than once.
I guess it would be better to check if the solution matched the players drawing and not the other way around. Since the solution wouldnāt have missing or duplicate tiles.
Itās all theory unless I have time to try it myself.
The pixel reader method is also an option if you use an offset for the Y value between the solution and the players board.