#Checking for colours as collision (Another Scratch based one)

28 messages · Page 1 of 1 (latest)

tender roost
#

Here's another difficulty that I'm facing with my converter -- colour based collision. During the early days of Scratch, this was used extensively. But I don't know of a way to do it in Game Maker without causing lag. Worse yet is that there's another block that checks if a colour on a sprite touches another colour too. The sprites are always precise per frame, no exceptions. Is this even feasible?

burnt osprey
#

not by color no. atleast not easily or efficiently

scratch looks like it does this so that you can draw basic shapes as walls, and then check for collisions with that

in gamemaker, you're straight checking those "basic shapes", as objects. obj_Wall can be whatever color it wants, even multiple colors, and you're checking for a collision with obj_Wall.

you can also use parenting to have different objects be the same "category". like if you make obj_tree and obj_rock children of obj_wall, then any collision check with obj_wall will collide with obj_tree and obj_rock too - this is analogous to checking for collision with "red", and "red" can be a red triangle or red star or whatever

tender roost
#

That's the problem

#

What I could do is make an outline of the object for draw_getpixel

#

Using a for loop

burnt osprey
#

getting the color on a surface is a heavy operation

#

checking for color is infeasible

tender roost
#

then sadly a scratch to game maker converter is impossible

#

I could reduce the use of draw_getpixel by stopping execution of the loop once it finds the colour it's looking for

burnt osprey
#

what you can do

#

is use color as a categorization tool

tender roost
#

I'm listening

burnt osprey
#
color_object_groups = {}


color_object_groups[$ "14f833"] = [ instance_1, instance_2, instance_3 ]

if place_meeting(x,y, color[$ "14f833"])
#

something like that

#

maybe

#

whenever you "make a new color"

#

you add it to a category

tender roost
#

I see

burnt osprey
#

and the name of the struct member is the name of the color, as a string

#

lots of data management, making sure the right instances are in the right category

#

and ultimately it boils down to objects

tender roost
#

Sadly I can't split up the colours into separate object

#

The only option is getting colours

#

Worse yet is that it gets the colour directly under the sprite

#

Scratch 1.4 allows you to dive into the source code of the program though, maybe I can get some answers there

#

That wasn't a joke btw

burnt osprey
#

if it is literally colors

https://forum.gamemaker.io/index.php?threads/how-to-get-the-color-of-a-specific-pixel-from-a-sprite.40509/ give this a read

you need to load the sprite onto a buffer, and then start reading off of the buffer to get the colors.

issue is collisions then, since now you're gonna have to write your own custom collision function that loops through multiple object's sprite buffers pixel by pixel to find a match

#

gamemaker's built in collision functions are very very efficient, so not being able to leverage that is a huge loss