G11_C7
Game Performance Measures
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
TA | 4-7 | Warm up+Quiz+Revision | 5 min |
8-15 | Understanding loops | 7 min | |
16-21 | Brick Creation | 5 min | |
SA | 22-26 | Orange brick creation | 5 min |
27-31 | Brick-ball collision | 7 min | |
TA | 32 | Precap to next class | 2min |
Wrap - Up | 33-36 | Quiz | 5 min |
SA | 38-40 | Additional Activity | 5 min |
Slide No. | Topic |
---|---|
14 | TA1 solution |
19 | TA2 solution |
21 | TA3 solution |
24 | SA1 solution |
30 | SA2 solution |
40 | SAA1 solution |
Class Structure
Preparation and Reference
PRE REQUISITES
Pre-Requisites
FOR TEACHER
FOR STUDENTS
1. Computer with an Internet connection.
2. The latest browser installed.
1. Computer with an Internet connection.
2. The latest browser installed.
3. Spyder installed.
4. Projetor to present the screen
first_num=2
while first_num<4:
for i in range(1,4):
res=i*first_num
if res%2==0:
print(res)
first_num+=1
What would be the output of the
following code:
C
Syntax error
2,4,6,6
Q.1
A
2,4,6,6
B
C
-
The while loop will iterate first_num through two values:2,3
-
The for loop will iterate i through 3 values:1,2,3.
-
Out of all the products only even ones will be printed
2,4,6
num=2
while if num==2:
print(num)
num=num+1
What would be the output of the
following code:
C
2
SyntaxError
Q.2
A
SyntaxError
B
C
We cannot use an if inside the while statement itself.
No output
Revision
What we have learnt?
roll_no=[12,56,90]
Box Brackets
Comma
+
-
Lists
Remove brick
Removing a brick on collision
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
Why detect brick and ball collision?
Brick collided with ball??
The way forward
+Score
Remove brick
Change ball direction
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
ballx=-ballx
bally=-bally
score+=3
How do I know the score?
Displaying the score
Are all data same?
23
String
Text-based data
Datatype: STRING (str)
Syntax:
Place in
" " (or) ' '
Example:
name="David"
Integer
Numeric
data
Datatype: INTEGER (int)
Syntax:
Nothing specific
Example:
age=68
Floating Point
Fractional
data
Datatype: FLOATING POINT (float)
Syntax:
Nothing specific
Example:
weight=72.5
Boolean
Comparison
data
Datatype: BOOLEAN (bool)
Syntax:
True
False
Example:
indian=True
name="David"
print(type(name))
age=68
print(type(age))
weight=72.5
print(type(weight))
indian=True
print(type(indian))
GREAT!
How do I show some data on the game screen?
Displaying data
Score:34
Specify style of text
Specify content of text
Display text
Different styles of writing
Show me your style of writing
Brick disappears
How do I make the computer write in a particular style?
Selecting a style of text
How do I tell the computer what to write?
Selecting the content
How do I show this text on the screen now?
Display the content
Rectangle
draw( )
Text
blit( )
GREAT!
font = pygame.font.Font(None, 34)
text = font.render("Score: ", 1, WHITE)
screen.blit(text, (20,10))
This just wrote the word score. What is score now?
Something missing?
Score:
??
Now let's code for ball-brick collisions.
Try to code!!
Hints:
Remove the brick from the list
Negate 'bally' to change the direction of the ball.
Increase the score by 2.
print(x==12)
What would be the output of the
following code:
C
12
True
Q.1
A
True
B
C
When comparison is done, the output is the boolean form of True or False.
true
x="5"
print(type(x))
What would be the output of the
following code:
C
int
str
Q.2
A
str
B
C
Although 5 is a number , here it is enclosed in inverted commas , hence it will considered as a string.
5
Now let's code for ball-brick collisions for the yellow bricks.
Try to code!!
Hints:
Remove the brick from the list
Negate 'bally' to change the direction of the ball.
Increase the score by 1.
Now let's code for ball-brick collisions.
Try to code!!
Hints:
First Name: John
Country: India
State:Bengal
-
Create a screen with the color of your choice.
-
Create one font specifying the font size.
-
Create three text variables with the different text mentioned and display on screen.
Copy of G11_C7
By Sanjukta Bhattacharya
Copy of G11_C7
- 99