Fixes to make it work
This commit is contained in:
parent
bf5217b14a
commit
aedf9f14f1
3 changed files with 18 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,3 +4,5 @@ pixelnuke/pixelnuke
|
|||
|
||||
pixelwar/.*
|
||||
pixelwar/target
|
||||
save/
|
||||
__pycache__/
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def on_connect(c, client):
|
|||
@on('KEYDOWN-c')
|
||||
def on_key_c(c):
|
||||
c.clear()
|
||||
pixelflut.async(c.text, 5, 5, text, delay=0.1)
|
||||
pixelflut.async2(c.text, 5, 5, text, delay=0.1)
|
||||
|
||||
@on('KEYDOWN-s')
|
||||
def on_key_s(c):
|
||||
|
|
@ -77,6 +77,7 @@ def on_text(canvas, client, x, y, *words):
|
|||
@on('COMMAND-SIZE')
|
||||
def on_size(canvas, client):
|
||||
client.send('SIZE %d %d' % canvas.get_size())
|
||||
#pass
|
||||
|
||||
@on('COMMAND-QUIT')
|
||||
def on_quit(canvas, client):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import os.path
|
|||
import logging
|
||||
log = logging.getLogger('pixelflut')
|
||||
|
||||
async = spawn
|
||||
async2 = spawn
|
||||
|
||||
class Client(object):
|
||||
pps = 1000
|
||||
|
|
@ -35,7 +35,8 @@ class Client(object):
|
|||
def send(self, line):
|
||||
with self.lock:
|
||||
if self.socket:
|
||||
self.socket.sendall(line + '\n')
|
||||
self.socket.sendall((line + '\n').encode())
|
||||
#self.socket.sendall(line)
|
||||
|
||||
def nospam(self, line):
|
||||
self.send(line)
|
||||
|
|
@ -75,12 +76,15 @@ class Client(object):
|
|||
|
||||
class Canvas(object):
|
||||
size = 640, 480
|
||||
flags = pygame.RESIZABLE#|pygame.FULLSCREEN
|
||||
flags = pygame.RESIZABLE|pygame.NOFRAME#|pygame.FULLSCREEN
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self,pos_x,pos_y):
|
||||
pygame.init()
|
||||
pygame.mixer.quit()
|
||||
self.set_title()
|
||||
os.environ['SDL_VIDEO_WINDOW_POS'] = '%i,%i' % (pos_x,pos_y)
|
||||
os.environ['SDL_VIDEO_CENTERED'] = '0'
|
||||
|
||||
self.screen = pygame.display.set_mode(self.size, self.flags)
|
||||
self.frames = 0
|
||||
self.width = self.screen.get_width()
|
||||
|
|
@ -192,6 +196,8 @@ class Canvas(object):
|
|||
def load_from(self, filename):
|
||||
img = pygame.image.load(filename).convert()
|
||||
self.screen.blit(img, (0,0))
|
||||
def move(self, x, y):
|
||||
self.screen.move(x, y)
|
||||
|
||||
def load_font(self, fname):
|
||||
''' Load a font image with 16x16 sprites. '''
|
||||
|
|
@ -232,12 +238,14 @@ if __name__ == '__main__':
|
|||
help="specify hostname to run on")
|
||||
parser.add_option("-p", "--port", dest="portnum", default=1234,
|
||||
type="int", help="port number to run on")
|
||||
parser.add_option("-x", "--delta-x", type="int", default=0)
|
||||
parser.add_option("-y", "--delta-y", type="int", default=0)
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 1:
|
||||
parser.error("incorrect number of arguments")
|
||||
|
||||
canvas = Canvas()
|
||||
canvas = Canvas(options.delta_x, options.delta_y)
|
||||
task = spawn(canvas.serve, options.hostname, options.portnum)
|
||||
|
||||
brainfile = args[0]
|
||||
|
|
@ -249,7 +257,7 @@ if __name__ == '__main__':
|
|||
canvas.fire('UNLOAD')
|
||||
canvas.events.clear()
|
||||
try:
|
||||
execfile(brainfile, {'on':canvas.on, '__file__': brainfile})
|
||||
exec(open(brainfile).read(), {'on':canvas.on, '__file__': brainfile})
|
||||
except:
|
||||
log.exception('Brain failed')
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue