Skip to main content

a script for simulating a object with a direction that can move in said direction

Project description

https://github.com/XKMR/PythonMovingBot

PythonMovingBot

this is a script for simulating a object with a direction that can move in said direction

demo:

#this is a demo program


try:
    while(True):
        smturn("right")
        print(displayCurrentPlace(currentX, currentY, currentDirection))
        sleep(0.5)
        for i in range(11): 
            smforward(1)
            print(displayCurrentPlace(currentX, currentY, currentDirection))
            sleep(0.1)
except KeyboardInterrupt:
    print("X: ",currentX," Y: ",currentY)
    print("pointing at ", currentDirection)

functions:

turn(): turnes the object by 90 degrees clockwise or counterclockwise arguments should be: "CC/CW", the current direction returns: the new direction ("up" , "down" , "left" , "right")

forward():

adds or subtracts an amount based on the inputed steps to/from X and Y (moving the object in the direction that is's looking in) arguments: the current X, the current Y, the current direction, a number of steps returns: the new x,y

smturn():

simplifies the turn command by removing the need for inputing the current direction requires the turn() function to work, requires a variable named "currentDirection" to work arguments: "left"/"right" variables required to work: currentDirction functions required to work: turn() returns: 0

smforward():

simplifies the turn command by removing the need for inputing anything other than the amount of steps that is going to be taken. arguments: int variables required to work: currentX, currentX, currentDirection functions required to work: forward() returns: 0

displayCurrentPlace():

makes a 20x20 "screen" that will display the place and direction of the object. note that this needs some improvements arguments: variables needed to work: currentX, currentX, currentDirection returns: 0

variables: currentX: the current position of the object on the X axis currentY: the current position of the object on the Y axis currentDirection: the current direction of the object ("up","down","left","right")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

MovingBot-0.0.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

MovingBot-0.0.1-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page