Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added MP4 Project Proposal.pdf
Binary file not shown.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# InteractiveProgramming
This is the base repo for the interactive programming project for Software Design, Spring 2018 at Olin College.
This is the repo for the Live Wallpaper Program. Created for the fourth Mini-Project for Software Design, Spring 2018 at Olin College.

All art is under copyright by Hwei-Shin Harriman and is not for distribution except with express permission from the artist.

Link to Project Reflection: https://github.com/hsharriman/InteractiveProgramming/tree/master/Writeup

Before running, install PyGame from terminal:
$ apt-get build-dep python-pygame
$ apt-get install mercurial python-dev python-numpy ffmpeg libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev
$ pip install pygame

To run the program:
navigate to the InteractiveProgramming folder on your computer and type:
$ python main
into the command line

To spawn hot-air balloons, click anywhere in the sky.
To spawn a cactus flower, click on the big cactus.
To exit the program, click the 'x' in the upper left-hand corner.
82 changes: 82 additions & 0 deletions Scrolling.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"\n",
"import pygame\n",
"import PIL\n",
"\n",
"class Main:\n",
"\n",
"\n",
" def __init__(self, width=640,height=480):\n",
" pygame.init()\n",
" self.width = width\n",
" self.height = height\n",
" self.screen = pygame.display.set_mode((self.width, self.height))\n",
"\n",
" def MainLoop(self):\n",
" while 1:\n",
" for event in pygame.event.get():\n",
" if event.type == pygame.QUIT:\n",
" sys.exit()\n",
"\n",
"\n",
"\n",
"class Background():\n",
" def __init__(self):\n",
" self.bgimage = pygame.image.load('images/backgroundtest.png')\n",
" self.bgX1 = 0\n",
"\n",
" self.bgY2 = self.bgimage.get_height()\n",
" self.bgX2 = 0\n",
"\n",
" self.movingUpSpeed = 2\n",
"\n",
" def update(self):\n",
" self.bgY1 -= self.movingUpSpeed\n",
" self.bgY2 -= self.movingUpSpeed\n",
" if self.bgY1 <= -self.rectBGimg.height:\n",
" self.bgY1 = self.rectBGimg.height\n",
" if self.bgY2 <= -self.rectBGimg.height:\n",
" self.bgY2 = self.rectBGimg.height\n",
"\n",
" def render(self):\n",
" surface.blit(self.bgimage, (self.bgX1, self.bgY1))\n",
" surface.blit(self.bgimage, (self.bgX2, self.bgY2))\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" MainWindow = Main()\n",
" MainWindow.MainLoop()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added Writeup/UML.pdf
Binary file not shown.
17 changes: 17 additions & 0 deletions Writeup/Writeup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Interactive Live Wallpaper
#### Hwei-Shin Harriman and Jessie Potter
### Project Overview
When the project was introduced, both of us were attracted to the idea of coding interactive art. We decided to pursue a project aimed to create an interactive scrolling background, much like the live wall-screens of Android products. We did this using art by Hwei-Shin, which we transformed into a background, platforms, and sprites to form our live background.

### Results
Our results were a scrolling background that continuously moved through our background image, seamlessly connecting the end and beginning of the image while looping through. Platform clouds floated at varying speeds and directions above the background. There were also a variety of other sprites, such as hot air balloons, flowers, and cacti that added depth to our scenery.

### Implementation
We implemented our program using the Pygame software. We started with a SpriteSheet class, which would take sprite data we stored in a separate "constants" script, and get the image associated with each sprite. Then, we created a Sprite class, which used SpriteSheet to extract any sprite whose data we passed into the argument and also defined its own version of draw. The next classes, Balloon, BlackCloud, PurpleCloud, SmallCloud, Cactus, and Flower, were all derived classes of the Sprite Class. Each one contains its own update method, specific to the behavior of the sprite it is representing. This allowed us to avoid defining pygame group objects for every type of sprite we used, and allowed us to write a more general update function for all of the sprites later on.

We then used a superclass Scene to define the background, the main update, draw, and shift_world methods, as well as the the spawn balloon and flower methods. We chose to avoid using the pygame group classes all together in favor of writing our own update functions and derived classes to avoid needless repetition of very similar functions for each group class. This means that we chose to avoid using any of the pygame group methods like .add(), .update(), .draw(), or .kill(), but it made the code much more readable and accessible in the long run. We used Summer as a subclass to generate all of our sprites and sort them by type by calling the appropriate derived class that we had defined above.

To run the code, we created a third script that contained our main() function. This function references all of the class objects from livebackground.py. It sets up the environment so that the program can run, keeps track of time steps, tracks user interaction, and tells the program when to update the screen.

### Reflection
Reflecting back on our project experience, there were definitely things that worked better than others. Our actual ideation process went really well, as we were both passionate about similar topics. We also did pivot our project at a reasonable time, because initially we wanted to work with hardware to create a lighting display. The project was fairly well scoped for the time period, but it would've been a lot easier to manage if we did not lose that first weekend. Both teammates did put quite a bit of time into the project, however Hwei-Shin was far more successful. While Jessie put a lot of hours into the project and worked with ninjas, she struggled and was not able to contribute as much. Jessie was also gone for the main weekend of the project, which made it hard to pursue our initial plan of Paired Programming throughout this project. Additionally, there was an issue with poor communication and proactivity throughout important times in the week, which resulted in the entire workload getting pushed back to the last couple of days. Addressing this issue proved to be complicated, because both of us had to set aside our learning goals for the sake of finishing the project in time. Thus, going forward, we would definitely work in the Paired Programming style more often and arrange more regular meeting times/check-ins. We would also try to implement more unit testing throughout our work, and also work towards making more interactive sprites.
Binary file added Writeup/wallpaper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bigcactus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added blackclouds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added comets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
Global constants
"""
#Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)

#Screen dimensions
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080

#------------PIXEL POSITION, WIDTH, HEIGHT OF ALL SPRITES-----------------

#small clouds
SMALL1 = (0, 0, 399, 113)
SMALL2 = (0, 113, 334, 178)
SMALL3 = (9, 291, 561, 128)
SMALL4 = (0, 419, 582, 168)

#purple clouds
PURP1 = (0, 0, 1145, 577)
PURP2 = (1145, 0, 1008, 277)
PURP3 = (0, 577, 877, 280)
PURP4 = (877, 540, 977, 413)

#black clouds
BLK1 = (0, 0, 1197, 345)
BLK2 = (1197, 0, 1992, 248)
BLK3 = (0, 345, 908, 359)
BLK4 = (908, 245, 971, 363)

#Hot-air balloons
BIG1 = (0, 0, 127, 180)
BIG2 = (0, 180, 164, 201)
BIG3 = (0, 381, 199, 239)
BIG4 = (56, 620, 138, 194)
BIG5 = (164, 0, 215, 276)

SMOL1 = (0, 620, 56, 57)
SMOL2 = (0, 677, 43, 52)
SMOL3 = (0, 729, 56, 73)
SMOL4 = (164, 276, 69, 103)
SMOL5 = (233, 276, 70, 109)
SMOL6 = (199, 385, 70, 81)

#comets
SHORT1 = (91, 0, 38, 78)
SHORT2 = (91, 94, 78, 50)
SHORT3 = (175, 0, 91, 32)
LONG1 = (0, 0, 68, 187)
LONG2 = (0, 187, 182, 175)
LONG3 = (0, 362, 350, 148)

#big cactus
CACTUS = (0, 0, 363, 495)
#[CACTUS, 3012, 489]
FLOWER = (0, 0, 82, 105)

#--------------------SPRITE LISTS----------------------
summer = [[BLK1, 1739, 18],
[BLK2, 45, 46],
[BLK3, 2538, 32],
[BLK4, 1046, -30],
[PURP1, 862, -15],
[PURP2, 196, 260],
[PURP3, 1188, 300],
[PURP4, 2773, 139],
[SMALL1, 429, 390],
[SMALL2, 3488, 375],
[SMALL3, 1911, 400],
[SMALL4, 1301, 420],
[CACTUS, 2958, 497],
[FLOWER, 2971, 728]]

balloons = [BIG1, BIG2, BIG3, BIG4, BIG5, SMOL1, SMOL2, SMOL3, SMOL4, SMOL5, SMOL6]
Binary file added flower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added hotairballoons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading