How to detect the color of pixels?

0 favourites
  • 3 posts
From the Asset Store
Vintage steam pixels for your UI! 125 unique assets in a single pack!
  • I'm making an dungeon game, and, for every dungeon level, i need more than 1 pattern to generate dungeons. So, i made 1 sprite that i called dungeon layout, and, he has more than 30 animations. These animations are the dungeon layout, so, in each animation, it has a blue pixel = Walls, green pixel = Traps, and yellow pixel = Chest. My objective is, to detect the color of the pixel and changes it for the designited object. Like, change the yellow pixel to an chest. But, detecting automatically in every animation to make it easier to load a lot of dungeon layouts. ( If you know a better dungeon generator system, tell me too. Like, an random generator without making animations. )

  • to get the colour of a pixel, you will have to use the canvas plugin, paste the sprite to the canvas.

    Then you can use Canvas.redAt(x,y) Canvas.greenAt(x,y) and Canvas.blueAt(x,y) to get the rgb values.

    there are lots of other ways to make maps - load json data, tilemaps, etc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • to get the colour of a pixel, you will have to use the canvas plugin, paste the sprite to the canvas.

    Then you can use Canvas.redAt(x,y) Canvas.greenAt(x,y) and Canvas.blueAt(x,y) to get the rgb values.

    there are lots of other ways to make maps - load json data, tilemaps, etc.

    Thanks bro, it worked but, other ways to make map of dungeons using json or others ways, can you tell me an example?

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