Example #1
0
def keypress_up(slash=False):
    if not slash and (pressed("left") or pressed("right")): return
    x, y = share.img.getScreenRect()
    iw, ih = share.img.getSize()
    maxy = max(0, define.windowHeight - ih)
    if y == maxy:
        return
    if y + define.moveDistance <= maxy:
        share.img.moveScreenRect(ydiff=define.moveDistance)
    else:
        share.img.setScreenRect(y=maxy)
    core.logdebug(share.img.getRect(), share.img.getScreenRect())
    draw.updateScreen()
Example #2
0
def keypress_up(slash=False):
	if not slash and (pressed("left") or pressed("right")): return
	x, y = share.img.getScreenRect()
	iw, ih = share.img.getSize()
	maxy = max(0, define.windowHeight-ih)
	if y == maxy:
		return
	if y+define.moveDistance <= maxy:
		share.img.moveScreenRect(ydiff=define.moveDistance)
	else:
		share.img.setScreenRect(y=maxy)
	core.logdebug(share.img.getRect(), share.img.getScreenRect())
	draw.updateScreen()
Example #3
0
def keypress_left():
	if pressed("up"): keypress_up(True)
	elif pressed("down"): keypress_down(True)
	x, y = share.img.getScreenRect()
	iw, ih = share.img.getSize()
	maxx = max(0, define.windowWidth-iw)
	if x == maxx:
		return
	if x+define.moveDistance <= maxx:
		share.img.moveScreenRect(xdiff=define.moveDistance)
	else:
		share.img.setScreenRect(x=maxx)
	core.logdebug(share.img.getRect(), share.img.getScreenRect())
	draw.updateScreen()
Example #4
0
def keypress_down(slash=False):
	if pressed("up"): return
	if not slash and (pressed("left") or pressed("right")): return
	x, y = share.img.getScreenRect()
	iw, ih = share.img.getSize()
	miny = min(0, define.windowHeight-ih)
	if y == miny:
		return
	elif y-define.moveDistance >= miny:
		share.img.moveScreenRect(ydiff=-define.moveDistance)
	else:
		share.img.setScreenRect(y=miny)
	core.logdebug(share.img.getRect(), share.img.getScreenRect())
	draw.updateScreen()
Example #5
0
def keypress_left():
    if pressed("up"): keypress_up(True)
    elif pressed("down"): keypress_down(True)
    x, y = share.img.getScreenRect()
    iw, ih = share.img.getSize()
    maxx = max(0, define.windowWidth - iw)
    if x == maxx:
        return
    if x + define.moveDistance <= maxx:
        share.img.moveScreenRect(xdiff=define.moveDistance)
    else:
        share.img.setScreenRect(x=maxx)
    core.logdebug(share.img.getRect(), share.img.getScreenRect())
    draw.updateScreen()
Example #6
0
def keypress_down(slash=False):
    if pressed("up"): return
    if not slash and (pressed("left") or pressed("right")): return
    x, y = share.img.getScreenRect()
    iw, ih = share.img.getSize()
    miny = min(0, define.windowHeight - ih)
    if y == miny:
        return
    elif y - define.moveDistance >= miny:
        share.img.moveScreenRect(ydiff=-define.moveDistance)
    else:
        share.img.setScreenRect(y=miny)
    core.logdebug(share.img.getRect(), share.img.getScreenRect())
    draw.updateScreen()
Example #7
0
def keypress_right():
	if pressed("left"): return
	if pressed("up"): keypress_up(True)
	elif pressed("down"): keypress_down(True)
	x, y = share.img.getScreenRect()
	iw, ih = share.img.getSize()
	minx = min(0, define.windowWidth-iw)
	if x == minx:
		return
	elif x-define.moveDistance >= minx:
		share.img.moveScreenRect(xdiff=-define.moveDistance)
	else:
		share.img.setScreenRect(x=minx)
	core.logdebug(share.img.getRect(), share.img.getScreenRect())
	draw.updateScreen()
Example #8
0
def keypress_right():
    if pressed("left"): return
    if pressed("up"): keypress_up(True)
    elif pressed("down"): keypress_down(True)
    x, y = share.img.getScreenRect()
    iw, ih = share.img.getSize()
    minx = min(0, define.windowWidth - iw)
    if x == minx:
        return
    elif x - define.moveDistance >= minx:
        share.img.moveScreenRect(xdiff=-define.moveDistance)
    else:
        share.img.setScreenRect(x=minx)
    core.logdebug(share.img.getRect(), share.img.getScreenRect())
    draw.updateScreen()
Example #9
0
def mainLoop():
    procStartTime = time.time()
    procEndTime = time.time()
    draw.updateScreen()
    while share.running:
        procEndTime = time.time()
        sleepTime = define.drawDelay - (procEndTime - procStartTime)
        #core.logdebug("sleep", sleepTime)
        if sleepTime > 0:
            time.sleep(define.drawDelay - (procEndTime - procStartTime))
        procStartTime = time.time()
        draw.drawScreen()
        keyboard.procKeypress()
        while core.pollEvent():
            evtype = core.event.type
            if evtype == SDL_QUIT:
                core.log("SDL_QUIT event")
                share.running = False
            elif evtype == SDL_KEYDOWN:
                #str(core.sdl.String)
                keyboard.keydown(str(SDL_GetKeyName(
                    core.event.key.keysym.sym)))
            elif evtype == SDL_KEYUP:
                keyboard.keyup(str(SDL_GetKeyName(core.event.key.keysym.sym)))
Example #10
0
def keypress_v():
	share.anime.stop()
	draw.updateScreen()
	keyup("v")
Example #11
0
def keypress_v():
    share.anime.stop()
    draw.updateScreen()
    keyup("v")