G9_C13_ForTeacher(ANJALI)
How collision can be detect in objects
x-axis
y-axis
1
2
3
4
When objects having same x or y-axis then collosion happen
Teacher Activity- Lets understand with example when two object get collosion
import pygame
a = pygame.Rect((1, 1), (2, 2))
b = pygame.Rect((0, 0), (2, 2))
c = pygame.Rect((0, 0), (1, 1))
print(a.colliderect(b))
print(a.colliderect(c))
print(b.colliderect(c))
Output is 1 because y-axis of a and b is same
Output is 0 because both axis of and is different
Output is 1 because x-axis of b and c is same
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
3-7 | Revision + Quiz | 2 mins | |
8-18 | Introduction to Lists |
12 mins | |
TA | 19-23 | TA-Coding | 10 mins |
SA | 24-29 | Student Activity | 10 mins |
Wrap-Up | 30-32 | Wrap-Up Quiz | 2 mins |
SAA | 33-34 | Additional Activities | 10 mins |
Slide No. | Topic |
---|---|
13 | Lists in python |
20-23 | TA Coding Steps |
36 | Activity Links Table |
In python constructor function is named as __init__
randInt() function generate only integer between the given range.
Integer between 5 and 10
Either of 5 or 10
All numbers between 5 and 10
15
Integer between 5 and 10
random.randInt(5,10)
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Step 1: Think of a two digit number.
Step 2: Multiply it with three. (16 x 3 = 48)
Step 3: Add 6 to this number. (48 + 6 = 54)
Step 4: Divide it with three. (54 / 3 = 18)
Step 5: Subtract the number chosen in step 1 with step 4 (18–16= 2)
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Change with earlier class image
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Step 1: Create the move() function that will move the pipes
Step 2: Call the move function inside the game loop to move each created pipe.
Oputput:
Task: Reset the pipe to original position when it get's out from left edge.
Hint:
1. Check inside the move() function if the pipe moved out from left edge.
2. Move both top and bottom pipe to right edge of the screen
Task: Change the positioning of top and bottom pipe when reset.
Hint:
1. Update value of gap randomly after restting the pipe
2. Set top and bottom pipe according to the gap.
While defining a method in a class we need to give at least one argument that will poitn to current object.
Class name must be in same case as it is defined
book1 = Book()
book1 = Book()
book=book()
class Book:
price=10
author="xyz"
def showPrice(self):
print(self.price);
Book= book(self)
Hint:
1. Check if bird is moved out from bottom. (In gravity function)
2. Set bird.y to 0 to move it to the top.
Hint: 1. Load the cloud image in the images dictionary
2. Place the cloud image on the screen
Hint: 1. Load the cloud image in the images dictionary
2. Place the cloud image on the screen
Hint:
1. Check if bird is moved out from top. (In gravity function)
2. Set bird.y to 600 to move it to the bottom.
Hint: 1. Load the cloud image in the images dictionary
2. Place the cloud image on the screen
Activity No. | Activity Name | Links |
---|---|---|
Teacher Activity 1 | Bee 3 |
|
Teacher Activity 2 | Bee 4 -SA solution | |
Teacher Activity3 | AA1- Solution | |
Teacher Activity4 | AA2 Solution | |
Student Activity 1 | Bee 3.5 | |
Additional Activity 1 | Bee 3.5 | |
Additional Activity 2 | Bee 3.5 |
G9_C14_ForTeacher
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
3-7 | Revision + Quiz | 2 mins | |
8-18 | Introduction to Lists |
12 mins | |
TA | 19-23 | TA-Coding | 10 mins |
SA | 24-29 | Student Activity | 10 mins |
Wrap-Up | 30-32 | Wrap-Up Quiz | 2 mins |
SAA | 33-34 | Additional Activities | 10 mins |
Slide No. | Topic |
---|---|
13 | Lists in python |
20-23 | TA Coding Steps |
36 | Activity Links Table |
In python constructor function is named as __init__
randInt() function generate only integer between the given range.
Integer between 5 and 10
Either of 5 or 10
All numbers between 5 and 10
15
Integer between 5 and 10
random.randInt(5,10)
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Annie: Delhi
Sam : Noida
Jack : Gurgram
John : Gurgram
Step 1: Create a variable state="play"
Step 2: Check if pipe1 collided with bee and make the state="over"
Step 3: Create If condition for "over" state.
Step 4: Display "gameover" image inside "over" state if-block
Output:
Task: Stop Everything once bee hits the pipes
Hint:
1. Create a play state if block.
2. We only need to show pipes and bird in the play state, so move the display function inside the play state if block
Task: Make the bee collide with pipe2 also
Hint:
1. Add the condition to check collision between pipe2 and bird using OR key word.
bee.bee.colliderect(pipe2.topPipe) or bee.bee.colliderect(pipe2.bottomPipe)
bee.gravity()
if groundx< -330:
groundx=0
if bee.bee.colliderect(pipe1.topPipe) or bee.bee.colliderect(pipe1.bottomPipe) or bee.bee.colliderect(pipe2.topPipe) or bee.bee.colliderect(pipe2.bottomPipe) :
state="over"
pipe1.move()
pipe2.move()
if state=="play":
bee.display()
pipe1.display()
pipe2.display()
groundx =groundx-5
The "and" keyword makes sure all conditions are true before doing a task.
"or" will return true when either of two condition is satisfied. i.e. or makes sure if block runs even if a single condition is true.
or
and
not
if marks<35 ? attendance<35:
#repeate the course
or
Hint:
1. Use print() to print the state of the game to console.
Hint: 1. Load the cloud image in the images dictionary
2. Place the cloud image on the screen
Hint:
1. Use # symbol to add Comments in the code.
Activity No. | Activity Name | Links |
---|---|---|
Teacher Activity 1 | Bee 3 |
|
Teacher Activity 2 | Bee 4 -SA solution | |
Teacher Activity3 | AA1- Solution | |
Teacher Activity4 | AA2 Solution | |
Student Activity 1 | Bee 3.5 | |
Additional Activity 1 | Bee 3.5 | |
Additional Activity 2 | Bee 3.5 |