Nilom's Forum Posts

  • I'm still having no luck.

    That's the updated version:

    What it should do:

    - Loop through every pixel of the DrawingCanvas

    - Store the pixels rgb value in the temporary variables red, green and blue

    - Then check if these values are within +-5% from another (means, if the color is black-ish, gray-ish or white-ish)

    - If so, check if (red+green+blue)/3 is above 50 (= white_ink +1) or below (= black_ink +1)

    - If the color is not black, gray or white their color proportions will be calculated:

    red_ink will be increased by: red/(red+green+blue)

    green_ink will be increased by: green/(red+green+blue)

    blue_ink will be increased by: blue/(red+green+blue)

    For example rgbEx(100,0,100), which is purple, will increase red and blue by 0.5 each.

    So, but what it actually does:

    - The white color is count correctly if I'm not wrong (if I fill the 800*800 DrawingCanvas with white its about over half a million white pixels)

    - Black is count very weird. If I draw a long white line it will increase the white_ink by about 200-300. If I do it with black color it is only increased by 1-5. Sometimes even decreased (?!).

    - The colored pixels will not be count at all. In the debug mode NaN will be displayed behind them

    .

    What am I doing wrong here? Any suggestions please? :D

    Thank you in advance <3

  • My main problem for now is the math behind it. Finding a suitable formula that can calculate the amount of color used, also considering black and white. The dictionary/array may help with performance later.

    Edit:

    Thats what I have so far:

    I'm not sure yet if that is correct.

  • Hey there!

    For my drawing game I want to get the amount of ink used of each color to draw the picture.

    Therefore, after the picture is drawn I take a snapshot of it and run a loop_x and loop_y with the expressions redat(loop_x,loop_y), greenat(loop_x,loop_y), blueat(loop_x,loop_y).

    For the basic colors it is pretty easy. Let's assume the picture was filled with rgbEx(100,0,0). Then the amount of red ink used would be DrawingCanvas.width * DrawingCanvas.height. Because every pixel inside the DrawingCanvas uses only red.

    But I have a hard time figuring out a formula for mixed colors like rgbEx(77,35,68). I need help finding a formula that evaluates the values in relation to each other.

    For example: If the color values of rgbEx are the same, if they are above 50 the ink used is white, if below the ink used is black. Then there probably needs to be a variance of 5-10%. For example here rgbEx(100,97,98) the values are not the same but the color is still white.

    Some basic rules I must fulfill:

    - The amount of red ink used for rgbEx(100,0,0) must be the same as rgbEx(40,0,0) or the players would never draw in bright colors if it costs them more ink

    - black and white need to be separate ink colors too or it would be free of ink to draw black and the most expensive to draw white (or leave white spaces)

    It was pretty hard to explain and I hope you understand what I'm trying to do here. If you have questions feel free to ask. :D

    Maybe someone has a smart solution or an expression I didn't know.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you. I will do this. I think I will use tween for the scrolling.

  • Hello there!

    Is there a way to right click an item inside a ListBox object? There is only an option to check for left click in the event system.

    Or alternatively is there a way to simulate left clicking? I could check for right click on the ListBox object and then simulate left click to choose the right item in the list (where the mouse right clicked) and then just start the "right click on list" events.

    And if that is not possible either is there a way to see the height of the items inside the list? Then I could use mouse.x, mouse.y, listbox.x, listbox.y and listbox.itemheight (or something like that) to calculate where it was right clicked.

    Thank you in advance!

  • Hey there!

    For my savegame I will most likely use a dictionary to json on local storage. I will need to save about 20-50 variables/values.

    Now I'm thinking whether I should load the dictionaries contents into global variables after loading or just call (get) them from inside the dictionary.

    These will be values like room_id, nickname, settings etc. .

    What are the benefits over one another? I came across this old thread where Kyatric mentions that with dictionaries you can do some "string manipulation". Does anyone have an example for this?

    Thank you in advance!

  • Oh yeah. So simple and I thought way too complicated.

    Thank you it works!

  • Hey there!

    I have a hard time finding a tutorial or an explanation on how I can draw in the DrawingCanvas object if I moved it, say, in the middle of the screen. Or basically anywhere other than x and y 0.

    Expected behaviour: I can just draw in the DrawingCanvas and the pixels will appear exactly where the mouse was.

    What actually happens: If the DrawingCanvas is 100x100 big I need to draw in the area inside x<100 and y<100 even though the DrawingCanvas is at 800, 600 or somewhere else. The lines will appear inside the DrawingCanvas though.

    How do I convert mouse coordinates to relative DrawingCanvas coordinates?

    Thanks in advance!

  • You should really expand the event and object names. Otherwise we can not understand what you are trying to do.

    The else event must be on the same level as its first statement, not below. But we can not see what you want to use the else for.

  • Okay I will do exactly that. Thank you. :)

  • Thank you Ashley and oosyrag for the clarification.

    For now I do not have all of the demanding systems implemented like real time shadows, cone of view limitation, fog and so on. I had these questions beforehand so that I can learn how I use the eventing system efficiently so that I will not need to rewrite later.

    But I see, the code/eventing part is rarely the limiting part.

    Construct's collision cells system means collisions already automatically only check nearby objects

    That is extremely good to know. Makes me worry a lot less about that forest! :D

  • That is actually a great idea! I will test this tomorrow.

    Edit:

    I ended up using a similar approach but with object names instead.

    if InteractiveFamily tapped {
    	if InteractiveFamily.ObjectTypeName = "tree" {
    	}
    	if InteractiveFamily.ObjectTypeName = "door" {
    	}
    	..etc.
    }
    
  • Okay I will use instance variables if someone doesn't come up with a better solution. Maybe there is a simple trick or event call for that. :D

  • There is no difference, the number of collision checks (which you can see and test yourself in debug preview mode) remains the same. As mentioned above, optimize performance by using other conditions to narrow down the number of objects that need checking, by using within distance or is on screen or something similar.

    That was the case in Game Maker. Because the engine would focus on one object to check its collision instead of check all hundreds of objects and their possible collisions. It was recommended to check the collisions of the objects with fewer counts. And if I narrow the objects down with distance or is-on-screen wouldn't that also need the engine to check each objects x and y etc.?

    I would use an instance variable to keep track of the state of the tree (0 for stationary, 1 for falling ect.).

    I did not do that because I assume that the engine would need to check each of the trees instance variables first.

    Use an "Else" event after an is overlapping event to set oacity to 100.

    Wouldn't this set all the trees opacity to 100 every tick? That could cost a massive amount of performance.

    Not familiar with this, but the golden rule is that if you can't measure a difference yourself, its not worth worrying about!

    For now I do not have enough of the gameplay ready for testing the childs performance loss. So I wanted to ask before.

    Thank you for the reply.

  • Oh I didn't know that! I thought if it is not picked all of the other objects are affected. But now I see that if another object is picked instead it behaves differently than that. Great to know, thanks.