CS 320 n Elements of Visual Programming List
- Slides: 13
CS 320 n – Elements of Visual Programming List Search Mike Scott (Slides 9 -2) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for. Visual slide. Programming ideas. List Search
Common Uses of Lists • Iterating through a list of several like items to accomplish the same task with each item. – As in the previous chickens example • Iterating through a list of several like items to search for one item that has a given property. – This session demonstrates a list search. – is searching important in computer programs? Visual Programming List Search 2
Example • A Wac. AMole arcade game. • Little moles pop up from holes in the top of the booth. The user tries to whack the mole before it drops out of sight. • The game is over when 10 moles are hit. Visual Programming List Search 3
Designing the game • To design the game animation, we need to answer several questions: – How will the game work, overall? – How do we keep score? – How do we know when the user whacks a mole? – Will a list help us? (make it easier) Visual Programming List Search 4
How will the game work, overall? • A mole pops up and then goes back down. – Each time the mole pops up, the user attempts to use the mouse to click the mole. • When a click occurs, we check to see if a mole was clicked. – If so, a sound plays and the score increases. • The above actions repeat until the game is over. Visual Programming List Search 5
Overall design Is the game over? yes congratulate no pop random mole Mouse click event yes Did mouse click on a mole? Change score display no Visual Programming Play sound do nothing List Search 6
Storyboard for overall game • This is the main driver for the game. • The code will be written in World. my first method While the game isn't over randomly select one mole and call pop. Mole Congratulate the user Visual Programming List Search 7
Storyboard: pop. Mole Do in order Move the mole up Wait some time Move the mole back down Visual Programming List Search 8
How do we keep score? • We will use a visual scorekeeper. • The scorekeeper is made up of two cylinders – A gray cylinder above the ground – A yellow cylinder below the ground. Visual Programming List Search 9
How do we keep score? • Each time the user successfully clicks a mole, the yellow cylinder will move up 1/5 meter. • When the yellow cylinder is above ground (has moved up 10 times), the game is over. – true when yellow cylinder is above the ground Visual Programming List Search 10
How do we know when the user has clicked on a mole? • This is where a list comes in handy: – create a list of the moles (one mole is below each hole) – create a mouse click event – each time the mouse is clicked, call a score method to iterate through the list of moles to see whether one of the moles has been clicked! Visual Programming List Search 11
Storyboard: keep score Event: User clicks mouse Response: score For All in order If any mole in the mole list was the object clicked Make a noise Move the playerscore (yellow cylinder) up 1/10 meter Visual Programming List Search 12
Demo • Concepts illustrated in this example – A item can be randomly selected from a list • In this example, a random mole was popped up from a list of moles. – A visual scorekeeper gives the player feedback on the progress of a game. Visual Programming List Search 13
- Paul strand
- Perbedaan linear programming dan integer programming
- Greedy programming vs dynamic programming
- Runtime programming
- Integer programming vs linear programming
- Definisi integer
- Case structure flowchart
- Intro to visual basic
- Ai2.appinventor.mit.edu emulator
- Language a
- Visual basic programming language
- Visual logic commands
- Introduction to visual basic programming
- Object oriented programming visual basic