How do I get my colour mixing game to work

0 favourites
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • Hello again, guys.

    I figured I should post my work in progress question as I'm having quite lot of problems with it.

    I'm very new to Contruct and programming in general, having only been experimenting for a couple of weeks now.

    Would you lovely people have a look at this:

    (URL edited after confusion in following posts)

    The basic idea is to grab one of the little coloured box characters and drag it to the blue 'den'. The graphics are a little work in progress too, so forgive me.

    After dragging TWO coloured blocks into the den, I want them to mix in RGB format.

    This is where I've come unstuck.

    I just don't know how to do it.

    As you can see, by looking at the code, I have an array that stores the 'tint' values of each of the blocks onscreen.

    It's not finished yet, but I really don't know where to go next.

    Grabbing the three values of RGB from the array and adding them to the other block in the den, simply colours that block the same colour!

    That's not right.

    I've also realised that my way of doing things isn't gonna work well because I'd be left with only 4 combinations!

    Once I've added the red, green and blue, I'd be left with white and each array element would be 100. Therefore, no where else to go.

    I hope someone can help me out with this.

    It started as a simple idea in 'coloured block collecting' and ended up much more of a challenge that I envisaged.

    Also, is my programming ok? Can it be cleaned up at all?

    Like I say, I've very new at this and what you see here is two weeks or so of learning.


  • I cannot open it. You need to save the project as a single file if you want to share it. The extension has to be .capx.

  • Oooops, sorry.

    I think it's there now.

    First time I've done this so.....

    Anyway, it should be there now.

  • What am I supposed to do? Nothing is happening when I run the project, I only see the layout but that's it.

  • I have no idea what happened there. I've just run what I uploaded and it was just wrong!

    I've tried again and tested it this time. It's ok now.

    Basically, the idea is to grab one of the coloured blocks and drag it to the large pale blue square. This will eventually be the 'combining den'.

    Grab another and drop it to the same place.

    Press the 'combine' button and the two coloured blocks should mix together after a short wait.

    The combing isn't working as planned and so I've put this post on the forum in the hope I may get some help or better way of accomplishing what I set out to do.

  • Your events look a little complicated so I've made a new event sheet with how I would do it and you can tell me if this is what you wanted to do or not.

    I've made a new event sheet, if you want to use yours, just change back the event sheet that the layout uses.

    I've tried to make what you described, you can drag the blocks into the den and when you press spacebar (the button wasn't working for me) they get destroyed and a new block appears with the combined tint values of the previous blocks.

    Also, Construct 2 already has a system to save/load, just use the save or load actions: ... -savegames

  • Where can I download your changes?


  • I forgot to upload it.

  • Wow, that is impressive. Your solution is so much more compact than mine!

    The combinations of coloured blocks works very well but still leaves me with a problem of what would be considered a short-coming in my original idea.

    How, for example, does one make pink?

    There's definitely very few combinations that one can achieve, especially considering how each RGB value has 0 to 100!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can make pink by combining the red and blue. Red = 100, Blue = 100

    You can modify the tint values at the editor and see the results in real time, it will give you a better idea what values you need.

  • Red and blue make magenta.

    My problem is, when two cubes are put into the den, their tints are effectively added to the other cubes tint.

    To make pink, one would have to subtract a value from the red block. Not add.

    I know there are many combinations to Red/Green/Blue but, having not thought the game through enough, I realise it can't be written! If colours are only added, the values of each blocks tints do not go down.

    A random element would have to be added, but that detracts from the original idea of using colour combinations to make others.

    I want to that you for all your help, Xavier. It was your quick programming skills that have led me to the conclusion that I may well be barking up the wrong tree with this one.


  • You probably need to convert to LAB first, do the average, and then convert back.

    Ref: ... javascript

  • Thanks for those links.

    It seems I'd have to convert from RGB to XYZ to LAB, average, then convert back.

    I wouldn't have a clue how to apply those formula though.

    Thanks for the help though, it made for an interesting read.

  • You're welcome and you're right about RGB being an additive format for producing colors. For real life color mixing you'll need the Lab Colour Space format blackhornet mentioned. It doesn't sound like an easy task, at least for me, and it probably involves formulas or complicated expressions.

    It could also be added as a plugin with Construct 2 SDK if someone wanted to do it.

  • Here. I've bookmarked the key events that convert the first sprite, the seconds sprite, the Average calculation and the final Tint on the third sprite.

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