def funcionando(self): self.updFondo() self.m = Mouse.Mouse(self.supIzq, self.infDer) #inicializo todos para que no haya errores for i in xrange(int(self.smooth / 2) + 1): centro = (0, 0) self.__agregarPunto(centro, self.puntosFoto) self.__agregarPunto(centro, self.puntosSuav) self.centroSuav = (0, 0) i = 0 print time.clock() while self.cont: i += 1 centro = self.analizar() self.__agregarPunto(centro, self.puntosFoto) #para el butter self.centroSuav = self.__getPuntoSuav1() self.__agregarPunto(self.centroSuav, self.puntosSuav) self.m.setPos(self.centroSuav) if i > 60: self.updGTK() i = 0 print time.clock()
def __init__(self): ReactionBase.__init__(self) self.recongnition = Recongnition() self.infoGetter = ChessInformation() self.frame = Framework() self.mouse = Mouse() self.endFlag = True
def enter(): global character, mouse, map, monsters global items character = Character.Character() mouse = Mouse.Mouse() map = Map.Map() monsters = [Monster.Monster() for i in range(60)] items = [Item.Item() for i in range(2)]
def initialize(self): ''' It's better to call this method after create all objects''' self.timeNow = now.time() if self.frame : print('Frame already created') else : self.frame = Frame.Frame(self) self.updateScreen() self.mouse = Mouse.Mouse(self) self.keyboard = Keyboard.Keyboard(self) self.running = True
def __init__(self, players): initKeys(logic.expandPath("//conf.mol")) #bge.constraints.setDebugMode(bge.constraints.DBG_DRAWWIREFRAME) #Constants: self.players = players self.mouse = Mouse() self.prefix = "default" self.radialSpeedIncrease = 1 #The speed with the radial speed will increase self.maxVelocity = 10 self.maxDotValue = 0.5 self.maxTimer = 6.0 self.minTimer = 2.0 self.reticuleXY = overlayer1.objects["reticuleXY"] self.reticuleXZ = overlayer1.objects["reticuleXZ"] overlayer1.objects["curveXZ"].localScale.y *= self.maxDotValue self.flagXY = overlayer1.objects["flagXY"] self.flagXZ = overlayer1.objects["flagXZ"] self.molkky = scene.objects["Mölkky"] self.puppet = scene.objects["Mölkky_puppet"] self.origin = scene.objects["Origin"] self.reference = scene.objects["reference"].worldPosition self.pinList = [] for i in range(0, 12): self.pinList.append(scene.objects["pin." + str(i + 1)].groupMembers["pin"]) #Variables: self.test = 0 self.playerNumber = 0 #The ID of the actual player self.player = self.players[self.playerNumber] self.molkkyLaunched = 0 self.leftActivated = 0 self.rightActivated = 0 self.oldLeftClick = 0 self.leftClick = 0 self.timer = Utils.Timer() self.oldPinsPos = [Vector((0, 0, 0))] * 12 self.oldMollkyPos = Vector((0, 0, 0)) #Init oldPinsPos && oldMollkyPos for i in range(0, 12): self.oldPinsPos[i] = self.pinList[i].worldPosition self.oldMollkyPos = Vector( (self.molkky.worldPosition.x, self.molkky.worldPosition.y, self.molkky.worldPosition.z))
def main(): input("Press ENTER to start...") start_time = time.clock() products = [ Laptop.Laptop(), Desktop.Desktop(), Monitor.Monitor(), Printer.Printer(), Mouse.Mouse(), Keyboard.Keyboard() ] for product in products: product.run() print("\n{0}s".format(time.clock() - start_time))
def __init__(self, color, title="StreetCode Academy", show_mouse_pos=False): pygame.init() pygame.font.init() self.screen = pygame.display.set_mode(SCREEN_SIZE) pygame.display.set_caption(title) self.clock = pygame.time.Clock() if pygame.font: self.font = pygame.font.Font(None, 30) else: self.font = None self.screen_color = color self.is_playing_game = True self.sprites = {} self.collision_flag = 0 self._keyboard = Keyboard() self._mouse = Mouse() self._show_mouse_pos = show_mouse_pos if self._show_mouse_pos: self.draw_rectangle(0, 100, 10, 1, WHITE) self.draw_rectangle(0, 200, 10, 1, WHITE) self.draw_rectangle(0, 300, 10, 1, WHITE) self.draw_rectangle(0, 400, 10, 1, WHITE) self.draw_rectangle(100, 0, 1, 10, WHITE) self.draw_rectangle(200, 0, 1, 10, WHITE) self.draw_rectangle(300, 0, 1, 10, WHITE) self.draw_rectangle(400, 0, 1, 10, WHITE) self.draw_rectangle(500, 0, 1, 10, WHITE) self.draw_rectangle(600, 0, 1, 10, WHITE) self.mouse_pos_text = self.draw_text(0, SCREEN_SIZE[1] - 17, '(0,0)', BLACK, size=12)
def main(): print("Start !") hWList = util.findWindowList("阴阳师") mouse = Mouse.Mouse() for hW in hWList: pageInstance = Page.Page(hW) autoYuHun = AutoYuHun.AutoYuHun(pageInstance, mouse) while (True): try: print( list(pageInstance.pageType.keys())[list( pageInstance.pageType.values()).index( pageInstance.nowPage)]) except Exception as e: print(pageInstance.nowPage) print(e) time.sleep(1) print("End !")
from Duck import * from Mouse import * def describe(object): object.talk() object.coat() donald = Duck() mickey = Mouse() describe(donald) describe(mickey)
opts, args = getopt.getopt(sys.argv[1:], 'l:r:m:', ['left=', 'right=', 'mouse=']) is_single = False for opt in opts: if opt[0] in ('-l','--left'): left_path = "/dev/input/event" + opt[1] print("got left") if opt[0] in ('-r','--right'): right_path = "/dev/input/event" + opt[1] print("got right") if opt[0] in ('-m','--mouse'): mouse_path = "/dev/input/event" + opt[1] is_single = True print("got mouse") if is_single: mouse = Mouse.Mouse(mouse_path) mouse_thread = threading.Thread(target = mouse.loop) mouse_thread.daemon = True mouse_thread.start() while True: print("X: {0}, Y: {1}".format(mouse.get_dx(), mouse.get_dy())) time.sleep(1) left_mouse = Mouse.Mouse(left_path) right_mouse = Mouse.Mouse(right_path) camera = OpenMV_IN.Reciever() handler = OpenMV_Handler.Handler() left_thread = threading.Thread(target = left_mouse.loop) right_thread = threading.Thread(target = right_mouse.loop) camera_thread = threading.Thread(target = camera.in_loop)
__author__ = 'zhengxiaoyu' 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 Mouse import * from WalkingTurtle import * from Status import * from Cat import * little_mouse = Mouse(Vector(345, 350), 1, 1) little_cat = Cat(Vector(800, 350), 1, little_mouse) little_status = Status(Vector(450, 350), 1) tk = Tk() # Create a Tk top-level widget arena = Arena(tk, little_cat) # Create an Arena widget, arena arena.pack() arena.add(little_mouse) arena.add(little_cat) arena.add(little_status) tk.mainloop() # Enter the Tkinter event loop
def enter(): global character, mouse, map, monsters character = Character.Character() mouse = Mouse.Mouse() map = Map.Map() monsters = [Monster.Monster() for i in range(10)]
import pygame import Pages import Mouse import Constants pygame.init() Screen = pygame.display.set_mode(Constants.SCREENSIZE, pygame.FULLSCREEN) pygame.key.set_repeat(30, 1) mouse = Mouse.Mouse(Constants.SCREENSIZE[0] / 2, Constants.SCREENSIZE[1] / 2) Currentpage = Pages.ExamplePage.ExamplePage() Currentpage.check(mouse) Currentpage.display(Screen) Done = False x = 0 count = 0 while not Done: pygame.time.delay(1) events = pygame.event.get() for event in events: if event.type == pygame.QUIT: Done = True mouse.HandleEvents(events) output = Currentpage.check(mouse) #print output if output[0]: if output[1] == "x":
cat_angle = 150.000 cat_heading = cat_angle - 90 cat_radius = 8.100 ''' ''' # case 5 mouse_angle = -57.000 mouse_heading = mouse_angle - 90 cat_angle = 0.000 cat_heading = cat_angle - 90 cat_radius = 4.000 # stoptime = 30*10**3 ''' statue = Statue(Vector(200, 200), 0, radius * 100) mouse = Mouse(Vector(200, 200), mouse_heading, radius * 100, 1, mouse_angle, arena) cat = Cat(Vector(200, 200), cat_heading, radius * 100, cat_radius * 100, 1.25, 1, cat_angle, mouse_angle, mouse, arena, updatetime.callback()) arena.add(statue) arena.add(mouse) arena.add(cat) arena.getinitial() arena.make_time_widgets() def cursor_motion(event): if arena.is_running() != 1: # print('stopped') if round(cat.position.x + arena._canvas_offset.x - 15) <= round( event.x
import queue import getopt import time import struct import sys import OpenMV_IN import OpenMV_Handler import Roborio_IN import Mouse if __name__ == '__main__': #opts, args = getopt.getopt(sys.argv[1:], 'l:r:m:', ['left=', 'right=', 'mouse=']) robot = Roborio_IN.Roborio() camera = OpenMV_IN.Reciever() handler = OpenMV_Handler.Handler() mouse = Mouse.Mouse("/dev/input/event0") time.sleep(0.01) #let the camera decoding start up before the in thread a = [ handler.get_RTS_info, handler.get_RTR_info, handler.get_ball_info, mouse.get_robot_out ] robot_in_thread = threading.Thread(target = robot.in_loop) robot_out_thread = threading.Thread(target = robot.filter_loop, args = [a] ) camera_thread = threading.Thread(target = camera.in_loop) handler_thread = threading.Thread(target = handler.loop) mouse_thread = threading.Thread(target = mouse.loop) robot_in_thread.daemon = True #ensure the threads close when oo.py is stopped robot_out_thread.daemon = True camera_thread.daemon = True handler_thread.daemon = True
import pygame import Pages import Mouse import Constants import Components import Games import Combos pygame.init() Screen = pygame.display.set_mode(Constants.SCREENSIZE, pygame.FULLSCREEN) # pygame.key.set_repeat(30, 1) mouse = Mouse.Mouse(int(Constants.SCREENSIZE[0] * Constants.scaleConstant / 2), int(Constants.SCREENSIZE[1] * Constants.scaleConstant / 2)) Currentpage = Pages.MainPage.MainPage() Currentpage.display(Screen, Constants.scaleConstant) LastPage = [Currentpage] Done = False x = 0 Wait = 0 count = 0 timeCount = 0 secretCombos = [] ##exitCode = [273, 274, 102, 114, 122, 32, 308, 306, 50] ##otherCode = [Constants.ArcadiaBoard.LeftLeverUp, ## Constants.ArcadiaBoard.RightLeverUp, ## Constants.ArcadiaBoard.LeftLeverDown, ## Constants.ArcadiaBoard.RightLeverDown,
import Camera, Mouse, Util, Light from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * import pygame import time # keyboard defines ESC_KEY = b'\x1b' # control defines CLICK_MIN_TIME = 0.1 # 1 décimo de segundo camera = Camera.Camera() mouse = Mouse.Mouse() mouseLock = False # controla a trava do mouse ao clicar rapidamente para desenhar saveMouse = False # controla se a posição do mouse vai ser salva start = 0 # controla o tempo do click do mouse # window size width = 800 height = 600 # texture img = pygame.image.load('texture/tex.jpg') texData = pygame.image.tostring(img, "RGBA", 1) texWidth = img.get_width() texHeight = img.get_height() texId = 0
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 Turtle.m = 50.0 # Scaling factor Turtle.origin = Vector(400, 300) from Statue import * from Mouse import * from Cat import * statue = Statue(Turtle.origin + Vector(0, 0), 0) mouse = Mouse(Turtle.origin + Vector(0, -Turtle.m).rotate(40), 0) cat = Cat(Turtle.origin + Vector(0, -4 * Turtle.m).rotate(200), 0, mouse) tk = Tk() # Create a Tk top-level widget arena = Arena(tk, 800, 600) # Create an Arena widget, arena arena.pack() # Tell arena to pack itself on screen arena.add(statue) # Add a very simple, statue arena.add(mouse) # Add a green mouse centered at the base of the statue arena.add(cat) # Add a red cat cat_radius = StringVar() cat_radius.set('CatRadius: %2.f' % cat.radius) cat_angle = StringVar() cat_angle.set('CatAngle: %2.f' % cat.angle) mouse_angle = StringVar() mouse_angle.set('MouseAngle: %2.f' % mouse.angle) arena.add_labels(arena.time, cat_radius, cat_angle, mouse_angle) tk.mainloop() # Enter the Tkinter event loop
FPS = 30 WINDOWWIDTH = 640 WINDOWHEIGHT = 480 boxSize = MEDIUMBOXSIZE PALETTEGAPSIZE = 10 PALETTESIZE = 45 EASY = 0 # arbitrary but unique value MEDIUM = 1 # arbitrary but unique value HARD = 2 # arbitrary but unique value difficulty = MEDIUM # game starts in "medium" mode maxLife = MEDIUMMAXLIFE boardWidth = MEDIUMBOARDSIZE boardHeight = MEDIUMBOARDSIZE MOUSE = Mouse.Mouse(WINDOWWIDTH * 7 / 8, WINDOWHEIGHT * 7 / 8) MOUSE.CHANGE = 5 # R G B WHITE = (255, 255, 255) DARKGRAY = (70, 70, 70) BLACK = (0, 0, 0) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) ORANGE = (255, 128, 0) PURPLE = (255, 0, 255) SELECTED = 0 # The first color in each scheme is the background color, the next six are the palette colors.
nx = 100 ny = 100 cheesePos = [90, 91] discount = 1.0 memsize = 10 mouse_pos = [math.floor((nx + 1) / 2), math.floor((ny + 1) / 2)] print(mouse_pos) directions = ['left', 'right', 'up', 'down'] world = wld.World(nx, ny, mouse_pos) world.add_cheese(cheesePos, cheeseValue) smell = world.get_smell() mouse = mouseagent.Mouse(directions, memsize) number_iterations = 200 history = [] distances_from_cheese = [] for i in range(number_iterations): mouse_position = world.get_position() history.append([mouse_position[0], mouse_position[1]]) d = world.get_distance_from_cheese(cheesePos) distances_from_cheese.append(d) # check for solution if (mouse_position == cheesePos):