Hello. I have been having trouble with this pygame program. I am trying to imitate a wind turbine.
However, when I run the command, it returns with a blank black screen with a square.
What is wrong??
Here's the program:

import pygame

#############################################
# Written by P****** ******* and V***** *** #
# Copyright 2012                            #
#############################################

pygame.init()

# Gets Information
humidity = float(raw_input("Enter Humidity Percentile"))
altitude = float(raw_input("Enter Altitude in M"))
wind_velocity = float(raw_input("Enter Wind Velocity"))
air_density = float(raw_input("Enter Air Density"))
turbine = float(raw_input("Which Turbine would You Like to Test?"))


#Turbine information
if turbine == 1:
    print "YES"
    final_altitude = altitude + 90
    swept_area_of_blades = 5342.90625
else:
    print "NO!"


# Basic GUI stuff
size = [500,500]
screen = pygame.display.set_mode(size)
pygame.display.set_caption('Wind Simulator V 0.5')
clock = pygame.time.Clock()


# Engine variables

RPM = 0
running = True
FPS = 30
windturbineback = pygame.image.load("bin/back.png")
windturbine = pygame.image.load("bin/windmill.png")
windstalk = pygame.image.load("bin/windstalk.png")

total_energy_part_one = .5 * air_density * swept_area_of_blades 
total_energy_part_two = total_energy_part_one * wind_velocity * wind_velocity * wind_velocity
extracted_energy = (2 * total_energy_part_two) / 3

# Colors
blue = (0,0,255)
white = (255,255,255)
black = (0,0,0)
font = pygame.font.SysFont("comicsansms", 15)


# Main

print "Started Wind Sim"

while running == True:

    # Controls
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
                    running = False

    # Render Code
    screen.fill(white)


    # Prepares variables to blit
    blitFPS = font.render("FPS - %d" % FPS,True,black)
    blitRPM = font.render("RPM - %d" % RPM,True,black)
    blitHumidity = font.render("Humidity - %r %%" % humidity,True,black)
    blitAltitude = font.render("Altitude - %r M" % altitude,True,black)
    blitPower = font.render("Power Output - %d Watts" % extracted_energy,True,black)


    # Blits the little wind turbine
    screen.blit(windturbineback, [0, 400])
    screen.blit(windstalk, [48, 450])
    screen.blit(windturbine, [0, 400])

    # Blits all the variables
    screen.blit(blitFPS, [10, 20])
    screen.blit(blitRPM, [10, 35])
    screen.blit(blitHumidity, [10, 50])
    screen.blit(blitAltitude, [10, 65])
    screen.blit(blitPower, [10, 80])





clock.tick(FPS)
pygame.display.flip
pygame.quit

Thanks

Recommended Answers

All 3 Replies

Update the display inside the while loop.

Thank you Frensi.
However, when I tried to update it inside the while loop, it said "IndentationError: unindent does not match any outer indentation level"
Thanks you for your answer though,
Victor

Never mind, I got it now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.