So i have a code that choses a random number between 1 and 2. If the code choses 1, i want to increase the probability of choosing 1 by 10%. If the code choses 2, i want to increase the probability of choosing by 2 15%. Here is my code :
import pygame, random,sys
pygame.init()
SCREEN_WIDTH = 500
SCREEN_HEIGHT = 500
BLACK = (0,0,0)
white = "#FFFFFF"
win = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Test")
def test2():
win.fill(BLACK)
test = random.randint(1,2)
text_font = pygame.font.Font('freesansbold.ttf', 100)
screws_text = text_font.render(str(test), True ,white)
textRect = screws_text.get_rect()
textRect.center = (250,250)
win.blit(screws_text, textRect)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
test2()
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
I didn't really tried anything because i have no idea that i should do, i never did that so i would be very grateful if you could help me.
Aucun commentaire:
Enregistrer un commentaire