Nilom's Recent Forum Activity

  • 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.

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.
    }
    
Nilom's avatar

Nilom

Member since 26 Dec, 2019

Twitter
Nilom has 1 followers

Trophy Case

  • 4-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

9/44
How to earn trophies