foreign
[Applause]
okay my own yep
all right ah okay so we've had our very
teeny tiny morning tea break I hope you
all are adequately caffeinated and now
we're approximately back on time so
that's good uh today I'm going to be
talking about uh Pi game zero so I'm a
teacher I've been a teacher for a while
now and uh there's a thing called pie
game that most people that are python
developers know of and never ever ever
touch because who would but there's also
another thing called pie game zero and
I'm going to be doing a bit of an
analysis of the two today and telling
you about my story in the classroom so
that any Educators that are watching can
understand some of the pitfalls that
I've come across and how to avoid them
in their own classroom and some of the
benefits also
so the summary is xero or hero pie game
zero in the classroom so who am I uh
this is my fabulous game Avatar that my
son made me
um
so I'm a Computing teacher and have been
for about 15 years I used to work in
industry but it was it's getting to be
an embarrassingly long time ago now and
I am concerned about the implementation
of new syllabuses in New South Wales
we're getting a lot of them over the
next two years and I am a terrible
kickboxer despite this image
Okay so
this is a quote by Pablo Picasso is that
and I'm not a big fan I've got to say
but I'm a big fan of this quote and I do
I do take it on I synthesize this in my
classroom so we learn the rules like a
pro so we can break them like an artist
and so this means that I have a slightly
different take on teaching Computing
from a lot of teachers and this dovetail
is quite interestingly with Jack's talk
because I steer clear of libraries for
the most part at least for the first
phase of programming some teachers go in
with lots of libraries very early get
the kids to feel that efficacy of making
stuff happen
and I am a bit more like the first
principles we have to have that
foundation and so
the transition that we make in the
classroom in my programs um
programs are the teacher word for uh
like the the things we do in the
classroom they're all written into a
program and so
our programs start with output we have
print on the screen real early that
hello world thing that's true we print
on the screen real early and then we add
some variables to that and then we add
some input so we can we can see what
what the user is typing and then we
might do some string processing in there
so that the students get a lot of
practice at that and then we add
selection which is your if statements
and then we make complex selections so
nesting of if statements and LF gets
added in there and then we have loops
added start with while transition to
four and then we have loops with
selections loops with other Loops like
this is the this is the growing ripples
of computer coding in the classroom and
then finally we're getting two functions
that is our that is our end goal there
you'll notice There's No Object oriented
in here there is now object oriented
program being mandated for year 11 and
12 coming from next year in the New
South Wales syllabuses but this I'm
mostly talking about stage five which is
years nine and ten when they when
they've passed the very basic like I
made something appear on a screen thing
and they're now transitioning into doing
more complex stuff with functions okay
this is the fundamental problem we're
trying to solve so that's the
fundamentals that's all the stuff that I
just spoke about we've got output we've
got variables we've got input we've got
selection we've got Loops all of the
complexity complexities of of
interlacing those and we've got
functions and you're still a million
billion miles from gooeys right
it's it's very very far and it's hard
you have a budget and also there's
physics involved to get you from one to
the other and so that this is the
problem that we all have to try and
solve in our classroom somehow
today
we have have made the game Flappy brick
uh and I've made this game twice I've
made it in pie game and I've made it in
pie game zero and we are going to
compare the two and see what's going on
and why they're different and what's
good about them
um so it's the easiest game I could
think of that I could make with the
least amount of physics
um so what we have here is
a game character a Sprite and you click
a mouse button and it goes up it does
not go up in any smooth way please don't
critique my code it's really aimed at 14
year olds all right so it doesn't go up
in any kind of smooth animation it just
jumps 30 pixels and the the pipes or you
know the obstacles move from left to
right so the Sprite goes up and down the
obstacles move left to right that's the
whole game it's real basic
there's only one input and the score is
based on some basic mathematics
uh yeah okay
so why games this is an important
question I've had some very interesting
debates with some people I really
respect uh who say Do not teach games in
the classroom you're killing your
children
um that Gap that I showed you earlier
that we have to bridge between the
fundamentals and the guis is just too
great and too disappointing and so we
should just steer clear of games but
I think there's a really good reason for
games in the classroom
um and that is that kids don't know
anything about the world
so when they have to try and come up
with the rules involved in some kind of
business case they are at Sea they have
no idea you have to give them to them
whereas with a game they have a lot of
experience playing games different kinds
of games maybe that particularly there
is a bit of a gender split in the kinds
of games that the students play but
they've still all had some experience
with games and they find games engaging
amazing surprising things I know but
they're very strictly rule based a
student if you sit down and say how do
you play naughts and Crosses they can
tell you the rules they know the rules
they've synthesized that games have
rules and these rules are very easily
articulated and they want to test their
programs geez as a Computing program as
a Computing teacher we want kids to want
to test their programs and they want to
test them if they're games and it's
easily since the sized why not games
because guis are really really really
really really hard okay
why python lots of people say you should
start with something else maybe you
should start with JavaScript maybe you
should use web stuff it's mostly for the
reason that Jack showed in his previous
talk which is that you get rid of all of
the stuff that you say please ignore
this until later and you're left with
python so we're just going to start with
python also python is now mandated at
the HSC from 2025 so the students that
come into software engineering in year
11 next year will be required to write
python in a browser window in their in
their HSC exam and so if we're aiming
there we need to smooth that path and so
at our school we've decided to go 7 to
12 python
um so consistency I also love that
python has that low floor and very high
ceiling there are lots of things that
students can do to extend themselves
with all of the different open source
libraries that allow that that are
available to them with python
um there are some students that do
extend I have students who come to me
and say I want to do my major project in
Rust and after I stop weeping
um then I say sure you're going to get a
lot less hand-holding from me and
they're like it's all right Miss I'm
fine and for the kid that's it's all
right Miss I'm fine then sure go do Rust
but for the most of them a vast majority
of the students that I take through the
HSC still need a bunch of hand holding
and so it's better if those resources I
can make once with one one language
the other thing is that in the HSC in
2025 not only do the students have to
write python in the browser
they also have to know HTML CSS and some
SQL and that's a lot that's enough now
keeping those syntaxes straight I know
that the whole HTML is not a programming
language thing is is great have that
debate outside but also it's still it's
still a literacy that they need to have
it's still tagging it's still things
that they need to remember and there's a
lot of cognitive load there there are a
couple of talks a couple of years uh
that was sorry there was a great talk a
couple of years back about all the
different options if you've decided to
do games in Python what should what's
available to you and so I'll direct you
to that because I'm not going to do that
cover that today we're assuming that our
solution was Pi game
and there are lots of reasons the number
one reason was I didn't want to start
with objects and there's a lot that you
can do in pi game
with using objects without having to
write your own without having to write
classes and that's where I needed to be
okay so the first thing I want to do is
show you a snippet of a tutorial that
I've made for a pie game
um from before I started using pi game
zero and it looked like this
okay so I've got little Snippets of code
I've got explanations of how things work
and you can see the main Loop here while
not done for event Empire game we're
going to have to go and get those events
this is just the code to make the screen
close so once you run this code the
screen will close when you hit the
little x button that's it and there's
quite a lot of lines there
all right
so in general we're talking about games
that are single screen and they follow a
very basic same general shape okay I'm
going to show you the shape of a basic
game
we begin
we set up the game stuff there's a whole
lot of stuff that needs to be set up in
advance and then we enter a loop and
then we handle the player input we
update all the objects we draw
everything to the screen and then we
check have we ended the loop or not and
then we do it again and we do it a lot
and then at the end we do some Andy
stuff maybe there's a high score or
something like that and then we end the
game that's the shape this is the shape
we'll be referring to for the remainder
of the talk
okay
so initial setup I'm going to do the
comparison side by side Pi game Pi game
zero
all right so on the left we have Pi game
and on the right we have Pi game zero
um so I want to I don't know if I can do
this can I do this oh
I have little red dots I love it okay so
um all right so Pi game zero has been
made to try and smooth the transition
from scratch to Pi game to using python
in in guis and I'm not sure I don't have
students that are trying to make that
jump from scratch directly to Pi game so
I'm not sure if it's successful there
but there are some great things about it
so it's done a lot of what Jack was
talking about in the last talk of
wrapping up the craft I guess so here we
have we have to
um in pi game we have to Define our
colors and we have to make the tuples of
the RGB
um we have to do this thing here where
we set up a screen and we give it a size
but the size has to be a tuple or in
this case it's a list but but has to
have the brackets and so students the
first thing a student will do wrong in
pi game is to not put double brackets
there which is why I've pulled out size
as a separate variable
okay and then we have this thing called
a Sprite so the brick is a Sprite
and that Sprite then has to have an
image loaded against it then it has to
have a rectangle defined and the
rectangle definition is what you then
set X Y values against it gets a lot of
lines for one Sprite being set up okay
um over here we have Pi game zero this
is how you set up a screen
you have one capitalized variable so
constant I guess called width and it has
a number against it and one called
height and it has a number against it
and Pi game zero goes and does all of
the screen creation stuff for you based
on those two numbers which is really
useful and then down here we have a
thing called an actor which is like a
Sprite but with a lot less letters and
an actor takes in it of the name of the
image
so this is the name of the image it's in
Images slash brick.png so it's in
exactly the same place
I actually have a GitHub at the end
where both of these pieces of code are
so you can see that the images are in
the same place and so if you've put the
image in the images folder which is
really good practice and they're all
pngs then it just works as a string like
this which is Magic
the other thing is that over here we
have that whole rectangle thing where to
make it move and set its x value you
have to do three lines of code
over here brick just has its own X and Y
value there's also an extra step where
Pi game zero has re-registered X and Y
to be the center of the image whereas
does anybody know where Pi game
automatically puts the X Y value
top left
explain that and I have
um
uh yeah so everything is built from the
top left whereas in pi game zero things
are built from the center out which is
just useful
okay
all right so that was the initial setup
that's all the stuff that happens before
the game Loop and now we have the game
Loop itself
okay so uh I have
uh
the function here update all and the
function here display all right and over
here I've got a function update and a
function draw
in pi game zero you are required to use
the function name update and the
function name draw so it will do the
update thing and then the draw thing one
after the other inside the loop over
here I could call them anything which is
why I called them slightly different so
they didn't get confused and the global
still required but you can see here the
positioning of the different Sprites is
much trickier in pi game than in pi game
zero and the Collision detection is
actually yuckier too so Collision
detection where Collide rectangle
between the brick and the wall top and
the brick and the wall bottom over here
we've got
this this Collide rect but it has to be
brick wrecked and not brick itself and
wall top rect instead of wall top so
it's just an extra an extra thing that
they have to keep in their heads and
these are just this is every single
mistake a kid has made is has been
anticipated and kind of corrected in pi
game zero which is amazing the last
thing I want you to look at is down here
I have brick dot draw walltop dot draw
wall bottom dot draw fantastic right you
know what that does it's almost like
English over here we have screen dot BLT
brick image Brit rect X Brit wrecked y
right
what the heck is a blit
this is a heck of visible it okay so you
have a set of pixels and you have to
mesh them sew them together with the
another set of pixels a larger set of
pixels like a screen then that process
is called blitting uh and I think it
stands for something but that's that's
the process that's splitting and so
blitting
is what it's called in pie game because
it's correctly called blitting but no
kid needs to know that so drawing is the
thing that they think of it doing so
um the the language is much clearer
okay so there's our blit okay so now we
have you that they're the things that
are inside the loop now we have the user
input and the loop itself
all right so user input in pi game is
awful we have to Loop through the events
this is the one that I showed you
earlier in my tutorial this is how you
make it quit when the top X is pressed
and this is how we find that there has
been a button click we look for an event
type of
mouseapygame.mouse button down and then
we jump the rectangle up 30 up the
screen is minus 30. same thing over here
up the screen is -30 but we're just
using an on Mouse down event
and then the last thing to look at is
pygamestplay.flip right
that's not necessary now the other thing
is see this while not done that while
loop doesn't exist in pi game not at all
there's no loop it's all implicit which
is a bit wacky and this is my biggest
problem with pi game zero is that it
hides a lot and it does get you part the
way across that bridge image we showed
earlier
um to the to introduction to guis but it
doesn't get you all the way so in
summary
pie game zero is awesome it really does
mean that students have that efficacy to
do things without constant tutorials
constant hand-holding that is really
useful but the questions that are asked
are I know how a function works why is
this why have I defined this function
but never called it and it's because Pi
game zero calls the function itself it
calls the update function it calls the
draw function by itself without the user
having that without the programmer
having to do it which is confusing to
smooth the transition to the next step
and it's confusing to the students who
know how functions work so it's really
quite useful for the students that are
making that first jump in but it doesn't
quite bridge the gap well enough to do
the jump out to the next stage which is
taking on I guess pie game by itself and
so teachers uh like I've been doing this
a long time teachers that embrace race
Pi game zero because look how easy it
makes this stuff are going to need
training and support to have those
conversations with their students to
bridge the gap to the next step and help
them understand why there's some magic
going on there and how much Magic
I guess so there are some downsides we
have a bunch of functions that are never
called it obscures too much in some
aspects and it makes the next step for
novices very difficult but in conclusion
whoops
um
uh yeah in conclusion I'll continue to
use it but I I will be doing it with
these conversations that I've already
rehearsed with my students to make sure
they understand that there's some stuff
being done there for them
and that is my GitHub if you want to go
play
thank you very much
[Applause]
thank you Amanda gaming I love it it
certainly um is a way to engage our
students do we have any questions out
there
oh they're all in all that's because I
explained everything so well I know
you're such an educator
um and I I do think that you will have
some conversations in the change over
time with maybe Dr Allison who about the
physics that your game does not hold yet
and and the unrealistics of me yeah so
who whoever said that science and gaming
doesn't ever overlap it really does so
I'd like to say thank you Amanda well we
um
um and there'll be a very short break
while we mic up our next victim guest
star thank you very much for this and
congratulations on being one of the very
only times that we we we let the border
between uh organizer and presenter but
obviously very well worth it so thank
you very much again
[Applause]