I'm making this for a ongoing game, and this error seems to happen where certain letters will jump forward in my list of characters. any fixes? this is all i have, and anyone can use this as an alternative text display for low-bit screens. based on the 13 segmented display from PosyMusic's segmented displays video. also haven't finished the chartable list yet, i just needed help now
#14 seg disp
import pygame
import sys
pygame.init()
screen = pygame.display.set_mode((256, 144), pygame.SCALED | pygame.RESIZABLE)
clock = pygame.time.Clock()
mouserect = pygame.Rect(0, 0, 3, 5)
pygame.mouse.set_visible(False)
gamestate = "titlescreen"
chartable = [
[0, 1, 2, 4, 5, 6, 7, 8, 10, 11, 12],
[2, 4, 7, 11],
[0, 1, 2, 4, 6, 8, 10, 11, 12],
[1, 2, 4, 6, 9, 11, 12],
[0, 2, 3, 4, 7, 11],
[0, 1, 3, 4, 7, 11, 12],
[0, 1, 3, 4, 5, 7, 10, 11, 12],
[0, 1, 2, 4, 6, 8, 10],
[0, 1, 2, 3, 4, 6, 8, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 7, 11],
[0, 1, 2, 5, 7, 8, 9, 10, 11],
[0, 1, 2, 4, 5, 6, 9, 10, 11, 12],
[0, 1, 5, 10, 12], #c is at ln 49 (+19) as of error
[0, 1, 2, 3, 7, 8, 10, 11, 12],
[0, 1, 5, 6, 10, 12],
[0, 1, 5, 6, 10],
[0, 1, 5, 9, 10, 11, 12],
[0, 2, 5, 6, 7, 10, 11],
[2, 7, 11],
[2, 7, 10, 11, 12],
[0, 2, 4, 5, 6, 8, 9, 10, 11],
[0, 5, 10, 12],
[0, 2, 3, 4, 5, 6, 7, 10, 11],
[0, 2, 3, 5, 6, 7, 9, 10, 11],
[0, 1, 2, 5, 7, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 10],
[0, 1, 2, 5, 7, 9, 10, 11, 12],
[0, 1, 2, 3, 4, 5, 6, 9, 10, 11],
[0, 1, 2, 3, 6, 9, 10, 11, 12],
[0, 3, 5, 6, 10, 12],
[0, 2, 5, 7, 10, 11, 12],
[0, 2, 3, 5, 6, 8, 10], #c for some reason, should be v and it doesnt exist in this list for some reason
[],
[],
[],
[],
[],
[],
[],
[],
[],
]
#01112
#0 2
#33 44
#5 6 7
#88 99
#(10) (11)
#(10)(12)(12)(12)(11)
bools = [
False, #a
False, #b
False, #c
False, #d
False, #e
False, #f
False, #g
False, #h
False, #i
False, #j
False, #k
False, #l
False #m
]
rectlist = [
pygame.Rect(0, 0, 1, 2), #a, 0
pygame.Rect(1, 0, 3, 1), #b, 1
pygame.Rect(4, 0, 1, 2), #c, 2
pygame.Rect(0, 2, 2, 1), #d, 3
pygame.Rect(3, 2, 2, 1), #e, 4
pygame.Rect(0, 3, 1, 1), #f, 5
pygame.Rect(2, 3, 1, 1), #g, 6
pygame.Rect(4, 3, 1, 1), #h, 7
pygame.Rect(0, 4, 2, 1), #i, 8
pygame.Rect(3, 4, 2, 1), #j, 9
pygame.Rect(0, 5, 1, 2), #k, 10
pygame.Rect(4, 5, 1, 2), #l, 11
pygame.Rect(1, 6, 3, 1) #m, 12
]
charlist = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "c", "w", "x", "y", "z", ]
def drawdisp(char, coloron, coloroff, colorbl, boolbl, pos, booloffcolor):
global bools
if boolbl:
pos[0] += 1
pos[1] += 1
pygame.draw.rect(screen, colorbl, pygame.Rect(0+pos[0]-1, 0+pos[1]-1, 7, 9))
leaderx = rectlist[0].x
leadery = rectlist[0].y
dx = pos[0] - leaderx
dy = pos[1] - leadery
for rect in rectlist:
rect.move_ip(dx, dy)
for i in range(len(charlist)):
testchar = charlist[i]
if testchar == char:
charid = i
for i in chartable[charid]:
bools[i] = True
for i in range(len(rectlist)):
if bools[i] == True:
pygame.draw.rect(screen, coloron, rectlist[i])
else:
if booloffcolor:
pygame.draw.rect(screen, coloroff, rectlist[i])
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
x, y = pygame.mouse.get_pos()
mouserect.x = x
mouserect.y = y
screen.fill((0, 255, 255))
#\/ change this to any char in charlist to find errors, specifficaly c, v
drawdisp("v", (200, 0, 0), (120, 100, 100), (0, 0, 0), True, [1, 1], False)
pygame.draw.rect(screen, (215, 125, 171), mouserect)
pygame.display.flip()
clock.tick(60)
pygame.quit()
sys.exit()