#connecting objects togather/ having them affect each other

15 messages · Page 1 of 1 (latest)

granite robin
#

hello, i wanted ask for help regarding a game I’m making (i have not coded in years and this is my first time using gamemaker).

the basic concept is a game where you can customise a drink. an example would be clicking a button/syrup bottle to add more red to the liquid. or 'water' to make it less thick (aka lower the opacity of the liquid )

Ideally the color would increase with a random intensity

so i was thinking one main object in the middle and 'buttons' around it that can affect the object's appearance. in terms of hues, opacity and possibly overlays.

any advice or method one would recomend to make it more efficient

gleaming eagle
#

say your main object is obj_drink

#

you could do something like obj_drink.image_blend = (whatever colour)

#

obj_drink.image_alpha = (whatever opacity)

#

make an overlay sprite variable that it draws on top of itself and then modify that
obj_drink.overlay_sprite = (whatever overlay)

#

should all be pretty easy

#

for colour stuff you can use

hollow magnetBOT
#

With this function you can take two colours and then merge them together to make a new colour. The amount of each of the component colours can be defined by changing the "amount" argument, where a value of 0 will return the first colour (col1), a value of 1 will return the second colour (col2) and a value in between will return the corresponding mix. For example, a value of 0.5 will mix the two colours equally. The following image illustrates how this works by merging the colours red and blue together:

Arguments
col1: The first colour to merge
col2: The second colour to merge
amount: How much of each colour should be merged. For example, 0 will return col1, 1 will return col2, and 0.5 would return a merge of both colours equally

gleaming eagle
#

and then make col2 be merged less to col1 depending on how much liquid youve been adding

#
//obj_drink create
liquid_count = 0;

//button create
col = c_red;

//button leftmb press
obj_drink.liquid_count++;
obj_drink.image_blend = merge_color(obj_drink.image_blend, col, 1 / obj_drink.liquid_count);
#

smth like this

#

you might want to give each button both a colour and alpha

#

ive shown how to merge colours, alpha is easier honestly, just use

hollow magnetBOT
#

With this function you can find the value that equates to the position between two other values for a given percentage. So if you do, for example:

Arguments
a: The first value.
b: The second value.
amt: The amount to interpolate.

gleaming eagle
#

since its just a number