All pastes #17863 Raw Edit

Stuff

public text v1 · immutable
#17863 ·published 2005-07-16 21:55 UTC
rendered paste body
#python storm test
#done
# - x/y position
#to do
# - speed

#import
import time

#objects
obj1 = "human"
obj2 = "car"
obj3 = "house"
tor = "tornado"

#settings
tor_pos_x = 0
tor_pos_y = 0
direction_x = 0
direction_y = 0
tor_speed = 10 #max 0 > 10 (windforce)
tor_time = 0 #set by speed converter

#functions
def storm(tor, speed, x, y):
    print tor, tor_speed, tor_pos_x, tor_pos_y
def input():
    return raw_input("input: ")
def speed_converter(x): #def speed_converter(x, tor_speed = tor_speed):
    return (1.0 - ((x-1.0)/10.0))

#storm loop
while 1:
    #spawn storm
    storm(tor, tor_speed, tor_pos_x, tor_pos_y)

    #x forwards
    if direction_x == 0 and tor_pos_x <= 21: #maximum x
        tor_pos_x +=1
        time.sleep(speed_converter(tor_speed))
    #x direction forwards/backwards check
    if tor_pos_x == 21:
        direction_x = 1
    if tor_pos_x == 0:
        direction_x = 0
    #x backwards
    if direction_x == 1 and tor_pos_x >= 0:
        tor_pos_x -=1
        time.sleep(speed_converter(tor_speed))

    #y forwards
    if direction_y == 0 and tor_pos_y <=21: #maximum y
        tor_pos_y +=1
        time.sleep(speed_converter(tor_speed))
    #y direction forwards/backwards check
    if tor_pos_y == 21:
        direction_y = 1
    if tor_pos_y == 0:
        direction_y = 0
    #y backwards
    if direction_y == 1 and tor_pos_y >= 0:
        tor_pos_y -=1
        time.sleep(speed_converter(tor_speed))