Firstly i need a userpanel. From there a user will enter 3 inputs. For example 1)What is your k? A)[USER İNPUT] 2) What is your M? B)[USER INPUT] 3)What is your a? C)[USER INPUT] whenever users apply these answers, pygame window will be open. The last answer will be our angle between the down platform of at the right side system and x direction. The other 2 answers will go arduino serial communation. Finally boundaries shoul be have. The circle can not pass up and down obstacles. Just pass from left side of the system. My code is below. Thanks four your answers,in advance :)
import pygame,sys
pygame.init()
win=pygame.display.set_mode((1030,650))
pygame.display.set_caption("Seri Manipulator Kontrolü")
x = 700
y = 300
width = 5
height = 0
vel = 5
oxu= 870
oyu= 420
owu= 160
ohu= 10
oxd= 870
oyd= 220
owd= 160
ohd= 10
centeredobx=870
centeredoby=230
centeredboy=190
centereden=10
cubukx= 880
cubuky= 320
cubuken= 140
cubukboy= 10
def yazdir():
win.fill((0,0,0))
pygame.draw.circle(win, (0, 127, 255), (x, y), width, 0)
pygame.draw.rect(win, (255, 0, 0), (oxu, oyu, owu, ohu))
pygame.draw.rect(win, (255, 0, 0), (oxd, oyd, owd, ohd))
pygame.draw.rect(win, (255, 255, 0), (centeredobx, centeredoby, centereden, centeredboy))
pygame.draw.rect(win, (128, 128, 128), (cubukx, cubuky, cubuken, cubukboy))
pygame.draw.rect(win, (255, 0, 0), (1020, 220, 10, 200))
pygame.display.update()
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
print(event)
if event.type == pygame.QUIT:
run = False
pygame.quit()
keys = pygame.key.get_pressed()
if pygame.key.get_pressed() and x in range(865,1025) and y in range(225,235) or pygame.key.get_pressed() and x in range(865,1025) and y in range(415,425):
return
else:
if keys[pygame.K_RIGHT] and 1010 > x > 860 and 235 <= y <= 415 and centeredobx <= 1005:
centeredobx += vel
cubukx += vel
cubuken -= vel
yazdir()
if keys[pygame.K_LEFT] and 1010 > x > 860 and 235 <= y <= 415 and centeredobx >= 875:
centeredobx -= vel
cubukx -= vel
cubuken += vel
yazdir()
if keys[pygame.K_LEFT] and x > 5:
x -= vel
yazdir()
if keys[pygame.K_RIGHT] and x < 1005:
x += vel
yazdir()
if keys[pygame.K_UP] and y > 5 :
y -= vel
yazdir()
if keys[pygame.K_DOWN] and y < 645:
y += vel
yazdir()
pygame.quit()