Category Archives: Assignments

Algorithm: Simplified Space Invaders

April 27th, 2016

Collision detection and input

Simplified Space Invaders
space invaders

Simplified Space Invaders
You can simplify the invaders to have different shapes.
You can simplify the shape of the buildings.
The behavior of the game has to be the same:
a. The invaders move right to left as they move down.
b. The bullets destroy the invaders ( they disappear).
c. The bullets destroy the buildings ( they disappear).
d. Keep score and lives.
e. Final message: Game Over

Optional Challenge: Have different levels of difficulty

Homework: Check edmodo.com

pygame: Drawpad_YI.py

Use pixelArray or other shapes from pygameHelloWorld.py and what you learned from previous assignments to write the program drawpad_YI.py

drawingpad

# get a pixel array of the surface
pixArray = pygame.PixelArray(windowSurface)
pixArray[480][380] = BLACK

Some helpful syntax:

pixArray = pygame.PixelArray(windowSurface)
pixArray[400][100] = BLACK
pixArray[pygame.mouse.get_pos()[0]][pygame.mouse.get_pos()[1]] = BLACK
del pixArray

pygame.mouse.get_pos()–> [x,y]
pygame.mouse.get_pos()[0] –> x
pygame.mouse.get_pos()[1] –> y

Cryptography: myEncryption1_YI.py

Classwork:
ASCII table

Encryption Assignment 1:
A company has asked you to write a program, YI_myEncryption1.py to encrypt its data. Your program should read the entire string.

Start by converting every character to uppercase. Then find the ASCII code for the first character of the string and subtract 64 (for discussion’s sake, call this X). X is the key for the encryption. Go through the entire string: for each character use the key, X. You should return a string of integers (twice the length of the original string + 2, the ASCII value of the first character) but instead of letters, it is a list of encrypted ASCII codes.
NOTES:
1. Place the ASCII value of the first character in front of the string of numbers.
2. Keep the shift within the ASCII values of A through Z.

Example:
Horse
the code is: 728087906577

Homework: Write a program, YI_myDecryption1.py to decrypt a string of encrypted ASCII codes, first find the first two integers (if the EAC is 728077848487, the first two integers are 72. 72 is the first character of the string). This means that the first string’s encrypted ASCII code is 80. Change from 80 to its real ASCII value (figure out this algorithm on your own) and then subtract each two integers from the first real ASCII value.

Final Project Proposal and Requirements

Final Project:

SUBMIT A PROPOSAL FOR MY APPROVAL. DO NOT START WORKING ON YOUR PROJECT. IF YOU HAVE INCOMPLETE ASSIGNMENTS, THEY HAVE TO BE FINISHED BEFORE YOU GET STARTED ON YOUR PROJECT BUT TALK TO ME ABOUT THEM.

  • The project can be a game that YOU created.
  • The project can be an application related to business, science, or any other subject you are interested on.
  • The project can be a program that was already assigned but you want to upgrade, modify or expand.
  • The project can be a pygame program or a python program.
  • If it is a pygame program, it must be animated. It must make use of list or dictionary.
  • If it is a python program, it must make use of list or dictionary.
  • The program must have good documentation.
  • The program has to be user friendly.
  • If the program uses other files, compress all of them into one file for submission.
  • Make sure you copy and paste the program on the post.
  • THIS PROJECT IS MEANT TO REPLACE THE WRITTEN FINAL EXAM ONLY IF YOU APPLY YOURSELF.
  • Pi Day activity

    March 12th, 2014

    Friday is Pi Day – We will have a pi-day activity
    Starting tomorrow we are celebrating Pi day by writing a program to do one of the following:
    1. Calculate the digits of Pi to highest possible precision
    2. Illustrate how Pi works
    3. Illustrate how Pi was discovered

    The programs will be judge based on ingenuity and/or creativity.
    NOTE: You can use online resources to help you develop your program. You can not use already written programs.

    Screen Shot 2014-03-12 at 9.40.23 AM
    Classwork:
    Write a pygame program, YI_MazeBouncing.py. Use the code you learned in animation.py but with a simple maze like the one below.
    Screen Shot 2014-03-07 at 9.29.25 AM

    Homework:
    Visit edmodo.com to answer these questions from Chapter 17.