G11_C8
| Activity Flow | Slide No. | Topic | Time |
|---|---|---|---|
| 4-10 | Warm up Quiz+Revision | 5 min | |
| TA1 | 11-17 | Ball bypassing the paddle and hitting the wall. Player life is decremented | 7 min |
| TA2 | 18-20 | Game over is displayed | 6 min |
| TA3 | 21-23 | Code for winner declaration | 10 min |
| SA1 | 24 | Student Activity 1 | 2 min |
| SA2 | 25-26 | Student Activity 2 | 2 min |
| SAA 1 | 27-28 | Student Additional Activity 1 | |
| SAA 2 | 29 | Student Additional Activity 2 | |
| 30-32 | Post Class Quiz | 4 min |
| Slide No. | Topic |
|---|---|
| 18 | TA1 solution |
| 21 | TA2 solution |
| 25 | SA1 solution |
| 29 | SAA1 solution |
| 30 | SAA2 solution |
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. Projector to present the screen
Same images
String and Int are the two integer datatypes, which will be resulted from the output of above two code blocks.
The output of first code block is "String".
The output of second code block is "Int"
name="Grade 11"
print(type(name))age=68
print(type(age)1.
2.
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
ballx=-ballx
bally=-bally
score+=3Revise!!
import pygame
...
pygame.Rect()
....
for event in pygame.event.get():
...
pygame.draw.rect()
pygame.display.update()
ballx=-1
bally=-1
...
ball.x=ball.x+ballx
ball.y=ball.y+bally
if ball.x>=590:
ballx=-ballx
if ball.x<=10:
ball.x=-ballx
......
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT:
if paddle.x<540:
paddle.x+=paddlex
if event.key == pygame.K_LEFT:
if paddle.x>0:
paddle.x-=paddlex
...
if paddle.collidepoint(ball.x,ball.y):
bally=-bally
......
for i in range(6):
brick=pygame.Rect(10 + i* 100,60,80,30)
pygame.draw.rect(screen,(255,0,0),brick)
for i in range(6):
brick=pygame.Rect(10 + i* 100,100,80,30)
pygame.draw.rect(screen,(255,100,0),brick)
......
carryOn = True
while carryOn:
for event in pygame.event.get():
if event.type == pygame.QUIT:
carryOn = False
......
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
...
for i in bricksR:
if i.collidepoint(ball.x,ball.y):
bricksR.remove(i)
ballx=-ballx
bally=-bally
score+=3
...
font = pygame.font.Font(None, 34)
text = font.render("Score: ", 1, WHITE)
screen.blit(text, (20,10))
...if ball.y>=590:
lives-=1
font = pygame.font.Font(None, 74)
text = font.render("LOST A LIFE", 1, WHITE)
screen.blit(text, (150,250))
font = pygame.font.Font(None, 34)
text = font.render("Lives left:"+str(lives), 1, WHITE)
screen.blit(text, (150,300))
pygame.display.flip()
ball.x=200
ball.y=250
pygame.time.wait(1000)if lives==0:
font = pygame.font.Font(None, 74)
text = font.render("GAME OVER", 1, RED)
screen.blit(text, (150,350))
pygame.display.flip()
pygame.time.wait(2000)
if score>=10:
font = pygame.font.Font(None, 74)
text = font.render("YOU WON!!", 1, RED)
screen.blit(text, (150,350))
pygame.display.flip()
pygame.time.wait(2000)
break
Solution
Solution