Introduction to programming
G11-C1
The breakout game
Activity flow | Slide No | Topic | Time |
---|---|---|---|
TA | 4 | Ice breaker | 3 min |
5-7 | Introduction to programming | 3 min | |
8-9 | Python | 3 min | |
9-11 | Spyder introduction | 3 min | |
12-13 | Functions | 5 min | |
14 | Variables | 3 min | |
SA | 13 | Functions-coding | 5 min |
14 | Variables -coding | 3 min | |
TA | 16 | Break out game introduction | 5 min |
Wrap-Up Quiz | |||
SAA1 | 15 | ||
SAA2 | 16 |
Class Structure
Pre-Requisites
For Teacher | For Student |
---|---|
1. Computer with internet connection 2. Latest browser installed |
1. Computer/phone with internet connection 2. Latest browser installed 3.A bottle of water 4.Pen and Paper |
Ice-Breaker
If you could have a personal robot, what is that one function you want your robot to do?
Drink Water
Drink Water
How will you make the robot drink water?
Drink Water
What is 8+3?
Game development
Easy to code
Help easily available
Data Analysis
Help easily available
Robotics
App & web development
Writing instructions in the programming world
Writing instruction in the real world
Editor
Help/Variable explorer/Plots/Files
TaskBar
Console
Now, let us try to write and execute some code using the console.
3+5
Now, let us try to write and execute some code using the editor.
What is the function of a blender?
What is the function of a printer?
Functions in python
func(x1,x2,x3)
Function name
Parameters
Functions in real world
Example: print function
print( Text/numbers)
paranthesis
print(5+3)
print(5+3)
print(100+200)
print(1000+2000)
Print the value of:
x=5
Variable in math
Variable in Python
x=5
a=3456
b=8
c=78
d=45
e=907430
f=73352
g=56
print(a+b+c+d+e+f+g)
Screen
Brick
Ball
Paddle
Introduction to the breakout game
Addition of variables in the game
import pygame
pygame.init()
WHITE = (255,255,255)
DARKBLUE = (36,90,190)
LIGHTBLUE = (0,176,240)
RED = (255,0,0)
ORANGE = (255,100,0)
YELLOW = (255,255,0)
#Declare a variable "score" and assign it the value 0
score=0
size = (600, 600)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Breakout Game")
carryOn = True
while carryOn:
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
carryOn = False # Flag that we are done so we exit this loop
screen.fill(DARKBLUE)
font = pygame.font.Font(None, 34)
text = font.render("Score: " + str(score), 1, WHITE)
screen.blit(text, (20,10))
pygame.display.flip()
Student additional activity 1
Student additional activity 2