wie ktoś dlaczego wyskakuje mi błąd w 51 linijce? "s.send(self.id)" błąd który wyskakuje: TypeError: a bytes-like object is required, not 'int' wiem tylko tyle że muszę zmienić typ tego co tam wpisuje ale nie wiem na jaki
import socket,pygame
pygame.init()
(x,y) = (720,720)
screen = pygame.display.set_mode((x,y))
pygame.display.set_caption("Client")
frame = 0
cursorRect = pygame.Rect(13,19,13,19)
option = 0
def blit(image,x,y):
screen.blit(image,(x,y))
def blitText(text,x,y,font,size,bold,r,g,b):
Font = pygame.font.Font(font,size)
Font.set_bold(bold)
Text = Font.render(text,True,(r,g,b))
blit(Text, x,y)
class drawRect(object):
def __init__(self,width,height,color,x,y,id):
global header
self.x = x
self.y = y
self.width = width
self.height = height
self.color = color
self.true = True
def drawRect(self, id):
global option
self.id = id
self.tile = pygame.Rect(self.x, self.y, self.width, self.height)
pygame.draw.rect(screen, (self.color), self.tile)
self.clickDetect()
if cursorRect.colliderect(self.tile):
self.color = (100, 100, 100)
elif option == self.id:
self.color = (120,120,120)
else:
self.color = (70, 70, 70)
def clickDetect(self):
global option
if self.tile.colliderect(cursorRect):
button1,button2,button3 = pygame.mouse.get_pressed()
if button1:
if self.true:
s.send(self.id)
print(s.recv(1024).decode())
self.true = False
SERVER_HOST = "192.168.0.36"
SERVER_PORT = 5002
separator_token = "<SEP>"
s = socket.socket()
Tile1 = drawRect(240,74,(80,80,80),0,0,1)
Tile2 = drawRect(240,74,(80,80,80),240,0,2)
Tile3 = drawRect(240,74,(80,80,80),480,0,3)
while True:
screen.fill((48, 48, 48))
(mouseX,mouseY) = pygame.mouse.get_pos()
cursorRect.x = mouseX
cursorRect.y = mouseY
if frame == 0:
blitText(f"[*] Connecting to {SERVER_HOST}:{SERVER_PORT}...",20,20,"assets/font/font1.ttf",13,True,122,10,10)
pygame.display.update()
s.connect((SERVER_HOST, SERVER_PORT))
blitText("[+] Connected.",20,40,"assets/font/font1.ttf",10,True,0,210,10)
pygame.time.delay(1000)
frame = 1
if frame == 1:
header = (70,70,70)
Tile1.drawRect(1)
Tile2.drawRect(2)
Tile3.drawRect(3)
blitText("Aktualności",50,10,"assets/font/font1.ttf",32,False,255,255,255)
blitText("Gry",340,10,"assets/font/font1.ttf",32,False,255,255,255)
blitText("Konto",560,10,"assets/font/font1.ttf",32,False,255,255,255)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT
pygame.display.update()
s.close()