70 likes | 202 Views
Programming Games. Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog . Homework: Modify Bo to make your own. Time event. Flash has Timer objects. You/your code needs to do 3 things:
E N D
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
Time event • Flash has Timer objects. • You/your code needs to do 3 things: • create the Timer object, setting the time and, optionally, the number of events • var btimer = new Timer(100); • var limitedtimer = new Timer(1000,3); • set up the event handling • btimer.addEventListener(TimerEvent.TIMER,movb) • start the timer • btimer.start();
Collisions • There are no balls, dogs, walls, etc. • Collisions are detected by doing calculations and, as appropriate, changing variables. • Bouncing ball example: if (rightwall.hitTestPoint(ball.x,ball.y, true)) { xd=-1; }
Bouncing ball • ball as movie clip instance on the Stage along with 4 instances of the movie clip symbol wall each with its own instance name! • Timer object: set up event to happen every interval of time and invoke function • that function moves the ball in x and y specified amounts and checks for hitting walls. When that happens, the appropriate deltas are changed. Demonstrate. Skim tutorial.
Bo the barking dog • The movie clip symbol has several frames representing moving legs… • The whole symbol is moved within a virtual box. Instead of bouncing, Bo disappears and reappears at the other side. • This is combination of cel and computed animation. Demonstrate. Examine code.
Assignment • Read Bouncing Ball tutorial and Bo the dog tutorial. • Download source for Bo the dog. • Change • all the graphics • something in the code • make dog/whatever speed up and slow down • add a button to change speed • add a slider to change speed. Look at examples, use Help. • change to bounce instead of exiting one side, etc. • ?
Other applications • If you complete this, you can look at other Bo the Barking Dog programs • source code • tutorial/notes