G12_C9
| Activity No. | Slide no | Topic | Time |
|---|---|---|---|
| TA | 4-11 | Last class revision + quiz | 8 min |
| 12-15 | Game features to be added | 2 mins | |
| 16-17 | TA1 | 4 mins | |
| 18-19 | TA2 | 4 mins | |
| 20-21 | TA3 | 4 mins | |
| 22 | TA4 | 4 mins | |
| SA | 23-24 | Student Activity | 4 mins |
| 25 | Student Activity Solution | 2 mins | |
| Wrap-up | 26-29 | Wrap Up Quiz | 3 mins |
| SAA | 30-31 | Student Additional Activity 1 | 2 mins |
| 32-33 | Student Additional Activity 2 | 2 mins |
| Slide no | Topic |
|---|---|
| 22 | Teacher Activity Solution |
| 25 | Student Activity Solution |
| 31 | Student Additional Activity Solution 1 |
| 33 | Student Additional Activity Solution 2 |
1. Concept of Object-Oriented Programming.
2. Dictionary in python.
3. Game creation by applying OOP's.
Constructor
Encapsulation
Objects
Classes
OBJECTS
CLASS
class <ClassName>:
variableName1,variableName2
def fun1(self):
______________
______________
______________
def fun2(self):
_____________
_____________
_____________
class Car:
engineCapacity=10
maxSpeed=200
def enginepower(self):
print('Engine Capacity is ',self.engineCapacity)
def accelerator(self):
print("Maximum speed of Car",self.maxSpeed)
mycar=Car()
mycar.enginepower()
mycar.accelerator()Output
class car:
def car_color(self,color):
self.color=color
def car_cost(self,cost):
self.cost=cost
def car_speed(self,speed):
self.speed=speed
Sports Car:
Van Car:
Default interior
customized interior
class <name_of_the_class>:
<variable_name_1>=_____________
<variable_name_2>=_____________
def __init__(self,<variable_name_1>,<variable_name_2>):
self.<variable_name_1>=<variable_name_1>
self.<variable_name_2>=<variable_name_2>
def <function_1>(self):
_____________________
def <function_2>(self):
_____________________
class Car:
engineCapacity=10
maxSpeed=200
def __init__(self,capacity,speed):
self.engineCapacity=capacity
self.maxSpeed=speed
def enginepower(self):
print('Engine Capacity is ',self.engineCapacity)
def accelerator(self):
print("Maximum speed of Car",self.maxSpeed)
mycar=Car(30,150)
mycar.enginepower()
mycar.accelerator()Teacher Activity 3 template: https://bit.ly/36OzJNZ
Creating the game screen
init()import display.set_mode()display.set_caption()while True:pygame.quit()Steps to be followed:
Let's begin by creating the basic game screen.
Solution link for Teacher Activity 3: https://bit.ly/36PjmRf
Output for Teacher Activity 3
John is trying to understand meaning of the phrase, "stroke of genius". Suggest him from where he can get the correct meaning of this phrase.
Syntax for Dictionary in Python
<name_of_dictionary> = {'<key1>': '<value1>', '<key2>': <value2>}
print(<name_of_dictionary>['<value1>'])
print(<name_of_dictionary>.get('<value2>'))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()
Teacher Activity 4 template: https://bit.ly/3BzHllM
Teacher Activity-4: Adding background to the game window using a dictionary
Teacher Activity 4 solution: https://bit.ly/3xTR8kp
Output Teacher Activity-4
Student Activity-1: Adding an image of flappy bird to the game window using a dictionary
Hints:
Template link: https://bit.ly/2V1i9na
my_dictionary = {'name': 'Martin', 'age': 16}my_dictionary = ['name': 'Martin', 'age': 16]my_dictionary = "'name': 'Martin', 'age': 16"my_dictionary = ('name': 'Martin', 'age': 16)
dictionary_name={"John": 10, "maria":20}
print(dictionary_name["John"])B
This is Additional Activity 1
This is Student ActivityTemplate Link : https://bit.ly/3kGQX8i
B
Hello, my name is JohnTemplate Link : https://bit.ly/3rn63kF
| ACTIVITY NUMBER | ACTIVITY NAME | LINKS |
|---|---|---|
| Teacher Activity 1 | Game features to be added | |
| Teacher Activity Solution | All Teacher Activity Solution | |
| Student Activity | Print "Game Over" | |
| Student Activity Solution | Print "Game Over" | |
| AA1 | pow function | |
| AA1 Solution | pow function solution | |
| AA 2 | Print Score | |
| AA2 Solution | Print Score solution |