Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Can't check for collisions or overlaps between groups #269

Closed
quinton-ashley opened this issue Oct 10, 2023 · 0 comments
Closed

[bug] Can't check for collisions or overlaps between groups #269

quinton-ashley opened this issue Oct 10, 2023 · 0 comments

Comments

@quinton-ashley
Copy link
Owner

quinton-ashley commented Oct 10, 2023

My documentation has always stated that checking collisions or overlaps between groups works, but it seems I forgot to implement this?! I checked past versions of p5play to see if this was a regression but it's not. 馃憖

Probably the most long standing bug in p5play. No one ever reported it either... can't believe it.

Top priority to fix!!

new Q5();

new Canvas(400, 400);

let a0 = new Group();
let s0 = new Sprite(100, 100, 50, 50);

let b0 = new Group();
let s1 = new Sprite(300, 300);

a0.add(s0);
b0.add(s1);

a0.overlapping(b0, () => log('hit'));

function draw() {
	if (mouse.pressing()) s0.moveTowards(mouse);
	else s0.speed = 0;

	if (a0.overlapping(b0)) {
		s0.color = 'orange';
	} else {
		s0.color = 'green';
	}

	if (b0.overlapping(a0)) {
		s1.color = 'yellow';
	} else {
		s1.color = 'green';
	}

	if (kb.presses('g')) {
		log('g pressed');
		a0.remove(s0);
		// b1.remove(s1);
	}

	if (kb.presses('a')) {
		log('a pressed');
		a0.add(s0);
		// b1.add(s1);
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant