added score

This commit is contained in:
Hannes
2026-05-24 23:06:39 +02:00
parent a1b5c06427
commit 4aaf5a0b15
+155 -30
View File
@@ -82,25 +82,117 @@ n9 = [
[1,1,1]
]
aa = [
[1,1,1],
[1,0,1],
[1,1,1],
[1,0,1]
# a_a = [
# [1,1,1],
# [1,0,1],
# [1,1,1],
# [1,0,1],
# [0,0,0]
# ]
# a_b = [
# [1,1,0],
# [1,1,1],
# [1,0,1],
# [1,1,1],
# [0,0,0]
# ]
# a_c = [
# [1,1,1],
# [1,0,0],
# [1,0,0],
# [1,1,1],
# [0,0,0]
# ]
# a_e = [
# [1,1,1],
# [1,1,0],
# [1,0,0],
# [1,1,1],
# [0,0,0]
# ]
# a_o = [
# [1,1,1],
# [1,0,1],
# [1,0,1],
# [1,1,1],
# [0,0,0]
# ]
# a_r = [
# [1,1,1],
# [1,0,1],
# [1,1,0],
# [1,0,1],
# [0,0,0]
# ]
# a_s = [
# [1,1,1],
# [1,0,0],
# [0,1,1],
# [1,1,1],
# [0,0,0]
# ]
### FONT: https://github.com/teryror/pixel-fonts/tree/master
a_s = [
[0,1,1,1,1,0],
[1,1,0,0,1,1],
[1,1,0,0,0,0],
[0,1,1,1,0,0],
[0,0,1,1,1,0],
[0,0,0,0,1,1],
[1,1,0,0,1,1],
[0,1,1,1,1,0]
]
ab = [
[1,1,0],
[1,1,1],
[1,0,1],
[1,1,1]
a_c = [
[0,1,1,1,1,0],
[1,1,1,0,1,1],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,1,0,1,1],
[0,1,1,1,1,0]
]
ac = [
[1,1,1],
[1,0,0],
[1,0,0],
[1,1,1]
a_o = [
[0,1,1,1,1,0],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[0,1,1,1,1,0]
]
a_r = [
[1,1,1,1,1,0],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1],
[1,1,1,1,1,0],
[1,1,0,1,1,1],
[1,1,0,0,1,1],
[1,1,0,0,1,1]
]
a_e = [
[1,1,1,1,1,1],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,1,1,1,1],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,0,0,0,0],
[1,1,1,1,1,1]
]
class color:
@@ -182,6 +274,10 @@ def make_sprite():
return sprite_pixels, sprite_width, sprite_height
def make_score():
score = random.randint(0, 999999999)
return score
# red = color(255, 0, 0, 255)
# blue = color(0, 0, 255, 255)
# green = color(0, 255, 0, 255)
@@ -190,17 +286,6 @@ def make_sprite():
black = color(0, 0, 0, 255)
white = color(255, 255, 255, 255)
# colors = [black, red, blue, green, purple, orange]
# colors2 = [
# black, # white-ish opposite of black
# color(0, 192, 192, 255), # cyan opposite of red
# color(192, 192, 0, 255), # yellow opposite of blue
# color(192, 0, 192, 255), # magenta opposite of green
# color(192, 192, 64, 255), # yellow-green opposite of purple
# color(0, 128, 255, 255), # sky blue opposite of orange
# ]
red = color(255, 0, 0, 255)
cyan = color(0, 255, 255, 255)
@@ -234,6 +319,8 @@ colors2 = [
lime
]
text_bg = black
next_board = make_next_board()
nb1 = coord(88, 96, 128, 128)
nb2 = coord(1064, 96, 128, 128)
@@ -243,6 +330,13 @@ b1 = coord(304, 40, 320, height=640)
board2_height, board2_width, board2 = make_board()
b2 = coord(656, 40, 320, height=640)
score1 = make_score()
s1 = coord(84, 454, 136, height=32)
sn1 = coord(74, 490, 156, height=20)
score2 = make_score()
s2 = coord(304, 40, 320, height=640)
sn2 = coord(304, 40, 320, height=640)
sprite_pixels, sprite_width, sprite_height = make_sprite()
width = 1280
@@ -286,6 +380,21 @@ for y in range(height):
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].get()
else:
pixels[x, y] = colors[next_board[yd>>5][xd>>5]].mask(0xFFFFFFC0)
### Score
elif x>=s1.x and x<s1.x+s1.width and y>=s1.y and y<s1.y+s1.height:
yd = y-s1.y
if x < (24+s1.x) and a_s[yd>>2][(x-s1.x)>>2]:
pixels[x, y] = white.get()
elif x<(52+s1.x) and x > (28+s1.x) and a_c[yd>>2][(x-(28+s1.x))>>2]:
pixels[x, y] = white.get()
elif x<(80+s1.x) and x > (56+s1.x) and a_o[yd>>2][(x-(56+s1.x))>>2]:
pixels[x, y] = white.get()
elif x<(108+s1.x) and x > (84+s1.x) and a_r[yd>>2][(x-(84+s1.x))>>2]:
pixels[x, y] = white.get()
elif x > (112+s1.x) and a_e[yd>>2][(x-(112+s1.x))>>2]:
pixels[x, y] = white.get()
else:
pixels[x, y] = text_bg.get()
####################### player 2
### Board
elif x>=b2.x and x<b2.x+b2.width and y>=b2.y and y<b2.y+b2.height:
@@ -313,15 +422,31 @@ for y in range(height):
pixels[x, y] = ((x+y)>>3,0,0)
offset = 0
numbers = [n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, aa, ab, ac]
numbers = [a_s, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9]
for num in numbers:
for y in range(len(num)*4):
for x in range(len(num[y>>2])*4):
for y in range(len(num)<<2):
for x in range(len(num[y>>2])<<2):
if num[y>>2][x>>2]:
pixels[x+offset, y] = white.get()
else:
pixels[x+offset, y] = black.get()
offset += 15
offset += (len(num[0])<<2)+4
letters = [a_s, a_c, a_o, a_r, a_e]
offset = 0
base_offset = 720-32
for letter in letters:
for y in range(len(letter)<<2):
for x in range(len(letter[y>>2])<<2):
if letter[y>>2][x>>2]:
pixels[x+offset, y+base_offset] = white.get()
else:
pixels[x+offset, y+base_offset] = black.get()
offset += (len(letter[0])<<2) + 4
img.save("output/alpha.png")
img.show()