G11_C7
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 |
PRE REQUISITES
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
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
num=2
while if num==2:
print(num)
num=num+1
We cannot use an if inside the while statement itself.
What we have learnt?
roll_no=[12,56,90]
Box Brackets
Comma
Remove brick
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
Why detect brick and ball collision?
Brick collided with ball??
+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?
23
Text-based data
Datatype: STRING (str)
Syntax:
Place in
" " (or) ' '
Example:
name="David"
Numeric
data
Datatype: INTEGER (int)
Syntax:
Nothing specific
Example:
age=68
Fractional
data
Datatype: FLOATING POINT (float)
Syntax:
Nothing specific
Example:
weight=72.5
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))
How do I show some data on the game screen?
Specify style of text
Specify content of text
Display text
Show me your style of writing
Brick disappears
How do I make the computer write in a particular style?
How do I tell the computer what to write?
How do I show this text on the screen now?
Rectangle
draw( )
Text
blit( )
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?
Now let's code for ball-brick collisions.
Hints:
Remove the brick from the list
Negate 'bally' to change the direction of the ball.
Increase the score by 2.
print(x==12)
When comparison is done, the output is the boolean form of True or False.
x="5"
print(type(x))
Although 5 is a number , here it is enclosed in inverted commas , hence it will considered as a string.
Now let's code for ball-brick collisions for the yellow bricks.
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.
Hints:
First Name: John
Country: India
State:Bengal