How do I solve this big problem?

0 favourites
  • 9 posts
From the Asset Store
Jump over the small square and avoid hitting it as long as you can!
  • I have two sprites with the same 15 animations and with 10 frames with images each of them. Some images are the same and some are not and the equal images can be in the same frame number or not. The programa will choose an animation and a frame number randomly for each sprite and before the program spawn the sprite1 and the sprite2, it needs to check if they have the same animation and after that, if the frames have the same image. I already created the system that check the animations but I don't know how to check the frames once the possibilities are so huge.

    For example, imagine that each frame store a image with a number and the program choose the animations below:

    Animation1 = 1 | 5 | 7| 11 | 32 | 56 | 18 | 2 | 42 | 61 |

    Animation2 = 7 | 4 | 0| 11 | 32 | 90 | 20 | 3 | 61 | 11 |

    If the system choose the frame 4 (11) for both animations or frame 10 for sprite1 (61) and frame 9 for sprite2 (61), it needs to choose another frame for both animations automatically. The problem is that I have 15 animations with different combinations. Any idea?

  • You can't compare images data (well, you probably can extract them both to BASE64 string and compare strings, but this will be slow and really a huge overkill). So you need some sort of a database. I have already recommended a few options to you in another post:

    Use CSV for storing these lists of numbers. Load CSV into array and pick random numbers from the array, making sure that 2 numbers are not the same.

    Instead of many animations with many duplicating images, add all images as files to your project, create 2 blank sprites and load imaged into them using "Load Image from URL" action. This will also decrease app/download size and memory usage, especially if your images are big.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can't compare images data (well, you probably can extract them both to BASE64 string and compare strings, but this will be slow and really a huge overkill). So you need some sort of a database. I have already recommended a few options to you in another post:

    Use CSV for storing these lists of numbers. Load CSV into array and pick random numbers from the array, making sure that 2 numbers are not the same.

    Instead of many animations with many duplicating images, add all images as files to your project, create 2 blank sprites and load imaged into them using "Load Image from URL" action. This will also decrease app/download size and memory usage, especially if your images are big.

    Hi dop2000

    Thanks for answering.

    This issue is related to the project that I started when I created the thread you mentioned. All the structure is working because I followed some of your suggestions. Now I just have to fix this particular issue. The problem is that I cannot change the combination of images, the duplicates images and the order of the respective frames because I am defining specific points for each image according to the frame position, and the same image can have a different value depending on the animation in which it is. As the duplicated images may not be in the same frame number, there's no reason for me to use a verification system to check if the frame numbers are the same.

    Although I am using small images I liked your suggestion about using "Load image" but I think it will not solve the problem.

  • Ok, if you have different image points on different sprites, then my second advice about loading images from files will not work.

    But you still need some way to store all this data about each sprite, their animations and images in each frame.

    How else would your game know that frame10/sprite1 and frame9/sprite2 is the same image?

    You need to put this information into an array first and then check this array when picking a random frame.

    You can try Extract image plugin, maybe it will allow to compare two images. Keep in mind though that the images should be 100% identical, even a difference in 1 pixel will produce a different string.

    The only other idea that comes to mind is to use image points to store image number.

    Say, in frame10/sprite1 you create an image point named "ImageNumber61", in another frame "ImageNumber23" etc.

    Then you can use a rather complicated method to determine what image point name "ImageNumberX" is defined in each particular frame. But this is a bad idea and I don't recommend it. Use an array instead.

  • Ok, if you have different image points on different sprites, then my second advice about loading images from files will not work.

    But you still need some way to store all this data about each sprite, their animations and images in each frame.

    How else would your game know that frame10/sprite1 and frame9/sprite2 is the same image?

    You need to put this information into an array first and then check this array when picking a random frame.

    But how can I use the array to check the frames? How to associate the frames with the array values?

  • I suggest SVC - create an Excel spreadsheet with all animations and frames. Save as CSV, import to C2 project, load to array.

    It may look like this:

    Sprite1, Animation1, 1, 5, 7, 11, 32, 56, 18, 2, 42, 61

    Sprite1, Animation2, 7, 4, 0, 11, 32, 90, 20, 3, 61, 11

    ....

  • I suggest SVC - create an Excel spreadsheet with all animations and frames. Save as CSV, import to C2 project, load to array.

    It may look like this:

    Sprite1, Animation1, 1, 5, 7, 11, 32, 56, 18, 2, 42, 61

    Sprite1, Animation2, 7, 4, 0, 11, 32, 90, 20, 3, 61, 11

    ....

    Can I populate the array directly with this information?

    How to compare the frames every time the system picks two random numbers?

  • Use CSV2Array plugin:

    When you select the first random frame, get image number from the array for this frame.

    Then pick the second random frame, get the second image number from the array. If both numbers are the same, repeat the last step. (Using While loop)

  • I thought to use something like this but using a dictionary instead of array but I was trying to find something more practical. Thanks for your help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)