Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _compute_(self, t, count=1):
b = stack[-1]
stack.rotate(1)
try:
stack.append((b / a) & MAXINT)
stack.append(int(b / a) & MAXINT)
except ZeroDivisionError:
stack.append(0)

Expand Down
24 changes: 12 additions & 12 deletions glitched.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def draw_valuepattern(buf, target, drop_frame=False):
global valuepattern
if not drop_frame:
for x, y in enumerate(buf):
valuepattern.set_at((127, 127-x/2), (y, y, y))
valuepattern.set_at((127, int(127-x/2)), (y, y, y))
target.fill((133, 153, 0)) # Solarized Green
target.blit(valuepattern, (0, 0), (0, 0, 128, 128), pygame.BLEND_ADD)
valuepattern.scroll(-1, 0)
Expand Down Expand Up @@ -301,7 +301,7 @@ def draw_graph(buf, stack, t, drop_frame=False):
if RENDER_STACK:
draw_stack(stack, graph, drop_frame)

for b in [buf[i:i+256] for i in xrange(0, len(buf), 256)]:
for b in [buf[i:i+256] for i in range(0, len(buf), 256)]:
if RENDER_VALUEPATTERN:
draw_valuepattern(b, graph, drop_frame)
if RENDER_YPATTERN:
Expand All @@ -322,7 +322,7 @@ def draw_graph(buf, stack, t, drop_frame=False):
while running:
starttime = time()
if (channel.get_queue() == None and not PAUSED): # no excess output
buf = [m._compute_(j) for j in xrange(i, i+BUFSIZE)]
buf = [m._compute_(j) for j in range(i, i+BUFSIZE)]
sound = pygame.sndarray.make_sound(numpy.array(buf, numpy.uint8))
channel.queue(sound)
i += BUFSIZE
Expand Down Expand Up @@ -388,24 +388,24 @@ def draw_graph(buf, stack, t, drop_frame=False):
m.tokens = m._tokenize_(m.lines[1:], [n-1 for n in mutedlines])
m._reset_()

if event.key in TEXT_KEYMAP.keys() or \
event.key in OPCODE_KEYMAP.keys() or \
if event.key in list(TEXT_KEYMAP.keys()) or \
event.key in list(OPCODE_KEYMAP.keys()) or \
event.key == pygame.K_PAGEUP or \
event.key == pygame.K_PAGEDOWN:
column = curpos[0]
row = curpos[1]
line = m.lines[row]
char = line[column]
line = m.lines[int(row)]
char = line[int(column)]

if (row == 0) and (
event.key in TEXT_KEYMAP.keys() or \
event.key in list(TEXT_KEYMAP.keys()) or \
event.key == pygame.K_PAGEUP or \
event.key == pygame.K_PAGEDOWN
):
KEYMAP = TEXT_KEYMAP
KEYORDER = TEXT_ORDER
elif (row > 0) and (
event.key in OPCODE_KEYMAP.keys() or \
event.key in list(OPCODE_KEYMAP.keys()) or \
event.key == pygame.K_PAGEUP or \
event.key == pygame.K_PAGEDOWN
):
Expand All @@ -426,7 +426,7 @@ def draw_graph(buf, stack, t, drop_frame=False):
index = (KEYORDER.find(char) + 1) % len(KEYORDER)
newchar = KEYORDER[index]

m.lines[row] = line[:column] + newchar + line[column+1:]
m.lines[int(row)] = line[:int(column)] + newchar + line[int(column)+1:]
m.tokens = m._tokenize_(m.lines[1:], mutedlines)
m._reset_()
stderr.write('Now playing: ' + str(m) + '\n')
Expand All @@ -442,8 +442,8 @@ def draw_graph(buf, stack, t, drop_frame=False):
RENDER_VALUEPATTERN = not RENDER_VALUEPATTERN
RENDER_STACK = not RENDER_STACK
else:
curpos[0] = x/GRID - 16
curpos[1] = y/GRID
curpos[0] = int(x/GRID - 16)
curpos[1] = int(y/GRID)
draw_controls()
draw_iterator(i)

Expand Down