Repository navigation
Turn in the Mini Project 4 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Subeen-Kim
wants to merge
38
commits into
sd17fall:master
Choose a base branch
from
jwen2:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b70ae97
location. py is the function indicating the site of pathogen, and imp…
Subeen-Kim c40af24
Version 1 Skeleton UI
jwen2 086c735
Added Click Interaction
jwen2 104e084
Virus Draft - RAW
victorbianchi 2cc94cd
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
victorbianchi d61d10c
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
Subeen-Kim b2a41e0
1st trial about time and input handling
Subeen-Kim a913dc0
Added Time and Pause Botton on Bottom Right
jwen2 8486919
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
jwen2 bbf1fd4
Country Population Database
victorbianchi b80dbf4
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
victorbianchi 262f5c1
Attempting to Add Circle Interaction
jwen2 7fdce31
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
jwen2 4273f42
UI Screen Change Test - Press C to Change Screens/Run Functions
jwen2 558de66
Useful File
jwen2 20379d8
new virus format with gorgeous time stuff
Subeen-Kim db39c83
propagation and death types are added
Subeen-Kim d73f897
Added display for total infected/total pop. Fixed Initial Infection
jwen2 95155e0
Added title screen and instructions
jwen2 16cbf96
modification about death stops at 5
Subeen-Kim a11db98
Added rounds function
vtbianchi 741f559
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
vtbianchi d8be63f
now it stops at zero
Subeen-Kim 7e115a0
Upgrade points is updated
Subeen-Kim f49c50c
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
Subeen-Kim 0a42179
Added End Game Screen
jwen2 6fd3c15
Added upgrade possibility
vtbianchi 1fae333
I modified Upgrade_Point into linear function
Subeen-Kim 4e5d19a
death rate modified
Subeen-Kim 6b59ba4
ReadMe File
vtbianchi d5c9fd7
Read Me File
vtbianchi 1d851ea
Added upgrades
vtbianchi 6086d69
Added Upgrade Points Box, Slow'd down points gain, Fixed upgrade cost
jwen2 ef209e0
documentation is improved
Subeen-Kim a2e05c5
Wirte-up and Reflection file
Subeen-Kim 3cb86bd
Reflection
vtbianchi b2326b7
Added doctor and cure funtionality, Fixed death bug (stuck at 15), ad…
jwen2 9a12fb2
Merge branch 'master' of https://github.com/jwen2/InteractiveProgramming
jwen2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
new virus format with gorgeous time stuff
- Loading branch information
commit 20379d8d6c31d014fcae835e0e4967159659294d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,17 +6,21 @@ | |
|
|
||
| pygame.init() | ||
|
|
||
|
|
||
| class Ball: | ||
| def __init__(self, x, y, radius=50, color=RED, infected_pop=0): | ||
| class Country: | ||
| def __init__(self, x, y, max_pop, radius=50, color=RED, infected_pop=0, infected_rate=1.1): | ||
| self.initial_pos = (x, y) | ||
| self.x = x | ||
| self.y = y | ||
| self.color = color | ||
| self.radius = radius | ||
| self.infected_pop = infected_pop | ||
| self.infected_rate = infected_rate | ||
| self.max_pop = max_pop | ||
|
|
||
| #def step | ||
| def step(self): | ||
| if self.infected_pop <= self.max_pop: | ||
| self.infected_pop = self.infected_pop * self.infected_rate | ||
| print(self.infected_pop) | ||
|
|
||
| def draw(self): | ||
| pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), | ||
|
|
@@ -33,25 +37,32 @@ def contains_pt(self, pt): | |
|
|
||
| screen = pygame.display.set_mode((640, 480)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of this setup code could go into a |
||
|
|
||
| ball1 = Ball(320, 240, radius=80) | ||
| country1 = Country(320, 240, 200, radius=80) | ||
|
|
||
| countries = [country1] | ||
|
|
||
| balls = [ball1] | ||
| Time = 0 | ||
| clock = pygame.time.Clock() | ||
|
|
||
| running = True | ||
| while running: # forever -- until user clicks in close box | ||
| for event in pygame.event.get(): | ||
| if event.type == pygame.MOUSEBUTTONDOWN: | ||
| for ball in balls: | ||
| if ball.contains_pt(pygame.mouse.get_pos()): | ||
| if ball.infected_pop == 0: | ||
| ball.infected_pop = ball.infected_pop + 1 | ||
| print(ball.infected_pop) | ||
| for country in countries: | ||
| if country.contains_pt(pygame.mouse.get_pos()): | ||
| if country.infected_pop == 0: | ||
| country.infected_pop = country.infected_pop + 1 | ||
| print(country.infected_pop) | ||
| if pygame.time.get_ticks() > (Time + 1000): | ||
| Time = pygame.time.get_ticks() | ||
| country.step() | ||
| if event.type == pygame.QUIT: | ||
| running = False | ||
|
|
||
| screen.fill(BLACK) # erases screen | ||
| for ball in balls: | ||
| ball.draw() | ||
| for country in countries: | ||
| country.draw() | ||
|
|
||
| pygame.display.update() # updates real screen from staged screen | ||
|
|
||
| pygame.quit() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class could be put into its own file and imported.