Hello,
I have been working on a code to simulate wind turbines.
However, I can't seem to rotate the wind turbine.
Here is the code.
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 = 1
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)
angle = 60
width1, height1 = windturbine.get_size()
image2 = pygame.transform.rotate(windturbine, angle)
width2,height2 = image2.get_size()
# Main
print "Started Wind Sim"
while running:
# 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])
screen.blit = (image2,[round(0 - (width1 - width2)/2),round(400 - (height1 - height2)/2)])
# 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])
pygame.display.flip()
clock.tick(FPS)
pygame.quit
Thanks