Class 308 – 2.1 Functions + 2.2 Mouse Events
Make your programs interactive and organized
Today's Goals
- Learn to create and use functions to organize code
- Make programs respond to mouse clicks
- Make programs respond to mouse movement
- Combine functions and events to build interactive graphics
Agenda
- Introduction to interactive programming
- Lesson on Functions (2.1)
- Lesson on Mouse Events (2.2)
- Work time in CMU CS Academy
What You Must Finish Today
- Complete Unit 2.1 (Functions) notes and exercises
- Complete Unit 2.2 (Mouse Events) notes and exercises
- Create at least one program that uses:
- A custom function
- Mouse click events OR mouse movement
Homework
Finish any Unit 2.1 or 2.2 activities you did not complete in class
Quick Reminder
- Functions: Use
defto define, then call them with() - onMousePress: Runs when you click
- onMouseMove: Runs as you move the mouse
mouseXandmouseYtell you where the mouse is