Colour Collision

10 views
Skip to first unread message

Moyrum Akhtar

unread,
Nov 30, 2019, 11:49:37 PM11/30/19
to Processing.js
one of my task for university requires to create code with allows a defender to detect if it's crashed with a alien... but I can't seem to get the code to work. The collision has to be detected by the colour of the alien. So the alien has its own class and the defender has its own class. so how will I get that to work?
 
aliens.pde
defenders.pde
defenderz.pde
spaceBackground.jpg

Lee Brunjes

unread,
Dec 1, 2019, 2:05:39 PM12/1/19
to proces...@googlegroups.com
Taking a look ad your code you seem to have the basics down. There are aliens, they are a color. 

Your Collision code is the problem.
First, you aren't calling defender.colliosn(Alien1) anywhere. You want to do your check before you draw the defender so it won't overwrite any alien colors.

Second, in your collision function you are comparing the color of the alien to the  X position of the alien. Those will hardly ever match.

You need to get the defenders color, (0,0,100) and compare to the alien color.

Hope that helps,
-Lee


On Sat, Nov 30, 2019 at 11:49 PM Moyrum Akhtar <nehaak...@gmail.com> wrote:
one of my task for university requires to create code with allows a defender to detect if it's crashed with a alien... but I can't seem to get the code to work. The collision has to be detected by the colour of the alien. So the alien has its own class and the defender has its own class. so how will I get that to work?
 

--
You received this message because you are subscribed to the Google Groups "Processing.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to processingjs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/processingjs/cfd21b39-62f5-4025-8ad0-22d3380417ef%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages