cleaning time
This commit is contained in:
parent
43d91e178d
commit
4d807fe0c9
2
game.py
2
game.py
@ -61,7 +61,7 @@ while(1):
|
|||||||
if(type(item) == House):
|
if(type(item) == House):
|
||||||
item.generate_rubbish()
|
item.generate_rubbish()
|
||||||
|
|
||||||
utils.get_statistics(all_sprites)
|
hud.get_statistics(all_sprites)
|
||||||
display.flip()
|
display.flip()
|
||||||
fps_clock.tick(FPS)
|
fps_clock.tick(FPS)
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
from sprites.house import House
|
||||||
|
from sprites.garbage_collector import Garbage_collector
|
||||||
from config import HUD_HEIGHT
|
from config import HUD_HEIGHT
|
||||||
HUD_COLOR = (51,21,4)
|
HUD_COLOR = (51,21,4)
|
||||||
WHITE = (255,255,255)
|
WHITE = (255,255,255)
|
||||||
@ -22,3 +24,33 @@ class Hud():
|
|||||||
map_glass_text = font.render("Glass: 0",True,WHITE)
|
map_glass_text = font.render("Glass: 0",True,WHITE)
|
||||||
overall_text = font.render("Garbage thrown away: 0",True,WHITE)
|
overall_text = font.render("Garbage thrown away: 0",True,WHITE)
|
||||||
GAMEWINDOW.blit(overall_text,(20, 20))
|
GAMEWINDOW.blit(overall_text,(20, 20))
|
||||||
|
|
||||||
|
def get_statistics(self, all_sprites):
|
||||||
|
###Garbage collector stats###
|
||||||
|
gc_taken_space_plastic = 0
|
||||||
|
gc_taken_space_metal = 0
|
||||||
|
gc_taken_space_glass = 0
|
||||||
|
gc_trash_space = 10
|
||||||
|
|
||||||
|
###Board stats###############
|
||||||
|
plastic_left = 0
|
||||||
|
metal_left = 0
|
||||||
|
glass_left = 0
|
||||||
|
total_gathered = 0
|
||||||
|
|
||||||
|
for item in all_sprites:
|
||||||
|
if(type(item) == House):
|
||||||
|
rubbish = item.get_rubbish_data()
|
||||||
|
plastic_left += rubbish[0]
|
||||||
|
glass_left += rubbish[1]
|
||||||
|
metal_left += rubbish[2]
|
||||||
|
if(type(item) == Garbage_collector):
|
||||||
|
space_taken = item.get_space_data()
|
||||||
|
gc_taken_space_plastic += space_taken.get("plastic")
|
||||||
|
gc_taken_space_glass += space_taken.get("glass")
|
||||||
|
gc_taken_space_metal += space_taken.get("metal")
|
||||||
|
total_gathered += item.get_collect_data()
|
||||||
|
|
||||||
|
print("plastic left: "+str(plastic_left)+" | glass left: "+str(glass_left)+" | metal left: "+str(metal_left))
|
||||||
|
print(" plastic: "+str(gc_taken_space_plastic)+"/"+str(gc_trash_space)+" | glass: "+str(gc_taken_space_glass)+"/"+str(gc_trash_space)+" | metal: "+str(gc_taken_space_metal)+"/"+str(gc_trash_space))
|
||||||
|
print("### TOTAL COLLECTED: "+str(total_gathered)+" ###")
|
||||||
|
33
utils.py
33
utils.py
@ -87,36 +87,3 @@ def generate_garbage_collector(all_sprites, obstacles_coords):
|
|||||||
all_sprites.add(gc)
|
all_sprites.add(gc)
|
||||||
return gc
|
return gc
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
|
||||||
##GET STATISTICS##################################################################
|
|
||||||
|
|
||||||
def get_statistics(all_sprites):
|
|
||||||
###Garbage collector stats###
|
|
||||||
gc_taken_space_plastic = 0
|
|
||||||
gc_taken_space_metal = 0
|
|
||||||
gc_taken_space_glass = 0
|
|
||||||
gc_trash_space = 10
|
|
||||||
|
|
||||||
###Board stats###############
|
|
||||||
plastic_left = 0
|
|
||||||
metal_left = 0
|
|
||||||
glass_left = 0
|
|
||||||
total_gathered = 0
|
|
||||||
|
|
||||||
for item in all_sprites:
|
|
||||||
if(type(item) == House):
|
|
||||||
rubbish = item.get_rubbish_data()
|
|
||||||
plastic_left += rubbish[0]
|
|
||||||
glass_left += rubbish[1]
|
|
||||||
metal_left += rubbish[2]
|
|
||||||
if(type(item) == Garbage_collector):
|
|
||||||
space_taken = item.get_space_data()
|
|
||||||
gc_taken_space_plastic += space_taken.get("plastic")
|
|
||||||
gc_taken_space_glass += space_taken.get("glass")
|
|
||||||
gc_taken_space_metal += space_taken.get("metal")
|
|
||||||
total_gathered += item.get_collect_data()
|
|
||||||
|
|
||||||
print("plastic left: "+str(plastic_left)+" | glass left: "+str(glass_left)+" | metal left: "+str(metal_left))
|
|
||||||
print(" plastic: "+str(gc_taken_space_plastic)+"/"+str(gc_trash_space)+" | glass: "+str(gc_taken_space_glass)+"/"+str(gc_trash_space)+" | metal: "+str(gc_taken_space_metal)+"/"+str(gc_trash_space))
|
|
||||||
print("### TOTAL COLLECTED: "+str(total_gathered)+" ###")
|
|
||||||
##################################################################################
|
|
||||||
|
Loading…
Reference in New Issue
Block a user