Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2c87b85
Added class defintions for course and req. Req is incomplete.
sokuno222 Oct 19, 2017
24678e7
Added import script
iblancett Oct 19, 2017
a168e80
Added ideation and source folders
iblancett Oct 19, 2017
42abeb2
progress on algos -- nothing working yet
iblancett Oct 19, 2017
8730859
Updating graphics window script. Added incomplete mouse pressed event
sokuno222 Oct 20, 2017
d959455
Courses can now be made
iblancett Oct 20, 2017
f4556da
Commiting to resolve pull errors. Added mouse_pressed event to graphi…
sokuno222 Oct 20, 2017
dba8016
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 20, 2017
8976520
Made course icons
leonardoliuuu Oct 20, 2017
5118db2
started game control
iblancett Oct 20, 2017
2d2ea2d
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 20, 2017
c15d2ea
Started setting up background function for graphics.py to call. Need …
sokuno222 Oct 20, 2017
4933c21
Made some level icons
leonardoliuuu Oct 21, 2017
e4c2e94
Changed files to incorperate icon images and mouseOver function. Stil…
sokuno222 Oct 21, 2017
afea157
Algo implemented for game control
iblancett Oct 22, 2017
a786ea4
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 22, 2017
d0b42b6
Something didn't push
iblancett Oct 22, 2017
96e4cd4
Deleted unused scripts
iblancett Oct 22, 2017
b133a20
Added some doctests to Gameplay and debugged
iblancett Oct 23, 2017
03ad23a
Debugged some more, added ending verdict and more doctests
iblancett Oct 23, 2017
459d704
added communication between gameplay and main
iblancett Oct 23, 2017
f273cc2
Rearranged environment images
iblancett Oct 23, 2017
31a7cdb
Setup portfolio class
iblancett Oct 23, 2017
163590c
changed file paths to work on Mac
iblancett Oct 23, 2017
5b05cd1
Moved rendered text to setUpE. Course Image loading not working
sokuno222 Oct 24, 2017
30641b9
Fixed rendering error in setUpE
sokuno222 Oct 24, 2017
2c3120d
Readded rendering font to mouseover function
sokuno222 Oct 24, 2017
07ab946
Fixing text overwriting problem
sokuno222 Oct 24, 2017
bd1937a
Fixed text writing over itself and size
sokuno222 Oct 24, 2017
e183459
Moved text rendering to setUpE, Made setUpE run only once.
sokuno222 Oct 26, 2017
47cb257
Unpushed changes
iblancett Oct 27, 2017
d216f76
Changed some lines to incorporate seperate mouseClicked function
sokuno222 Oct 27, 2017
cf87127
Started integration
iblancett Oct 27, 2017
df10443
Updated graphics
iblancett Oct 27, 2017
a870d23
Put graphics loop in main
iblancett Oct 28, 2017
3dac77b
Added userdefined events for pushing buttons to mouseClicked()
sokuno222 Oct 28, 2017
2435bc3
Added req to mouseClicks for button to not have been pressed before. …
sokuno222 Oct 28, 2017
e82a305
Added button events
iblancett Oct 28, 2017
8155d51
Debug
iblancett Oct 28, 2017
231df00
Fixed bugs, game is now functional, but algo needs to be optimized
iblancett Oct 29, 2017
90fad98
Added the reflection
leonardoliuuu Oct 29, 2017
2efaecc
Made changes to updating images
leonardoliuuu Oct 30, 2017
231e65f
Added b&w course icons to show button was pressed
sokuno222 Oct 30, 2017
a7ed21a
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
453689c
fixed level algo
iblancett Oct 30, 2017
bc190ca
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 30, 2017
a8d39f8
Added b&w icons to mouseClicks so clicked icon is greyed out.
sokuno222 Oct 30, 2017
59af4e5
rearranged code to be more modular
iblancett Oct 30, 2017
7d216f1
created calls to ending function
iblancett Oct 30, 2017
6894572
Added headers
iblancett Oct 30, 2017
4130462
Added course descriptions
sokuno222 Oct 30, 2017
5863d32
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
f63593d
revised project reflection
iblancett Oct 30, 2017
8f2efc1
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
iblancett Oct 30, 2017
646e64c
update on the portfolio image
leonardoliuuu Oct 30, 2017
8bfb444
Changing color
sokuno222 Oct 30, 2017
6f88e50
Fixed portfolio function
iblancett Oct 30, 2017
62e75c2
Update on README
leonardoliuuu Oct 30, 2017
4b50ce2
Created ending.py to make text ending
sokuno222 Oct 30, 2017
9dcf674
Added ending files.
sokuno222 Oct 30, 2017
245d255
Merge branch 'master' of https://github.com/iblancett/InteractiveProg…
sokuno222 Oct 30, 2017
340cbe8
Added call to ending function
iblancett Oct 30, 2017
b96b29e
Fixed ending
iblancett Oct 30, 2017
4549dc2
Got endings working, window no longer quits
sokuno222 Oct 30, 2017
e773ac0
Fixed typo
sokuno222 Oct 30, 2017
e6a9e17
Fixed icon descriptions to match the correct icons
sokuno222 Oct 30, 2017
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
Prev Previous commit
Next Next commit
Fixed portfolio function
  • Loading branch information
iblancett committed Oct 30, 2017
commit 6f88e50d387af4183e557e57a94609fe49d890b7
Binary file added Source/Level_Icons/robo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions Source/courses.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
label,course,description,max,dependencies
mech,Mechanical Prototyping,Learn techniques for mechanical design... and how to not kill your teammates,5,3bees1 4focs3 4elec2 5mats1
bees,Sustainable Beekeeping,Beekeeping. Good for the environment. Ben Linder. Good for the soul.
,3,2focs1 3mats2
focs,Fundamentals of Computer Science,Step one:FOCS. Step two:Offical Hacker d00d. Step 3:Rule the world.,3,3elec1
elec,Electricity and Magnetism,Does anyone know how electricity and magnetism work?,2,0
mats,Material Science,Material science. Explore materials. Self-explanatory...right?,2,0
robo,Fundamentals of Robotics,Death by Dave, but in a project-based-learning way.,1,2mech5 2bees3 2focs3 2elec2 2mats2
label,course,description,max,dependencies,xrange
mech,Mechanical Prototyping,Learn techniques for mechanical design... and how to not kill your teammates,5,3bees1 4focs3 4elec2 5mats1,841
bees,Sustainable Beekeeping,Beekeeping. Good for the environment. Ben Linder. Good for the soul.,3,2focs1 3mats2,51
focs,Fundamentals of Computer Science,Step one:FOCS. Step two:Offical Hacker d00d. Step 3:Rule the world.,3,3elec1,367
elec,Electricity and Magnetism,Does anyone know how electricity and magnetism work?,2,0,209
mats,Material Science,Material science. Explore materials. Self-explanatory...right?,2,0,683
robo,Fundamentals of Robotics,Death by Dave but in a project-based-learning way.,1,2mech5 2bees3 2focs3 2elec2 2mats2,525
4 changes: 2 additions & 2 deletions Source/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def setup(self, config):
self.description = config['description']
self.max = config['max']
self.reqs = config['dependencies']
self.range = config['xrange']
self.lvl = 0
self.order = 0

Expand All @@ -54,6 +55,7 @@ def populate():
'description':'DESCRIPTION',
'max': NUMBER OF LEVELS,
'dependencies': 'LVL' + 'NEEDEDCOURSE' + 'NEEDEDLEVEL',
'xrange': 'MIN MAX'
}

returns: dictionary of all course instances
Expand All @@ -71,5 +73,3 @@ def populate():
new_course = (create_course(row))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outer parens aren't necessary

all_courses[new_course.label] = new_course
return all_courses

populate()
29 changes: 19 additions & 10 deletions Source/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import os
import sys

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put all the functions below into a class for the screen. You're changing an object in your game essentially which is when classes are really nice :)

def initialize():
def initialize(descriptions):
""" Initializes graphic screen.
"""
pygame.init()
screen = pygame.display.set_mode((1000, 700))
pygame.font.init()
font = pygame.font.Font(None,30)
font = pygame.font.Font(None,26)
pygame.mouse.set_pos([500,350])
pygame.mouse.set_visible(True)
text = setUpE(screen, font)
text = setUpE(screen, font, descriptions)
return [screen, text]

def setUpE(screen, font):
def setUpE(screen, font, descriptions):
'''This code is to load the basic backscreen for the program.
setUpE is NOT to be run whenever the user clicks something, just at beginning.'''
#loading/scaling images (loads as S___ for start, scaled as F___ for final)
Expand Down Expand Up @@ -53,12 +53,12 @@ def setUpE(screen, font):
screen.blit(FMechProto_Icon,(841,550))
#render text
text = []
text.append(font.render("Bees?", 1, (255,255,255)))
text.append(font.render("Magic", 1, (255,255,255)))
text.append(font.render("Hacker d00d", 1, (255,255,255)))
text.append(font.render("beep boop", 1, (255,255,255)))
text.append(font.render("hm...", 1, (255,255,255)))
text.append(font.render("Mechie Art", 1, (255,255,255)))
text.append(font.render("Sustainable Beekeeping: %s" % descriptions[0], 1, (255,255,255)))
text.append(font.render("Electricity and Magnetism: %s" % descriptions[1], 1, (255,255,255)))
text.append(font.render("Fundamentals of Computer Science: %s" % descriptions[2], 1, (255,255,255)))
text.append(font.render("Fundamentals of Robotics: %s" % descriptions[3], 1, (255,255,255)))
text.append(font.render("Material Science: %s" % descriptions[4], 1, (255,255,255)))
text.append(font.render("Mechanical Prototyping: %s" % descriptions[5], 1, (255,255,255)))
#Reload display / return font
pygame.display.flip()
return text
Expand Down Expand Up @@ -126,3 +126,12 @@ def updateImg(screen, img, location):
loaded = pygame.transform.scale(pygame.image.load(img), (108, 100))
screen.blit(loaded, location)
pygame.display.flip()

def update_portfolio(courses, screen):
labels = list(courses)
pygame.draw.rect(screen, (255,255,255), (0,10,1000,440))
for label in labels:
if courses[label].lvl:
img = 'Source/Level_Icons/%s%s.png' % (label, courses[label].lvl)
xmin = int(courses[label].range)
updateImg(screen, img, (xmin, 150))
4 changes: 2 additions & 2 deletions Source/gameplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def level_up(self):
""" level up any courses that meet all requirements starting with the
user's previous choice

returns: None
returns: All courses

Examples:
>>> test_game = Gameplay(courses.populate(), 0)
Expand All @@ -64,7 +64,7 @@ def level_up(self):
# Check for maxed out and for dependencies
if int(self.courses[label].lvl) < int(self.courses[label].max) and self.check_reqs(label):
self.courses[label].lvl = self.courses[label].lvl + 1
return
return self.courses

def check_reqs(self, label):
""" given a course label, checks whether all dependencies are met
Expand Down
17 changes: 9 additions & 8 deletions Source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
from gameplay import Gameplay
import sys
import pygame
import ending
#import ending
from environment import *

# INITIALIZE GAME

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code below should be in a function or a class. It's always good practice to wrap things up and not have them free floating in a file.

BUTTON = pygame.USEREVENT + 1
init_courses = courses.populate()
text_screen = environment.initialize()
text_screen = initialize([init_courses[label].description for label in list(init_courses)])
screen = text_screen[0]
text = text_screen[1]
control = Gameplay(init_courses)
Expand All @@ -26,15 +26,16 @@
sys.exit(1)
if event.type == BUTTON:
done = control.add_order(event)
control.level_up()
courses = control.level_up()
update_portfolio(courses, screen)
mouseOver(text, screen)
mouseClicks(control.order, BUTTON, screen)
pygame.display.flip()
pygame.event.pump()

# EVALUATE ENDING AND SEND TO VICTORY SCREEN
victory = control.evaluate_portfolio()
if victory == 1:
ending.determine(victory, ["%s: %s" % (control.courses[course].name, 'MAX') for course in control.courses])
else:
ending.determine(victory, ["%s: %s" % (control.courses[course].name, control.courses[course].lvl) for course in control.courses])
#victory = control.evaluate_portfolio()
#if victory == 1:
# ending.determine(victory, ["%s: %s" % (control.courses[course].name, 'MAX') for course in control.courses])
#else:
# ending.determine(victory, ["%s: %s" % (control.courses[course].name, control.courses[course].lvl) for course in control.courses])
44 changes: 0 additions & 44 deletions Source/portfolio.py

This file was deleted.