G12_C10
Activity Flow | Slide No. | Topic | Time |
---|---|---|---|
Slide No. | Topic |
---|---|
my_dictionary = {}
x1, y1, z1 = 1, 2, 3
my_dictionary["A"] = x1 + y1 - z1;
x2, y2, z2 = 10, 20, 40
my_dictionary["B"] = x2 + y2 - z2;
print(my_dictionary)
class Car:
def __init__(self,model,cost,color):
self.model=model
self.cost=cost
self.color=color
def display(self):
print("Model is",self.model)
print("Cost is",self.cost)
print("Color is",self.color)
obj1 = Car("Van","INR 100000","White")
obj2 = Car("Sports Car","INR 200000","Red")
obj1.display()
obj2.display()
Teacher Activity 1 template: https://bit.ly/3rpPGns
Creating the game screen
Let's begin by creating the basic game screen.
init()
import
display.set_mode()
display.set_caption()
while True:
pygame.quit()
Steps to be followed:
import pygame, sys
pygame.init()
clock=pygame.time.Clock()
width=400
height=600
screen = pygame.display.set_mode((width,height))
while True:
screen.fill((50,150,255))
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
pygame.display.update()
pygame.quit()
Solution link for Teacher Activity 1: https://bit.ly/3io5vH4
images={}
images["bg1"] = pygame.image.load("D:/Flappy for AI/bg1.png").convert_alpha()
images["base"] = pygame.image.load("D:/Flappy for AI/base.png").convert_alpha()
images["bird"] = pygame.image.load("D:/Flappy for AI/bird.png").convert_alpha()
...
class Bird:
r=pygame.Rect(100,250,30,30)
speed=0
g=0.5
Teacher Activity 2 template: https://bit.ly/2W25wZK
Teacher Activity 2 solution: https://bit.ly/3xUBEMK
def display(self):
screen.blit(images["bird"],self.r)
...
bird = Bird()
...
bird.display()
screen.blit(images["base"],[0,550])
Student Activity template:https://bit.ly/3isTYGk
Student Activity solution: https://bit.ly/2ToN7p4
Now let's change the starting coordinates of the bird.
Template link: https://bit.ly/3rigzJT
Hints:
class Bird:
r=pygame.Rect(300,300,30,30)
speed=0
g=0.5
Student Additional Activity 1 solution: https://bit.ly/2UUx7LY
Template link:
Can you figure out a way, in which, we can make the flappy bird jump, double its current pixel values?
Hints: