We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi I'm very new to processing and unfortunately I am very ambitious. I've made this ridiculous mouse/animal thing and would really like to know (if possible!) how to make the wheels spin and/or if(mousePressed)... make multiple dots 'shoot' out of the animal's nose and bounce off the walls. I know this sounds fairly complicated but I would really like to know how to do this with detail! The code is here and you can add/edit it if you want:
void setup() {
size(720,480);
}
void draw() {
background(68,80,110);
stroke(255);
fill(185,11,11);
rect(-7, 380, 727, 170);
stroke(0);
fill(0);
ellipse(35,460,180,70);
stroke(255);
fill(128);
ellipse(mouseX-55, mouseY+26, 100, 48);//body
stroke(255);
fill(128);
ellipse(mouseX, mouseY, 50, 45);//head
stroke(255);
fill(128);
triangle(mouseX, mouseY, mouseX+5, mouseY+5, mouseX+40, mouseY);//nose
stroke(0);
fill(0);
ellipse(mouseX-3, mouseY-7, 5, 3);//left eye
stroke(0);
fill(0);
ellipse(mouseX+8, mouseY-7, 5, 3);//right eye
stroke(255);
fill(128);
triangle(mouseX-95, mouseY+12, mouseX-90, mouseY+8, mouseX-110, mouseY-20);//tail
stroke(255);
fill(128);
triangle(mouseX-13, mouseY-20, mouseX-20, mouseY-14, mouseX-30, mouseY-35);//left ear
stroke(255);
fill(128);
triangle(mouseX+8, mouseY-22, mouseX+16, mouseY-19, mouseX+23, mouseY-33);//right ear
stroke(255);
fill(128);
ellipse(mouseX-30, mouseY+48, 25, 25);//wheel right
stroke(255);
fill(128);
ellipse(mouseX-80, mouseY+48, 25, 25);//wheel left
if(mousePressed); {
stroke(0);
fill(231,100,20);
ellipse(mouseX+40, mouseY, 5, 5);//nosepoint
}
}
Thanks in advance! tephy2
Answers
for shoot: there are a lot of examples around in this forum - just search shoot
for rotate wheels - look at rotate in the reference pls
How to post code
when you post your code:
in the editor hit ctrl-t to auto format
copy it
paste it in the browser
leave 2 empty lines before it
mark the code (without the 2 empty lines)
press C in the small command bar.
this is the idea...
explanation
code for shoot by Ammon.Owed
shoot with space key
I use noCursor() to hide mouse cursor
mouse nose not red ?
there was a small issue with your mouse nose:
Problem: you mustn't have a ; after
because then all in the brackets { } is separated from the if-clause and thus executed always.
(the execute part (what is executed / done when condition is true) of the if-clause is only between if(......) and the ; so this part is empty. That's why you need to delete the ; so the execute part of the if-clause is all between { and } - the stroke and ellipse etc. )
This works now.
wheels
for the wheels I invented a function that gets the wheel position so we can use the same function for both wheels with different positions. Good.
unfortunately they always rotate and at the same speed. Bad.
shooting
for shooting I used a class - see OOP in the tutorials (object oriented programming)
Greetings, Chrisir ;-)
I also made the mouse roll on the floor, so mouseY is not in use anymore