/Codestrs

Code Samples for Hour Of Code

Primary LanguagePython

Codesters Bike Challenge

									Dec 6, 2016
  1. Start the Bicycle game

    • Go to link https://hourofcode.com/codestersflappybike
    • Press the Play button (green button with > icon)
    • Quickly press the space bar consecutively to keep the bicycle in the sky.
    • Play the game, a few seconds, to keep the bicycle from colliding into the blue rectangles.
    • Click the Stop button (red button with rectangle icon)
  2. Change the background to Underwater

    • Click on STAGE Codestrs category in left hand menu
    • Highlight this line of code by double clicking
      • stage.set_background(“city”)
    • Double click “Underwater” in the left hand menu to change the background
    • Verify the line of code now is
      • stage.set_background(“underwater”)
    • Click Play
  3. Change the background to a Fish

    • Click on SPRITE Codestrs category in left hand menu
    • Highlight this line of code by double clicking
      • sprite = codestrs.Sprite(“bike”)
    • Double click “Fish 1” in the left hand menu to change the sprite icon
    • Verify the line of code now is
      • sprite = codestrs.Sprite(“fish”)
    • Click Play
  4. Basic Grid * Start coding!! * 4a. Copy the Python code into your editor https://raw.githubusercontent.com/llevans/Codestrs/master/codestrs_grid.py * 4b. Click Play * 4c. Click the Right Arrow – the keyboard event triggers the bike to start and stop pedalling

  5. Flip the bike 360 degrees when the Left Arrow is clicked * 5a. Copy codestrs_flip_360.py into your editor https://raw.githubusercontent.com/llevans/Codestrs/master/codestrs_flip_360.py * 5b. Click Play * Click the “Right Arrow” – the keyboard event triggers the bike to start and stop pedalling * Click the “Left Arrow" – the keyboard event triggers the bike the flip

    * Assignment – Update the codestrs_flip_forloop_assign Python script to calculate the rotation in a for loop
       * 5c. Copy  codestrs_flip_forloop_assign.py into your editor https://raw.githubusercontent.com/llevans/Codestrs/master/codestrs_flip_forloop_assign.py
       * 5d. Update the code at line 29 to rotate the bike position inside a for loop
       * 5e. Click Play
    
  6. Make the Flappy Bike game more robust with user interacting with all 4 arrow keys * Assignment – Update the codestrs_final_assign Python script with to handle the "Up Arrow" key event * 6a. Copy codestrs_final_assign.py into your editor https://raw.githubusercontent.com/llevans/Codestrs/master/codestrs_final_assign.py * 6b. Update the code to * set the y_speed when the Up arrow is clicked * set the y_speed when the Down arrow is clicked * set the x_speed when the Left arrow is clicked * set the x_speed when the Right arrow is clicked

       * 6c. Click Play
    

###MIT App Inventor Setup: -

  • Install the Emulator –

  • Build an Android App in App Inventor -

    • Go to link http://code.appinventor.mit.edu/
    • Click Continue without an Account
    • Click Start New Project – TalkToMeApp
    • Click Connect – Emulator
    • Click GO to connect the App Inventor Studio to the aiStarter
    • Add a Button
      • Our project needs a button. Click and hold on the word "Button" in the palette. Drag your mouse over to the Viewer. Drop the button and a new button will appear on the Viewer.