Download presentation
Presentation is loading. Please wait.
1
Agenda for Unit 5: Control Structures
Objectives 5. Describe the main types of control structures in C++ programming. 5.1: Identify three types of control structures. 5.2: Define the purpose of the if-else-if statement. 5.3: Explain the use of condition-controlled and count-controlled loops in game programming. 5.4: Identify how to increment and decrement the value of variables in a program. 5.5: Define compound Boolean expressions using logical operators
2
Hour 1 Review Homework 4.1 Quick Hits
Review week 4 lab (Landing Spaceship)
3
Chapter 6: Control Structures
Hour 2 Chapter 6: Control Structures
4
Hour 3 Chapter 6: Control Structures
Lab 5.1 Red Shift / Round Peg in a Square Hole
5
Hour 4 Lab 5.1 Red Shift / Round Peg in a Square Hole (cont.) Quiz 5.1
Quiz 5.1 answers Homework 5.1 assignment
6
Ready?
7
Hour 1: Quiz 4.1 Stats High Score = 100% Low Score = 0 100s = 3
0 = 5 Class Average = 65.1%
8
Hour 1: Answers to Homework 4.1:
Turn to page 208 and read aloud: me for answers
9
Hour 1: Answers to Homework 4.1: (cont.)
Turn to page 209 and read aloud:
10
Hour 1: Quick Hits Make sure you empty your folder each week.
Snowman feedback is coming Make sure you are sending me .cpp files Naming conventions!!! I will start deducting more and more Lab4_LandingSpaceship_Grose.cpp subject line: Lab4_LandingSpaceship_Grose.cpp Plagiarism
11
Hour 1: Quick Hits (cont.)
The good news is that the program runs. The not-so-good news is that the glitches I found matched almost exactly to another student's. There are a few possibilities for this. 1. You copied his code 2. He copied your code 3. You worked on this together and shared some code 4. The program is rather simple with few variations in approach so although slim, you both could have made the same exact errors There WERE enough differences that I cannot accuse either of your of plagiarism and I am going to give you the benefit of the doubt that either #3 or #4 above is the explanation. So with that, I am going to give you some of the same comments I gave (name removed) because they apply to both of your very-similar code. 1. You did not exactly use my approach, which is fine, except you did not remove the comments that did not apply. Also, you added a few extra blank lines between statements You set the window width and height without using dbScreenWidth and dbScreenHeight. You basically hardwired it so it would only be good with 640x480. And it was exactly like (name removed)’s code. -1
12
Hour 1: Quick Hits (cont.)
3. I very much like the way you both picked a random center for the Duck. It was a simpler one than I had BUT there is a problem. You fell victim to the age-old trap of "off by one." You wrote this: int ellipseCenterX = dbRND(440) What if the random number was 440? Then the CenterX would be 540 and that means that with the duck radius of 100, the outer edge would be at 640. What's the problem? Well, the right-most pixel is at remember it goes from 0 to so the last pixel of the duck would be off the screen. Ooooooh, so close! I would take off for this but you came up with a better approach overall for this so it's a push! This is what is most peculiar. This novel approach combined with this same mistake in two different program codes ... well, you can see what caught my attention. Good job, just watch the details.
13
Hour 1: Review week 4 lab (Landing Spaceship)
See File
14
BREAK!
15
Hour 2: Chapter 6: Control Structures
You should have read this over the break so the lecture should be a REVIEW! Monitors off!
16
BREAK!
17
Hour 3: Chapter 6: Control Structures
You should have read this over the break so the lecture should be a REVIEW! Monitors off!
18
Hour 3: Lab 5.1: Red Shift / Round Peg in a Square Hole
(Programming Exercise #3 and #7 on pages of Starting Out with Games and Graphics in C++) What is the purpose? This lab gives you the opportunity to complete two very different exercises in using control structures. It requires not only proficiency with the three types of control structure but also an understanding of logical operators and Boolean variables. Welcome to your first experience writing programs with sophisticated logic. What are the steps? Task 1: Complete Programming Exercise #3 (“Red Shift”) on page 278 of the textbook. Procedure 1. Write a program that loads and displays an image and then waits for the users to press a key. 2. Add two loops, one for the width and one for the height, to step through all the pixels of the image. (Refer to pages for a similar example.)
19
Hour 3: Lab 5.1: Red Shift / Round Peg in a Square Hole (cont.)
Procedure (cont.) 3. For each pixel, set the red component of the color to 255. Notice the effect on the image when the program is run. 4. As an added challenge, when stepping through the pixels, find which color component (red, green or blue) is the greatest for each pixel and set only that color’s component to 255. Notice the effect this has on the output image.
20
Hour 3: Lab 5.1: Red Shift / Round Peg in a Square Hole (cont.)
Task 2 (EXTRA CREDIT): Complete Programming Exercise #7 (“Round Peg in a Square Hole”) on page 279 of the textbook. Procedure 1. Write a program that chooses a random point on the screen and draws a 50x50-pixel square at that location. 2. Ask the user to guess the x and y coordinates of the square’s center point. 3. Draw a circle with a 25-pixel diameter at the guessed location.
21
Hour 3: Lab 5.1: Red Shift / Round Peg in a Square Hole (cont.)
Procedure (cont.) 4. If the circle is completely within the square, display a congratulatory text message. Otherwise, allow the user to guess two more times before displaying a “failure” message. 5. As an added challenge, create a version of the program in which the user starts with 100 points and has points deducted depending on the inaccuracy of his/her guess for each round. The game should end when the player’s points run out. Display a summary screen showing the highest round number the player was able to reach.
22
BREAK!
23
Hour 4: Quiz 5.1: pg 276 Using the answer sheet provided, answer the ten True/False questions on pages 276 of Starting Out with Games and Graphics in C++.
24
Hour 4: Answers to Quiz 5.1: pg 276
Turn to page 276 and read aloud:
25
Hour 4: Homework 5.1 Answer the Multiple Choice Review Questions on pages of Starting Out with Games and Graphics in C++. Submit your written answers to me in next week.
26
Hour 4: Next Week Read Chapter 7: The Game Loop and Animation
Turn in Homework 5.1. your lab .cpp files to
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.