Wednesday, November 28, 2018

#OZCSCHAT Nov 2018

I was so excited to host the return of the #ozcschat last night! I appreciate everyone who came along to join in the conversation. Especially 
@nickyringland
@c_l_garcia
@sgunja1
@malynmawby
@timmiclark 
for keeping the conversation flowing and sharing so many insights and
@sailpip for letting me to take it on in the first place.

This is the wakelet showing many of the conversations which were started in the #ozcschat last night. You can be involved by joining us on January 29 2019 at 8PM or by tweeting at @ozcschat or with the hashtag #ozcschat. Any ideas for future questions or themes gratefully received.


Monday, November 26, 2018

OZCSCHAT is back!!!

I have received permission from Phillip Cook @sailpip (who started the chat years ago) to start OZCSCHAT back up again and I'm very excited because I've missed it so much. I'm trying to be the Computer science chat I want to see in the twitter.

So tomorrow night I will be marshalling? adjudicating? basically sitting on my computer and hoping for some friends for an hour to give us a chance to have a chat and wrap up 2018 and look forward to what we want out of our teaching lives in 2019 and learn from each other.

Since it's the first one in a while there won't be an official theme but rather just a catch up on what we're doing and where we want to go. Here are the 7 questions I have come up with. If the gong goes at 9pm and we haven't got to any I'll roll them over. 

The best thing about these chats are the spin-off conversations that happen when you ask for more detail or compare notes on a similar experience. Get to know your twitter friends and grow your Professional Learning Network!

Here are the questions:

















Friday, July 6, 2018

Pygame for the kiddies - My preso for GPN and files

Tonight I'm presenting on how to teach just enough Pygame to make something that works for novice Python programmers (read 10-17 year olds). 

One of the issues with Pygame is its barrier to entry but it has great benefits in given kids something visual to play with which has its own intrinsic motivation. This is a link to all the files I will be using tonight as well as my notes (probably to be added later) on each step and where the pitfalls are. 

Clearly, if you are an experienced programmer and familiar with objects, there are much better ways to design games but this project is scoped first and foremost to teach the bare minimum to get the kids going.


Files for use with the game






Steps to build the game in code (steps in text coming)


Step 1: a screen
#import stuff
import pygame

#setup screen
pygame.init()

screen = pygame.display.set_mode((640, 480))
#screen.fill((255, 255, 255))
#pygame.display.flip()


#setup vars and files

#instructions

#keeping track of cards

#managing time


#main loop

    #check time passed (slow computer down)

        #if there is a snap event
            #increase score and print outcome

            #update screen and pause
        
        #reset time_delay, update previous_card and get new card

        #update screen

    #check for events

        #if the quit button was pressed

        #else if there was a keypress (any keypress)    

            #check if card matches

                #increase score and print outcome

            #update screen with outcome and pause
            
            #reset time delay, update previous_card and get new card

            #update screen


Step 2: quitting

#import stuff
import pygame

#setup screen
pygame.init()

screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
pygame.display.flip()


#setup vars and files
game_over = False


#instructions

#keeping track of cards

#managing time


#main loop
while not game_over:

    #check time passed (slow computer down)

        #if there is a snap event
            #increase score and print outcome

            #update screen and pause
        
        #reset time_delay, update previous_card and get new card

        #update screen

    #check for events
    for event in pygame.event.get():

        #if the quit button was pressed
        if event.type == pygame.QUIT:
            print("Game over")
            game_over = True

        #else if there was a keypress (any keypress)    

            #check if card matches

                #increase score and print outcome

            #update screen with outcome and pause
            
            #reset time delay, update previous_card and get new card

            #update screen


pygame.quit()

Step 3: Blit


#import stuff
import pygame

#setup screen
pygame.init()

screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
pygame.display.flip()


#setup vars and files
game_over = False
#user_score = 0
#computer_score = 0


#instructions

#keeping track of cards

#managing time


#main loop
while not game_over:

    #check time passed (slow computer down)

        #if there is a snap event
            #increase score and print outcome

            #update screen and pause
        
        #reset time_delay, update previous_card and get new card

        #update screen

    #check for events
    for event in pygame.event.get():

        #if the quit button was pressed
        if event.type == pygame.QUIT:
            print("Game over")
            game_over = True

        elif event.type == pygame.KEYDOWN:

            #check if card matches -- faking this
            #yet to implement
            if pygame.key.get_pressed()[pygame.K_SPACE]:

                #increase score and print outcome
                #user_score = user_score + 1
                print("You Win!")
                #print("Computer: " + str(computer_score) + " User: " + str(user_score))
                
                image = pygame.image.load("snap.png")
            else:
                image = pygame.image.load("boo.png")

            #update screen with outcome and pause
            #screen.blit(image, (300, 80))
            #pygame.display.flip()
            #pygame.time.wait(500)
            
            #reset time delay, update previous_card and get new card

            #update screen


#pygame.quit()

Step 4: Cards


#import stuff
import pygame, time, random

#setup screen
pygame.init()

screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
pygame.display.flip()


#setup vars and files
game_over = False
user_score = 0
computer_score = 0
cards = ["ace.png","2.png","3.png","4.png"]

#instructions

#keeping track of cards
previous_card = "0"
card = cards[0]

#managing time
sec_to_add = random.randint(2,5)
time_delay = time.time()+sec_to_add

#main loop
while not game_over:

    #check time passed (slow computer down)

        #if there is a snap event
            #increase score and print outcome

            #update screen and pause
        
        #reset time_delay, update previous_card and get new card

        #update screen

    #check for events
    for event in pygame.event.get():

        #if the quit button was pressed
        if event.type == pygame.QUIT:
            print("Game over")
            game_over = True

        elif event.type == pygame.KEYDOWN:

            #check if card matches -- faking this
            if previous_card == card:

                #increase score and print outcome
                user_score = user_score + 1
                print("You Win!")
                print("Computer: " + str(computer_score) + " User: " + str(user_score))
                
                image = pygame.image.load("snap.png")
            else:
                image = pygame.image.load("boo.png")

            #update screen with outcome and pause
            screen.blit(image, (300, 80))
            pygame.display.flip()
            pygame.time.wait(500)
            
            #reset time delay, update previous_card and get new card
            time_delay = time.time() + random.randint(2,5)
            previous_card = card
            card = random.choice(cards)

            #update screen
            #screen.fill((255, 255, 255))
            #pygame.display.flip()
            #pygame.time.wait(200)


    image = pygame.image.load(card)
    screen.blit(image, (10, 100))
    pygame.display.flip()

pygame.quit()

Step 5: Computer Play (final ish)
#import stuff
import pygame, time, random

#setup screen
pygame.init()

screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
pygame.display.flip()


#setup vars and files
game_over = False
user_score = 0
computer_score = 0
cards = ["ace.png","2.png","3.png","4.png"]

#instructions
print("Press any key to SNAP!")

#keeping track of cards
previous_card = "0"
card = cards[0]

#managing time
sec_to_add = random.randint(2,5)
time_delay = time.time()+sec_to_add

#main loop
while not game_over:

    #check time passed (slow computer down)
    if time.time() > time_delay:

        if previous_card == card:
            #increase score and print outcome
            computer_score = computer_score + 1
            print("Computer Win!")
            print("Computer: " + str(computer_score) + " User: " + str(user_score))

            #update screen and pause
            image = pygame.image.load("snap_computer.png")
            screen.blit(image, (300, 240))
            pygame.display.flip()
            pygame.time.wait(500)

        #reset time_delay, update previous_card and get new card
        time_delay = time.time() + random.randint(2,5)
        previous_card = card
        card = random.choice(cards)

        #update screen
        screen.fill((255, 255, 255))
        pygame.display.flip()
        pygame.time.wait(200)

    #check for events
    for event in pygame.event.get():

        #if the quit button was pressed
        if event.type == pygame.QUIT:
            print("Game over")
            game_over = True

        elif event.type == pygame.KEYDOWN:

            #check if card matches -- faking this
            if previous_card == card:

                #increase score and print outcome
                user_score = user_score + 1
                print("You Win!")
                print("Computer: " + str(computer_score) + " User: " + str(user_score))
                
                image = pygame.image.load("snap.png")
            else:
                image = pygame.image.load("boo.png")

            #update screen with outcome and pause
            screen.blit(image, (300, 80))
            pygame.display.flip()
            pygame.time.wait(500)
            
            #reset time delay, update previous_card and get new card
            time_delay = time.time() + random.randint(2,5)
            previous_card = card
            card = random.choice(cards)

            #update screen
            screen.fill((255, 255, 255))
            pygame.display.flip()
            pygame.time.wait(200)


    image = pygame.image.load(card)
    screen.blit(image, (10, 100))
    pygame.display.flip()
pygame.quit()

All files can be found here: https://drive.google.com/drive/u/0/folders/0BzfvVt8-JyCmR0F5bmJOZzh6MVU