Exemplo n.º 1
0
    def start(self):
        pg.init()
        cat = Cat()
        mouse = Mouse()
        screen = pg.display.set_mode((1024, 768))
        clock = pg.time.Clock()
        running = True
        sprite = pg.sprite.Group()
        sprite.add(cat)
        sprite.add(mouse)
        calcCoords = USEREVENT + 1

        pg.time.set_timer(calcCoords, 50)

        while running:

            if pg.event.get(calcCoords):
                mouse.calcCoords()
                cat.calcCoords()

            sprite.update([cat.pos, mouse.pos])
            self.AuraDetection([cat.pos, mouse.pos], cat, mouse)
            clock.tick(60)
            pg.display.set_caption("{:.2f}".format(clock.get_fps()))
            screen.fill((250, 250, 250))
            for event in pg.event.get():
                if event.type == pg.QUIT:
                    running = False

            sprite.draw(screen)
            pg.display.flip()
Exemplo n.º 2
0
def main(argv):
    argv = ['', 'Labyrinths/Laby7.txt']
    labyrinth = Labyrinth.load_from_file(argv[1])
    mouse = Mouse(labyrinth)

    while not mouse.has_reached_exit():
        mouse.move()
        print(mouse)
Exemplo n.º 3
0
    def foo():
        angLenTable = empty((256, 256), dtype=object)

        for y in range(0, 255):
            newy = y - 128
            for x in range(0, 255):
                newx = x - 128
                if (newx != 0 and newy != 0):
                    angle = float(math.atan(Decimal(newy) / Decimal(newx)))
                    if (angle == 0 or angle == math.pi):
                        length = math.fabs(newx)
                    else:
                        length = math.fabs((newy) / (math.sin(angle)))
                        angLenTable[x][y] = Mouse(newx, newy, angle, length)
                else:
                    angLenTable[x][y] = Mouse(0, 0, 0, 0)
Exemplo n.º 4
0
    def initAngLenTable(self):

        for y in range(0, 255):
            newy = y - 128
            for x in range(0, 255):
                newx = x - 128
                if (newx != 0 and newy != 0):
                    angle = float(math.atan(Decimal(newy) / Decimal(newx)))
                    if (angle == 0 or angle == math.pi):
                        length = math.fabs(newx)
                    else:
                        length = math.fabs((newy) / (math.sin(angle)))
                        self.angLenTable[x][y] = Mouse(newx, newy, angle,
                                                       length)
                else:
                    self.angLenTable[x][y] = Mouse(0, 0, 0, 0)
Exemplo n.º 5
0
 def build(self):
     self.game = Game()
     self.keyboard = Keyboard()
     self.mouse = Mouse()
     self.settings = Settings()
     # Create loop with 1/60 sec delay
     Clock.schedule_interval(self.update, 1.0 / 60.0)
     return self.game
Exemplo n.º 6
0
 def __init__(self, tipi_io):
     # Extend this list to register new special request handlers
     #
     self.__reg = {
         0x20: Mouse(tipi_io),
         0x21: TipiVariable(tipi_io),
         0x22: TiSocket(tipi_io),
     }
Exemplo n.º 7
0
def create_new_user(name, age, avatar, password):
    """
    Создает нового пользователя и присваивает ему роль
    """
    rand = random.random()
    if rand > 0.7:
        return Owl(name, age, avatar, password)
    else:
        return Mouse(name, age, avatar, password)
def treats_event(event, board: Board, mouse: Mouse) -> bool:
    """treats pygame events

            Parameters:
                    event (Event): pygame event
                    board (Board): scenery that contains the main grid
                    mouse (Mouse): class that control mouse states

            Returns:
                    True (bool): quit game
                    False (bool): stay playing
    """
    if event.type == QUIT:
        return True
    elif event.type == MOUSEBUTTONUP:
        mouse.set_state(False)
    elif event.type == MOUSEBUTTONDOWN:
        mouse.set_state(True)
    return False
Exemplo n.º 9
0
def main():
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit(0)
            if event.type == pygame.MOUSEMOTION:
                x, y = event.pos
        Mouse.update()
        screen.fill((0, 0, 0))
        pygame.draw.line(screen, (255, 255, 255), (width / 2, 20),
                         (width / 2, height - 20))

        for behaviour in AllBehaviours:
            #wywołanie funkcji action dla każdego obiektu, który zostal dodany do AllBehaviours
            behaviour.action()
        pygame.display.update()

        FPS = 30
        fpsClock = pygame.time.Clock()
        fpsClock.tick(FPS)
Exemplo n.º 10
0
 def move(self):
     if self.steering == Steering.Arrows:  #sterowanie lewą paletką - strzałki
         keys = pygame.key.get_pressed()
         if keys[pygame.K_DOWN] and self.y < height - self.p_height:
             self.y += self.speed
         if keys[pygame.K_UP] and self.y > 0:
             self.y -= self.speed
     elif self.steering == Steering.Mouse:  #sterowanie prawą paletką - myszka
         if not self.isPaused:
             movement = Mouse.getDeltaPos()
             self.y += movement[1]
     elif self.steering == Steering.AI:  #przełączanie sterowania prawą paletką na AI
         self.play()
Exemplo n.º 11
0
    def __init__(self, boardLayoutFile):
        # Defined Class Variables
        self.cols, self.rows = None, None
        self.startCol, self.startRow = None, None
        self.endCol, self.endRow = None, None

        # 2d arrays. To be initialized later when length is known.
        self.gridVals = None
        self.obstacles = None

        # Read in file.
        self.readIn(boardLayoutFile)

        # Create the has-a mouse.
        self.mouse = Mouse(self.startCol, self.startRow)
Exemplo n.º 12
0
 def __init__(self, mouse_file="/dev/input/mice", switch_user=False, user="******", group="nogroup"):
     try:
         self.mouse_file = os.open(mouse_file, os.O_RDWR)
     except:
         raise OSError("Mouse file could not be opened")
     print("Mouse device opened")
     
     if switch_user:
         if drop_privileges(user, group):
             print("Privileges dropped")
         else:
             raise OSError("Privilege dropping failed")
     else:
         print("Privilege dropping is disabled")
     
     self.mouse = Mouse(self.mouse_file)
     
     if self.mouse.protocol == Mouse.INTELLI_MOUSE:
         mode = "IntelliMouse"
     elif self.mouse.protocol == Mouse.EXPLORER_MOUSE:
         mode = "Explorer Mouse"
     else:
         mode = "default"
     
     print("Found mouse in {} mode".format(mode))
     
     if self.mouse.protocol == Mouse.DEFAULT_MOUSE:
         #try switching to IntelliMouse protocol
         if self.mouse.setProtocol(Mouse.INTELLI_MOUSE):
             print("Mouse switched to IntelliMouse protocol")
             print("Mouse wheel support enabled")
         else:
             print("Mouse could not be switched to IntelliMouse protocol")
             print("Mouse wheel support disabled")
             print("Buttons 4 and 5 disabled")
     
     if self.mouse.protocol == Mouse.INTELLI_MOUSE:
         #try switching to Explorer Mouse protocol
         if self.mouse.setProtocol(Mouse.EXPLORER_MOUSE):
             print("Mouse switched to Explorer Mouse protocol")
             print("Buttons 4 and 5 enabled")
         else:
             print("Mouse could not be switched to Explorer Mouse protocol")
             print("Buttons 4 and 5 disabled")
    def generate_resources(self):
        unique_random_positions = self.generate_unique_random_positions()
        self.cheese_pos = []

        # self.cheese_pos = [[16, 21], [16, 5], [7, 18]]
        # self.cat = Cat([21, 8])
        # self.mouse = Mouse([21, 16])

        # self.cheese_pos = [[7, 11], [20, 14], [11, 27]]
        # self.cat = Cat([4, 20])
        # self.mouse = Mouse([4, 6])

        for i in range(self.num_of_cheese + 2):

            if i < self.num_of_cheese:
                self.cheese_pos.append(unique_random_positions[i])
            elif i < self.num_of_cheese + 1:
                self.cat = Cat(unique_random_positions[i])
            else:
                self.mouse = Mouse(unique_random_positions[i])
Exemplo n.º 14
0
 def set_type(self):
     self.type = Mouse()
     self.key_set = self.type.key_set
     self.del_key_set = self.type.del_key_set
Exemplo n.º 15
0
 def __init__(self, tipi_io):
     # Extend this list to register new special request handlers
     self.__reg = {0x20: Mouse(tipi_io)}
Exemplo n.º 16
0
from random import randint
from Mouse import Mouse
from Cat import Cat
from Cheese import Cheese
from BFS import BFS
from DFS import DFS
from AStar import AStarSearch
import copy

# Initialize items' position, not used for random map
cheese1 = Cheese([1,10])
cheese2 = Cheese([11, 1])
cheese3 = Cheese([4,8])

cheeseList = [cheese1, cheese2, cheese3]
mouse = Mouse([6, 4])
cat = Cat([10, 7])

MAP_HEIGHT = 12
MAP_WIDTH = 12
searchMethod = BFS()


myMap = MapState(None, cheeseList, mouse, cat, MAP_WIDTH, MAP_HEIGHT)
# set random positions
myMap.setInitState()

# ------------------For random map---------------
while(searchMethod.ifCatWin == False):
    print("Generating a random map...")
    searchMethod = BFS()
Exemplo n.º 17
0
from Tkinter  import *                  # Import everything from Tkinter
from Arena    import Arena              # Import our Arena
from Cat      import Cat                # Import our Cat
from Mouse    import Mouse              # Import our Statue
from Statue   import Statue             # Import our Statue
from Vector   import *                  # Import everything from our Vector
from globalVars import *                # Import everything from globalVars
from random   import random             # Import random

tk = Tk()                               # Create a Tk top-level widget
arena = Arena(tk, 800, 600, padx=12, pady=6) # Create an Arena widget, arena
arena.pack()                            # Tell arena to pack itself on screen

midX = arena.width/2                    # Horizontal center of window
midY = arena.height/2                   # Vertical center of window
mouseAngle = random()*360*scaleRad      # Random mouse angle to initialize
catAngle = random()*360*scaleRad        # Random cat angle to initialize
catRadius = 5                           # Random cat radius to initialize

statue = Statue(Vector(midX,midY), 0)   # Create a statue in center of arena, arbitrary heading
arena.add(statue)                       # Add statue

mouse = Mouse(Vector(midX + statue.radius*scalePixel*cos(mouseAngle), midY - statue.radius*scalePixel*sin(mouseAngle)), 0, arena, statue) # Create a mouse at right edge of statue, arbitrary heading since it will be overwritten in initialization
arena.add(mouse)                        # Add mouse
 
cat = Cat(Vector(midX + catRadius*scalePixel*cos(catAngle), midY - catRadius*scalePixel*sin(catAngle)), 0, arena, statue, mouse) # Create a cat at given angle and radius, arbitrary heading since it will be overwritten in initialization
arena.add(cat, "cat")                   # Add cat and specify that it's a cat as extra argument

tk.mainloop()                           # Enter the Tkinter event loop
fileWriteNameIterator = 'C:/Users/drunk/PycharmProjects/pythonProject/Pygame Mechanism Module/Pygame Mechanisms Projects/Senior Design/Achievable Mechanisms/03262021.csv'

screen_dim_pix = 800
screen_dim_inch = 150

v.time_delay = 0

screen = Screen(screen_dim_pix, screen_dim_inch)

arm1 = Arm(screen, sd.linkLength1, sd.linkLength2, sd.actuator1_ground,
           sd.actuator2_ground, sd.actuator1_connection, sd.linkage2_connection)

csvWriter = CsvWriter(screen, fileWriteName, arm1)
csvReader = CsvReader(screen, fileReadName)

mouse = Mouse(screen)

Point(screen, screen.inches_to_pixels(screen.origin_x + sd.linkLength1), screen.inches_to_pixels(screen.origin_y), 0, screen.points)

iterate = True
iterator = Iterator(screen, arm1)
csvWriterIterator = CsvWriter(screen, fileWriteNameIterator, iterator)

run = True
while run:
    screen.initialize()

    # Mouse Position
    keys = py.key.get_pressed()
    mouse_press = py.mouse.get_pressed()
    mouse_pos = py.mouse.get_pos()
Exemplo n.º 19
0
# Screen title
pygame.display.set_caption("Colorindo Cenarios")

# Create an object to help track time
clock = pygame.time.Clock()

# All buttons
draw_button = Button(STANDARD_COLOR, 815, 5, 225, 400, "DRAW")
clear_button = Button(GREY, 815, 410, 225, 400, "CLEAR")

gold_button = Button(GOLD, 1095, 5, 225, 200, "GOLD")
brown_button = Button(BROWN, 1330, 5, 225, 200, "BROWN")
red_button = Button(RED, 1095, 210, 225, 200, "RED")
green_button = Button(GREEN, 1330, 210, 225, 200, "GREEN")
yellow_button = Button(YELLOW, 1095, 410, 225, 200, "YELLOW")
blue_button = Button(BLUE, 1330, 410, 225, 200, "BLUE")
purple_button = Button(PURPLE, 1095, 610, 225, 200, "PURPLE")
pink_button = Button(PINK, 1330, 610, 225, 200, "PINK")
buttons = [
    draw_button, clear_button, brown_button, gold_button, green_button,
    red_button, yellow_button, blue_button, purple_button, pink_button
]

# Objects
board = Board(25, 25, 5, STANDARD_COLOR)
mouse = Mouse()

# Controls mouse color
new_color = WALL
Exemplo n.º 20
0
from Mouse import Mouse
import time

cursor = Mouse()

pos = cursor.get_position()
print pos

start_time = time.time()			# start time stamp
elapsed_time = time.time() - start_time		# elapsed time

max_elapsed = 3600		# maximum elapsed time, 60 minutes

while (elapsed_time < max_elapsed):
	if (not(pos == cursor.get_position())):
		pos = cursor.get_position()	# if the mouse moves, update it
		print pos

	# end if statement
# end of while loop
Exemplo n.º 21
0
from Mouse import Mouse
import time

mouse = Mouse()
mouse.click((20, 10), "left")
time.sleep(2.0)

mouse.click((100, 100), "right")
Exemplo n.º 22
0
def animalFromFile(filename):
    coordinates = []
    final = []
    with open(filename) as myfile:
        for line in myfile.readlines():
            xy = list(map(int, line.split()))
            coordinates.append(xy)

    for item in coordinates:
        for item2 in item:
            final.append(item2)
    return final


mice = [Mouse(animalFromFile("mysz.txt"), n) for n in range(0,8)]
middleCats = [MiddleCat(animalFromFile("middleCat.txt"), n) for n in range(0,8)]
lazyCats = [LazyCat(animalFromFile("leniuch.txt"), n) for n in range(0,8)]
kittens = [Kitten(animalFromFile("kociaki.txt"), n) for n in range(0,8)]


print(middleCats[3].x, middleCats[3].y)
print(lazyCats[3].x, middleCats[3].y)
print(kittens[3].x, kittens[3].y)
print(mice[3].x, mice[3].y)
print("--------------")

iterations = 0
while iterations < 199:
    for mouse in mice:
        mouse.move()
Exemplo n.º 23
0
class MouseDaemon:
    def __init__(self, mouse_file="/dev/input/mice", switch_user=False, user="******", group="nogroup"):
        try:
            self.mouse_file = os.open(mouse_file, os.O_RDWR)
        except:
            raise OSError("Mouse file could not be opened")
        print("Mouse device opened")
        
        if switch_user:
            if drop_privileges(user, group):
                print("Privileges dropped")
            else:
                raise OSError("Privilege dropping failed")
        else:
            print("Privilege dropping is disabled")
        
        self.mouse = Mouse(self.mouse_file)
        
        if self.mouse.protocol == Mouse.INTELLI_MOUSE:
            mode = "IntelliMouse"
        elif self.mouse.protocol == Mouse.EXPLORER_MOUSE:
            mode = "Explorer Mouse"
        else:
            mode = "default"
        
        print("Found mouse in {} mode".format(mode))
        
        if self.mouse.protocol == Mouse.DEFAULT_MOUSE:
            #try switching to IntelliMouse protocol
            if self.mouse.setProtocol(Mouse.INTELLI_MOUSE):
                print("Mouse switched to IntelliMouse protocol")
                print("Mouse wheel support enabled")
            else:
                print("Mouse could not be switched to IntelliMouse protocol")
                print("Mouse wheel support disabled")
                print("Buttons 4 and 5 disabled")
        
        if self.mouse.protocol == Mouse.INTELLI_MOUSE:
            #try switching to Explorer Mouse protocol
            if self.mouse.setProtocol(Mouse.EXPLORER_MOUSE):
                print("Mouse switched to Explorer Mouse protocol")
                print("Buttons 4 and 5 enabled")
            else:
                print("Mouse could not be switched to Explorer Mouse protocol")
                print("Buttons 4 and 5 disabled")
        
    def handleEvents(self, event_responder):
        """ Main loop, catches events and sends them to given event_responder """
        
        #Each button's state is locked from firing events until it is released again.
        btn1 = btn2 = btn3 = btn4 = btn5 = False
        
        #track x and y movement. This will have to be queried manually
        self.x = self.y = 0
        
        while True:
            try:
                data = self.mouse.getMouseState()
            
                #fire only one event at a time
                if   (data.btn1 and data.btn1 != btn1):
                    event_responder.respond(0)
                elif (data.btn2 and data.btn2 != btn2):
                    event_responder.respond(1)
                elif (data.btn3 and data.btn3 != btn3):
                    event_responder.respond(2)
                elif (data.btn4 and data.btn4 != btn4):
                    event_responder.respond(3)
                elif (data.btn5 and data.btn5 != btn5):
                    event_responder.respond(4)
                elif data.wheel > 0:
                    event_responder.respond(5)
                elif data.wheel < 0:
                    event_responder.respond(6)
                
                #print(data)
                
                #current implementation: don't register move when overflow bit set
                if not data.xovfl:
                    self.x += data.x
                if not data.yovfl:
                    self.y += data.y
                
                #save data for next run
                btn1, btn2, btn3, btn4, btn5 = data.btn1, data.btn2, data.btn3, data.btn4, data.btn5
            except MouseException:
                continue #ignore invalid data received from mouse
    
    def __del__(self):
        os.close(self.mouse_file)
        print("Mouse device closed")
Exemplo n.º 24
0
    def run(self, myMap):
        catPossibleMoveList = [[2, 1], [-2, -1], [-2, 1], [-1, -2], [-1, 2], [1, -2], [1, 2], [2, -1]]
        # catPossibleMoveList = [[-1, -2], [1, -2], [2, -1], [2, 1], [-1, 2], [1, 2], [-2, -1], [-2, 1]]

        mouseMoveTrackingList = []
        moveTrackingState = []
        stateStack = []
        catSearchedList = []
        remainingCheeseNum = 0
        stateStack.append(myMap)
        solution = None
        mouseMoveTrackingList.append(myMap.mouse.getPos())
        while(solution == None):
            if(len(stateStack) != 0):
                # FILO stack for DFS
                currentState = stateStack.pop(len(stateStack) - 1)
                # if with the same step moved, and mouse have no more cheese to eat, stop finding more successors, go backtracking
                if(len(currentState.cheeseList) != 0):
                    # Found the goal state
                    if(currentState.mouse.mousePos == currentState.cat.catPos):
                        solution = currentState
                        break

                    closestCheese = self.getClosestCheese(currentState.mouse.getPos(), currentState.cheeseList)
                    nextMouseMove = self.mouseMove(currentState.mouse.getPos(), closestCheese.getPos())
                    # add mouseMove to list
                    if(nextMouseMove not in mouseMoveTrackingList):
                        mouseMoveTrackingList.append(nextMouseMove)
                    # Generate current node's successors
                    for possibleMoves in catPossibleMoveList:
                        newCheeseList = []
                        for cheese in currentState.cheeseList:
                            cheese1 = Cheese(cheese.cheesePos)
                            newCheeseList.append(cheese1)
                        nextCatMove = [currentState.cat.catPos[0] + possibleMoves[1], currentState.cat.catPos[1] + possibleMoves[0]]
                        # generate a successor and set its parent to currentState
                        nextState = MapState(currentState, newCheeseList, Mouse(nextMouseMove), Cat(nextCatMove), currentState.mapWidth, currentState.mapHeight)
                        # set current state as its parent
                        nextState.parentState = currentState
                        # make sure nextCatMove is in boundary and the state is not in visited state list
                        if (nextCatMove[0] >= 0 and nextCatMove[0] < nextState.mapWidth and nextCatMove[1] < nextState.mapHeight and nextCatMove[1] >= 0 and (nextState not in catSearchedList)):
                            nextState.updateMousePos(nextMouseMove)
                            nextState.updateCatPos(nextCatMove)
                            catSearchedList.append(nextState)
                            # add the state to stack
                            stateStack.append(nextState)

                # count for iterations
                self.searchCount += 1
                print(self.searchCount)
                # print(self.searchCount)
                if(self.searchCount > 10000):
                    print("Having more than 10000 searchs, generating a new map...")
                    self.ifCatWin = False
                    break

            # cannot find a solution
            else:
                solution = currentState
                self.ifCatWin = False
                break
        if(solution != None and len(solution.cheeseList) != 0):
            self.ifCatWin = True
            remainingCheeseNum = len(solution.cheeseList)
            # add solution to tracking list one by one
            while(solution != None):
                moveTrackingState.append(solution)
                solution = solution.parentState
            moveTrackingState.reverse()

            for state in moveTrackingState:
                state.updateCatPos(state.cat.catPos)
                state.updateMousePos(state.mouse.mousePos)
                time.sleep(1)
                state.covertMapToUI()
            print("Cat Win!")
            print("Search Count:", self.searchCount)
            print("Total Move:", len(moveTrackingState) - 1)
            print("Number of cheeses remaining:", remainingCheeseNum)
Exemplo n.º 25
0
import pyautogui
import os
import time
import random
from Looter import Looter
from Mouse import Mouse
from ScreenGrab import ScreenGrab

m = Mouse()
l = Looter(m)


def check_creatures_present():
    s2 = ScreenGrab()
    s2.b_box = (0, 0) + (1176, 91)
    s2.grab_screen()
    return s2.is_creature_present()


i = 1
coords = None

while (True):

    s = ScreenGrab()
    s.set_map_bb()
    time.sleep(1 + random.random())
    pyautogui.press('space')
    time.sleep(3 + random.random())
    if i % 3 == 0:
        pyautogui.press('1')
Exemplo n.º 26
0
# An example file to show the capability of Mouse class

import time
from Mouse import Mouse

mouse = Mouse()
mouse.move_mouse((0, 0))
mouse.click((20, 10), "right")
time.sleep(1.5)
mouse.click((30, 20), "left")
Exemplo n.º 27
0
linkLength1 *= multiplier
linkLength2 *= multiplier
linkLength3 *= multiplier
linkLength4 *= multiplier
linkLength5 *= multiplier
linkLengthhip *= multiplier

screen = Screen(screen_dim_pix, screen_dim_inch)

leg1 = Leg(screen, linkLength1, linkLength2, linkLength3,
           linkLength4, linkLength5, linkLengthhip)

csvWriter = CsvWriter(screen, fileWriteName, leg1)
csvReader = CsvReader(screen, fileReadName)

mouse = Mouse(screen, 0, 0)

Point(screen, screen.inches_to_pixels(screen.origin_x), screen.inches_to_pixels(screen.origin_y + 3), 0, screen.points)

run = True
test = False
while run:
    screen.initialize()

    # Mouse Position
    keys = py.key.get_pressed()
    mouse_press = py.mouse.get_pressed()
    mouse_pos = py.mouse.get_pos()
    mouse.function(mouse_pos, mouse_press, leg1.lhipz)

    screen.check_key_commands(keys)
Exemplo n.º 28
0
from Cat import Cat
from Mouse import Mouse
from Humans import Humans

person = Humans()
tom = Cat("tom")
jerry = Mouse("jerry")
'''
person.feedCat(tom,"fish")
person.feedMouse(jerry,"coin")
'''
person.feedAniaml(tom, 'fish')
person.feedAniaml(jerry, 'jam')
Exemplo n.º 29
0
def main():
    maze = Maze(API.mazeWidth(), API.mazeHeight())
    mouse = Mouse(0, 0, Direction.NORTH)
    while not maze.inCenter(mouse.getPosition()):
        updateWalls(maze, mouse)
        moveOneCell(maze, mouse)
Exemplo n.º 30
0
    turns each String into a List of two coordinates
    and returns a List of Integers as a result.'''
    coordinates = []
    final = []
    with open(filename) as myfile:
        for line in myfile.readlines():
            xy = list(map(int, line.split()))
            coordinates.append(xy)

    for item in coordinates:
        for item2 in item:
            final.append(item2)
    return final


mice = [Mouse(animalFromFile("mice.txt"), n) for n in range(0, 15)]
kittens = [Kitten(animalFromFile("kittens.txt"), n) for n in range(0, 6)]
middleCats = [
    MiddleCat(animalFromFile("middleCats.txt"), n) for n in range(0, 4)
]  # initialize each Animal
lazyCats = [LazyCat(animalFromFile("lazyCats.txt"), n)
            for n in range(0, 4)]  # in a list of instances
bigCats = [BigCat(animalFromFile("bigCats.txt"), n) for n in range(0, 3)]


def simulate(iterations):
    '''Takes a number of iterations as an argument and simulates
    movement of each Animal from the list. Starts with mice and
    checks for interaction with each Cat type object.'''
    frames = 0
    while frames < iterations:
Exemplo n.º 31
0
def main():
    cpuConcreta = Cpu()
    tecladoConcreto = Teclado(cpuConcreta)
    mouseConcreto = Mouse(tecladoConcreto)


    mouseConcreto.manejaProcesos("Presionar")
    mouseConcreto.manejaProcesos("Hola1")
    mouseConcreto.manejaProcesos("Escribir")
    mouseConcreto.manejaProcesos("Hola2")
    mouseConcreto.manejaProcesos("Encender")
    mouseConcreto.manejaProcesos("Hola3")
Exemplo n.º 32
0
import board
import time
from Mouse import Mouse

bob = Mouse([board.D12, board.D11, board.D10])
bob.moveForward(0.25)
time.sleep(1)
bob.stop()
time.sleep(1)
bob.turn("right")
time.sleep(1)
bob.turn("right")
time.sleep(1)
bob.turn("left")
time.sleep(1)
bob.turn("right")
time.sleep(1)
bob.moveForward(0.25)
time.sleep(1)
bob.stop()
Exemplo n.º 33
0
def creat_image():
    print("create image")
    mn = Mouse()
    mn.create_image()
Exemplo n.º 34
0
Created on Sun Nov 18 15:44:25 2018

@author: Morten
"""

from tkinter import *  # Import everything from Tkinter
from Arena import Arena  # Import our Arena
from Turtle import Turtle  # Import our Turtle
from Vector import *  # Import everything from our Vector
from Statue import Statue
from Mouse import Mouse
from Cat import Cat
from globalVariables import *

statueRadius = 1
statuePosition = Vector(200, 200)
mouseAngle = -57.0
catAngle = 0.0
catRadius = 4.0

tk = Tk()  # Create a Tk top-level widget
arena = Arena(tk)  # Create an Arena widget, arena
arena.pack()  # Tell arena to pack itself on screen
s = Statue(statuePosition,
           statueRadius)  # Add a turtle at (200,200) heading 0=up
m = Mouse(statue=s, angle=mouseAngle, arena=arena)
c = Cat(arena=arena, mouse=m, angle=catAngle, radius=catRadius)
arena.add(s)
arena.add(m)
arena.add(c)
tk.mainloop()
Exemplo n.º 35
0
            sendInput(1, byref(Keyboard._physicalKeyInput),
                      sizeof(Keyboard._physicalKeyInput))

    press = staticmethod(press)

    def release(keyCode, virtual=True):
        if virtual:
            Keyboard._virtualKeyInput.ki.wVk = keyCode

            Keyboard._virtualKeyInput.ki.dwFlags = Keyboard.KeyEvent.KEYUP
            sendInput(1, byref(Keyboard._virtualKeyInput),
                      sizeof(Keyboard._virtualKeyInput))
        else:
            Keyboard._physicalKeyInput.ki.wScan = keyCode

            Keyboard._physicalKeyInput.ki.dwFlags = Keyboard.KeyEvent.SCANCODE | Keyboard.KeyEvent.KEYUP
            sendInput(1, byref(Keyboard._physicalKeyInput),
                      sizeof(Keyboard._physicalKeyInput))

    release = staticmethod(release)


if __name__ == '__main__':
    from Mouse import Mouse
    Mouse.moveTo(50, SCREENHEIGHT - 50)
    Mouse.click(Mouse.LEFT)
    Keyboard.press(Keyboard.VirtualKeys.R)
    Keyboard.release(Keyboard.VirtualKeys.R)
    Keyboard.press(Keyboard.VirtualKeys.R)
    Keyboard.release(Keyboard.VirtualKeys.R)