diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -2,6 +2,7 @@ import pygame import time import os import sys +import math from pygame import K_ESCAPE from pygame.locals import * @@ -25,6 +26,9 @@ pygame.display.set_caption("Ranger") window_h, window_w = screen.get_size () +if window_h > 1024: + screen = pygame.display.set_mode( (800,640) ) +window_h, window_w = screen.get_size () # Tree trees = [] @@ -128,7 +132,7 @@ while True: # Tree cutters kills trees for arbol in trees: for cortador in cutter: - if cortador.collides_with(arbol): + if cortador.collides_with(arbol) and arbol.air == 1: cortador.cut_tree = True arbol.draw_alert(screen) cortador.cut_time += 1 @@ -148,10 +152,10 @@ while True: ## SCORE IS DRAWN AFTER EVERYTHING ELSE # Score is equal to amount of trees for arbol in trees: - air += 1 + air = air + arbol.air # HUD text - hud_text = "Air: " + str(air) + " Score: " + str(score) + hud_text = "Air: " + str(air) + " Score: " + str(score) + " Speed: " + str(ranger.speed) font = pygame.font.Font(None, 36) text_hud = font.render( hud_text , 1, (0, 0, 0, 0)) screen.blit(text_hud, (0, 0)) @@ -168,7 +172,17 @@ while True: cutter_difficulty = 100 elif score <= 150: cutter_difficulty = 50 - + + # Speed based on air + if air > 0: + if ranger.speed > 1.0 : + ranger.speed = math.fabs(air/10) + else: + ranger.speed = 1 + else: + exit() + + # Score updates after being shown air = 0 |