We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In the example I share here, I have an array of aliens. I'm trying to get the aliens to animate as they do in the original game. For every alien you see in the sketch, there is another alien underneath it. Is there anyway I can get the aliens to jump from 1 to 2 and back..... sort of like this: 1, 2, 1, 2, 1, 2 as they move across the screen? or like this: ( _ ) (^_^) ( _ ) (^_^) ( _ )...
I'm a NOOB so I barely understand anything.
Answers
If you have a specific question then please make the subject relate to that question rather than just "p5.js".
****EDIT: My example is in java. Let me know if you want to see the p5.js version.
Is the alien made of two objects or are they always two aliens? As a concept, and important to the design, you would need to describe the behavior of your dual entity. Can one alien be killed while the other survives? Or if one dies, would the other die? Are they always tie together or can aliens swap with other aliens-pair?
Are you familiar with trigonometric functions? You can always check wikipedia or mathworld for more info. You don't have to use trig functions, but it is an alternative. Below there is a sketch that shows continues swapping vs. step swapping.
Kf
Thanks Kfrajer. The aliens are made with one object but I've thought of using more than one object. I want both to die if one is hit. I'll check out the trig functions. Thanks.
There is other way, using sprites. Check this post: https://forum.processing.org/two/discussion/comment/98098/#Comment_98098
For reference to learn about sprint and avialble functions, examples: http://p5play.molleindustria.org/docs/classes/p5.play.html#method-createSprite
For the post above, you can remove all the references to the video part. Then you need to download the sprites and store them under a specific folder, as defined in the sketch. You also need to include the p5.play js library in your html. I can't remember if you need p5.dom.js. Make sure these libs are set right after you load the p5.js (or p5.min.js) library call.
Kf