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
base: master
Are you sure you want to change the base?
Changes from 1 commit
b70ae97
c40af24
086c735
104e084
2cc94cd
d61d10c
b2a41e0
a913dc0
8486919
bbf1fd4
b80dbf4
262f5c1
7fdce31
4273f42
558de66
20379d8
db39c83
d73f897
95155e0
16cbf96
a11db98
741f559
d8be63f
7e115a0
f49c50c
0a42179
6fd3c15
1fae333
4e5d19a
6b59ba4
d5c9fd7
1d851ea
6086d69
ef209e0
a2e05c5
3cb86bd
b2326b7
9a12fb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import os | ||
| import pygame | ||
| import random | ||
| import math | ||
|
|
||
| BLACK = (0, 0, 0) | ||
| RED = (255, 0, 0) | ||
|
|
@@ -14,10 +13,10 @@ | |
|
|
||
| class Country: | ||
| """ | ||
| Each country has its maximum population without any inflected people, | ||
| Each country has its maximum population without any infected people, | ||
| before we do click the country in the beginning of game. | ||
| """ | ||
| def __init__(self, x, y, max_pop, radius=50, color=RED, infected_pop=0, infected_rate=1.1, dead_pop = 0): | ||
| def __init__(self, x, y, max_pop, radius=50, color=RED, infected_pop=0, infected_rate=1.1, dead_pop=0, death_rate=1): | ||
| self.initial_pos = (x, y) | ||
| self.x = x | ||
| self.y = y | ||
|
|
@@ -147,8 +146,6 @@ def propagation(self, other): | |
| abilities = 1.0 | ||
| symptoms = 1.0 | ||
|
|
||
| death_rate = 1 | ||
|
|
||
| running = True | ||
| while running: # forever -- until user clicks in close box | ||
| for event in pygame.event.get(): | ||
|
|
@@ -159,7 +156,8 @@ def propagation(self, other): | |
| country.infected_pop = country.infected_pop + 1 | ||
| infectionindex = infectionindex - 1 | ||
| country_pop_index = country | ||
| #print(country.infected_pop) | ||
| """now our pathogen embarks on infection!""" | ||
|
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. Use inline comments (like this: |
||
|
|
||
| if event.type == pygame.KEYDOWN: | ||
| #If upgrade infection rate | ||
| if event.key == pygame.K_t: | ||
|
|
@@ -180,28 +178,28 @@ def propagation(self, other): | |
| country.infected_rate = country.infected_rate * 1.15 | ||
| print (country.infected_rate) | ||
|
|
||
| """ | ||
| now our pathogen embarks on infection! | ||
| type: step, death, propagation | ||
|
|
||
| Modify Time + XXXX to modify the speed of the game. | ||
| """ | ||
| """Modify Time + XXXX to modify the speed of the game.""" | ||
| if pygame.time.get_ticks() > (Time + 100): | ||
| Time = pygame.time.get_ticks() | ||
| if all(country.max_pop == 0 for country in countries) == True: | ||
| running = False | ||
| endscreen = True | ||
| #print ('For each country: (infected ratio, total population)', (country1.infected_ratio(),country1.max_pop), (country2.infected_ratio(),country2.max_pop), (country3.infected_ratio(),country3.max_pop)) | ||
|
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. I suggest removing print statements and logs before submitting pull requests (in the future) |
||
| Total_infected = 0 | ||
|
|
||
| """ | ||
| Infection types: step, death, propagation | ||
| Upgrade Point is given at every step. | ||
| """ | ||
| for country in countries: | ||
| country.step() | ||
| country.death() | ||
| Total_infected += (country.infected_pop + country.dead_pop) | ||
| if infectionindex == 0: | ||
| Upgrade_Point += random.randint(1,3) | ||
| for other in countries: | ||
| if country != other: | ||
| country.propagation(other) | ||
| Upgrade_Point = int(math.pow(1.02,Total_infected)-1) | ||
| print (Upgrade_Point) | ||
|
|
||
| if event.type == pygame.QUIT: | ||
| running = False | ||
|
|
@@ -213,12 +211,10 @@ def propagation(self, other): | |
| """ | ||
| the number of infected, dead, and total population is displayed whenever we click certain country | ||
| """ | ||
| screen.blit(font.render('Infected:%.2d'%(country_pop_index.infected_pop) + ' ' +'Dead:%.2d'%(country_pop_index.dead_pop) + ' '+ 'Alive:%.2d'%(country_pop_index.max_pop) , True, (0, 255, 255)), (0, 440)) | ||
| screen.blit(font.render('Infected:%.2d'%(country_pop_index.infected_pop) + ' ' +'Dead:%.2d'%(country_pop_index.dead_pop) + ' '+ 'Alive:%.2d'%(country_pop_index.max_pop) +' '+'Upgrade Point:%.2d'%(Upgrade_Point) , True, (0, 255, 255)), (0, 440)) | ||
| pygame.display.update() # updates real screen from staged screen | ||
|
|
||
|
|
||
|
|
||
|
|
||
| while endscreen: | ||
| screen.fill(background_color) | ||
| for event in pygame.event.get(): | ||
|
|
||
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.