diff options
author | Diego Roversi <diegor@tiscali.it> | 2020-05-23 10:05:51 +0200 |
---|---|---|
committer | Diego Roversi <diegor@tiscali.it> | 2020-05-23 10:05:51 +0200 |
commit | 2c41e377ab7257f879840abca9305fd25c274100 (patch) | |
tree | e0760281aff75f297aae75474fda0224edff206c /bubbob/bubbles.py | |
parent | 81c86067960952f0ec87a035ce060da584e05df3 (diff) |
more string to bytearray conversion
Diffstat (limited to 'bubbob/bubbles.py')
-rw-r--r-- | bubbob/bubbles.py | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/bubbob/bubbles.py b/bubbob/bubbles.py index 523c64c..590b57e 100644 --- a/bubbob/bubbles.py +++ b/bubbob/bubbles.py @@ -1,5 +1,6 @@ -import random, math + +import random, math, sys import gamesrv import images import boards @@ -10,11 +11,11 @@ from mnstrmap import Lightning, Water, Fire, SpinningBalls, PlayerBubbles bubble_wind = { - '<': (-1, 0), - '>': (+1, 0), - '^': ( 0,-1), - 'v': ( 0,+1), - 'x': ( 0, 0), + b'<': (-1, 0), + b'>': (+1, 0), + b'^': ( 0,-1), + b'v': ( 0,+1), + b'x': ( 0, 0), } @@ -177,7 +178,10 @@ class Bubble(ActiveSprite): self.vertical_warp() ## dx = -dx w = wget(self.x, self.y) - if w != ' ': + print(f"normal_movement: >{w}< {type(w)}", file=sys.stderr) + if w != b' ': + print(f"normal_movement: w!=b' ' {w}", file=sys.stderr) + print(f" bubble_wind= {bubble_wind}", file=sys.stderr) dx, dy = bubble_wind[w] elif self.default_windless: dx, dy = self.default_windless @@ -257,14 +261,14 @@ class Bubble(ActiveSprite): y1 = (self.y + 27) // CELL if dir < 0: x1 = (self.x + 5) // CELL - if bget(x1, y1) == ' ' == bget(x1, y1-1): + if bget(x1, y1) == b' ' == bget(x1, y1-1): stepx = -hspeed else: ico = icons[0] dir = 1 else: x1 = (self.x + 26) // CELL - if bget(x1, y1) == ' ' == bget(x1, y1-1): + if bget(x1, y1) == b' ' == bget(x1, y1-1): stepx = hspeed else: ico = icons[0] @@ -457,7 +461,7 @@ class DragonBubble(Bubble): hspeed *= 0.965 xc = int(nx-3.8)//CELL+1 yc = (self.y+HALFCELL)//CELL - if bget(xc,yc) == '#' == bget(xc, yc+1): + if bget(xc,yc) == b'#' == bget(xc, yc+1): stop += 1 if stop <= 1: self.move(int(nx+0.5), int(ny+0.5)) @@ -748,7 +752,7 @@ class FireFlame(ActiveSprite): x0 = self.x//CELL y0 = self.y//CELL for dir in dirs: - if bget(x0+dir, y0+1) == '#' and bget(x0+dir, y0) == ' ': + if bget(x0+dir, y0+1) == b'#' and bget(x0+dir, y0) == b' ': FireFlame(x0+dir, y0, self.poplist, [dir], countdown-1) for i in range(self.timeout): yield None @@ -766,7 +770,7 @@ class FireDrop(ActiveSprite): self.gen.append(self.dropping()) def dropping(self): x0 = self.x//CELL - while bget(x0, self.y//CELL) == '#' or bget(x0, self.y//CELL+1) != '#': + while bget(x0, self.y//CELL) == b'#' or bget(x0, self.y//CELL+1) != b'#': if self.y >= boards.bheight: self.kill() return @@ -786,14 +790,14 @@ class FireBubble(BonusBubble): if dragon: x0 = self.x // CELL + 1 y0 = self.y // CELL + 1 - if bget(x0, y0) == '#': + if bget(x0, y0) == b'#': x1 = (self.x + HALFCELL) // CELL if x1 == x0: tries = [x1+1, x1-1] else: tries = [x1, x1+2] for x1 in tries: - if bget(x1, y0) == ' ': + if bget(x1, y0) == b' ': x0 = x1 break FireDrop(x0*CELL, self.y) @@ -985,15 +989,15 @@ class WaterCell(ActiveSprite): s.repeat = 0 x0 = x // CELL y0 = y // CELL - if bget(x0, y0+1) == ' ': + if bget(x0, y0+1) == b' ': if y >= boards.bheight: s.kill() continue s.ping = 0 y += CELL - elif bget(x0+dir, y0) == ' ': + elif bget(x0+dir, y0) == b' ': x += dir*CELL - elif bget(x0-dir, y0) == ' ': + elif bget(x0-dir, y0) == b' ': s.ping += 1 if s.ping == 3: s.kill() @@ -1061,7 +1065,7 @@ class WaterBubble(BonusBubble): x0 = self.x // CELL + 1 y0 = self.y // CELL + 1 for x1 in [x0, x0+1, x0-1]: - if bget(x1,y0) == ' ' or bget(x1,y0+1) == ' ': + if bget(x1,y0) == b' ' or bget(x1,y0+1) == b' ': x0 = x1 break watercell(x0*CELL, y0*CELL, [None], repeat=19) |