G12_C8
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
4-10 | Warm up Quiz+Revision | 5 min | |
TA1 | 11-16 | Teacher Activity 1 | 7 min |
TA2 | 17-19 | Teacher Activity 2 | 6 min |
SA1 | 20-25 | Student Activity 1 | 7 min |
SAA 1 | 26 | Student Additional Activity 1 | 3 min |
SAA 2 | 27 | Student Additional Activity 2 | 3 min |
28-30 | 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.
3. Spyder installed.
1. Computer with an Internet connection.
2. The latest browser installed.
3. Spyder installed.
4. Projector to present the screen
Revise!!
...
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
sys.exit()
pygame.draw.rect(screen,(23,100,100), paddle)
pygame.draw.rect(screen,(255,69,0), ball)
...
...
xvel=2
if event.type == pygame.QUIT:
pygame.quit()
enemy.x=enemy.x+xvel
...
...
if event.type == pygame.KEYUP:
if event.key ==pygame.K_LEFT or event.key == pygame.K_RIGHT:
change= 0
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
change =3
if event.key ==pygame.K_RIGHT:
change = -3
...
def newxy(oldx,oldy,distance,angle):
angle=math.radians(angle+90)
nx=oldx+(distance*math.cos(angle))
ny=oldy-(distance*math.sin(angle))
return nx,ny
newimg=pygame.transform.rotate(player_image,angle)
for enemy in enemies:
enemy.x+=xvel[i]
enemy.y+=yvel[i]
if enemy.x < -250 or enemy.x > 650:
xvel[i] = -1*xvel[i]
if enemy.y < -250 or enemy.y > 850:
yvel[i]=-1*yvel[i]
if bulletState == "ready":
bullet.x=player.x+15
bullet.y=player.y+15
if bulletState=="fired":
bullet.x ,bullet.y = newxy(bullet.x, bullet.y, 20 , angle)
if bullet.y<0 or bullet.x<0 or bullet.y>600 or bullet.x>400:
bulletState="ready"
if bullet.colliderect(enemy):
enemy.x=1000
enemy.y=1000
Objective of today's class: Game features that are yet to be added
This slide should be removed
Teacher Activity 1:
We are re-assigning the coordinates of the spaceship, once the spaceship crosses the game boundary
...
if player.x < 0 :
player.x = 400
elif player.x > 400 :
player.x =0
elif player.y < 0 :
player.y = 600
elif player.y > 600 :
player.y =0
...
Output Teacher Activity 1:
Objective of today's class: Game features that are yet to be added
English
Mathematics
Science
Social Science
Computers
This slide should be removed
Teacher Activity 2:
We are going to display the score, at the top left corner of the game window.
...
if bullet.colliderect(enemy):
enemy.y=random.choice([random.randint(-250,0),random.randint(600,840)])
print(enemy.y)
enemy.x=random.choice([random.randint(-250,0),random.randint(400,640)])
print(enemy.x)
score+=1
...
scoretext=game_font.render("Score : " + str(score),False,(200,200,200))
screen.blit(scoretext,(10,10))
...
Output Teacher Activity 2:
Objective of today's class: Game features that are yet to be added
*** Note to Illustrators ***
Add a gif here, in which, John and other students are sitting in classroom and are giving exam.
After sometime, the clock strikes 12 PM and teacher announces "Time Up"
This slide should be removed
Student Activity 1:
Students are required to code in the given template, about displaying the text "Game Over"
Template link: https://bit.ly/3dJrDtS
Hints:
Solution link:
Solution
Student Additional Activity 1:
Resize the game window to 600x400
Template
Solution
Student Additional Activity 2:
Updating score by 10, everytime the bullet hits the enemy
Template: