Summit Middle School classes for Andrew Busch
Andrew Busch - Summit
  • Home
  • Algebra 1
    • Alg 1B - Last Week
    • Alg1B 14 HW - Intro to Functions
    • Alg 1B 11 - Rational Expressions
    • Alg 1B 12 - Radical Expressions
    • Alg 1B 10 v2.0 - Quadratic Functions >
      • 10b Graphing with Pennies - Desmos Tutorial
      • 10i Snowboard Quadratic - Alg1B
      • 10 Quadratics Project
    • Alg 1B 10 Book - Factoring Quadratics
    • Alg 1B 9 - Exponential Functions
    • Alg 1B 8.5 - Representing Data
    • Alg 1B 13 - Inequalities
    • Alg 1B 8 - Best Fit Lines and Linear Regression
    • Alg 1B 7 - Linearity
  • Geometry
    • Geom Last Week
    • Geom 12 - Probability
    • Geom 11 - Circumference, Area, Volume
    • Geom 10-Circles
    • Geom 9 - Right Triangles and Trigonometry
    • Geom 8 - Similarity
    • Geom 7 - Quadrilaterals and Other Polygons
    • Geom 6 - Relationships Within Triangles
    • Geom 5 - Congruent Trianlges
    • Geom 4 - Transformations
    • Geometry 3.5 - Constructions
    • Geom 3 - Parallel and Perpendicular Lines
    • Geom 2 - Reasoning and Proofs
    • Geom 1 - Basics of Geometry
  • Programming
    • Directions for Sharing Programs with Me
    • Hour of Code
    • Intro to Python >
      • Installing and Using Portable Python
      • Introduction to Programming
      • Interactive Storyteller
      • Sophisticated Calculator
      • Getting Started with Games
      • Word Length Frequency
      • Substitution Cipher
      • Simple Game of Paddleball
      • Animating Many Objects
      • Accelerator
      • Applying Trigonometry
      • GIFs
      • Programmatic Art
      • Battleship
      • Pong
      • CodeCademy.com Suggested Work
      • Python Resources
    • Advanced Python >
      • Python Installation
      • Review of Intro to Programming
      • Objects and Classes >
        • More on Classes: Functions, Methods, Inheritance
        • Quadrilaterals
      • tkinter >
        • Paddle Ball
        • Light Bike
        • Frogger
        • Snake Game
        • Breakout
      • Reading and Writing Files
      • Directories and Importing Modules
      • Raspberry Pi
      • API's
      • Python Puzzles
  • Clubs
  • Graphing Calculator
  • PARCC Practice

Light Bike

​It's time to build a tron-esque light bike game. If you don't know what it is, click the above link and play a few rounds. 
The basic idea is that your motorcycle has a trail which never goes away... unless you crash. You can crash by either hitting the walls or any of the light trails--including your own.
Picture
Directions:
  1. You need to create this program using classes. You may NOT use sgfx... at all. By using classes, I mean you should not have a massively complex process of if-then statements. Those webs of logic you are used to creating should be broken up into smaller digestible pieces we will use as methods in the larger class. 
  2. Your animation loop CANNOT be a naked while loop like you used in the paddle ball program "Bounce". You need to define a mainloop function and embed the while loop in this function. The game will start when you call mainloop() at the end of the program.
  3. Your code must be commented for full credit!
  4. Your game must be two-player.
  5. You must have text on the screen indicating which player is which based on color.
  6. You must have a counter on the screen which either displays the score of multiple matches or the elapsed time of a single match.​
​Extension: 
  1. ​Give the user an option to play again or quit
  2. Give the user an option to play again or quit on the window/canvas so they don't have to go back to the interpreter. 
Requirements
Think through the process with me for a moment.

Step 1: We need to leave a trail behind our bike. I can think of two options to do this.

    Option 1: Move a bike around a screen and place a trail behind the bike.
    Option 2: Place new bikes on the screen in the direction we want to go. 
I suggest going this route.
Step 2: Create a bike that leaves a trail and responds to keyboard controls for direction.
Step 3: Your bike needs to crash when it runs into walls
Step 4: Your bike needs to crash when it runs into its own trail.
Step 5: You need an opponent to play against.
Step 6: Display text on the screen showing the winner and the amount of time the game lasted and/or the score.
Extension!!
Step 7: Give the user an option to play again or quit.

Step 8: Give the player an option to play again by using your window/canvas rather than having to back to the shell. 



































​Hint:
Here's the classes and methods I used for the program up to step 6. Once I started step 7 I created a 'game' class which allowed the program to run multiple times.



class Bike (object):
    def __init__(self,color):

    def turn_left(self, evt):
        #changes the self.x, self.y based on keyboard event.
​
    def turn_right(self, evt):
        #changes the self.x, self.y based on keyboard event.
 
    def turn_up(self, evt):
        #changes the self.x, self.y based on keyboard event.

    def turn_down(self, evt):
        #changes the self.x, self.y based on keyboard event.

    def MoveBike(self):
        #Places the position of the self.id rectangle into the both_trails array.
        #Creates new rectangles on the screen based on the
​           self.x and self.y given by the turn_left, turn_right, turn_up, turn_down methods above.

    def checkhit(self):
        #check to see if your position is in the both_trails array.    

    def new_game(self, game):
        #you only need this for the extension.

---
class Bike2(Bike):
    #this inherits everything from the Bike1 class, unless you decide to change it.
    #because you need a second bike with different key bindings.
   
    def __init__(self, color):
 
    def new_game(self, game):
        #you only need this for the extensions.
​
---
def mainloop():
    #this should contain the while loop used to animate the paddle ball game.    

both_trails = []

#declare the Bike objects
Bike1 = Bike(game, 'Red')
Bike2 = Bike2(game, 'Blue')

#run the game
mainloop()

Powered by Create your own unique website with customizable templates.