This site requires JavaScript, please enable it in your browser!
Greenfoot back
Dhiraj
Dhiraj wrote ...

2019/1/20

how to make actor react on noise through microphone

Dhiraj Dhiraj

2019/1/20

#
how to make actor move one direction when we make some noise? need immediate help!!! please i have to move the continuously moving actor stickman towards left when we make noise or else continue to its real movement..
import greenfoot.*;

/**
 * This is a stick man. Make him move right when you make noise or else continueously move left.
 * 
 * @author 
 * @version 
 */
public class Stickman extends Actor
{
    /**
     * Make the stickman act.
     */
    public void act() 
    { 
        move(3);
    }    
}
danpost danpost

2019/1/20

#
Use the Greenfoot.getMicLevel method. If the returned value is less than a certain value, move right as normal, otherwise (else) move left. Btw, the commented text in the code reads moving left is normal and move right when noise is being made.
You need to login to post a reply.