4 תשובות
אם היה לי פייתון הייתי כותב
פייתון זאתי שפת תכנות
import pygame
# initialize pygame
pygame.init()
# set the window size and title
screen = pygame.display.set_mode((400, 600))
pygame.display.set_caption("menorah")
# load the candle images
candle_img = pygame.image.load("candle.png")
lit_candle_img = pygame.image.load("lit_candle.png")
# set the position and size of each candle
candle_positions = [
(50, 50, 50, 200),
(100, 50, 50, 200),
(150, 50, 50, 200),
(200, 50, 50, 200),
(250, 50, 50, 200),
(300, 50, 50, 200),
(75, 300, 50, 300),
(125, 300, 50, 300),
(175, 300, 50, 300),
]
# set the current day and the index of the next candle to be lit
day = 1
next_candle = 6
# main game loop
running = true
while running:
# handle events
for event in pygame.event.get():
if event.type == pygame.quit:
running = false
# clear the screen
screen.fill((0, 0, 0))
# draw the candles
for i, position in enumerate(candle_positions):
if i < next_candle:
screen.blit(lit_candle_img, position)
else:
screen.blit(candle_img, position)
# draw the shamash (center candle)
screen.blit(lit_candle_img, (125, 300, 50, 300))
# update the display
pygame.display.flip()
# increment the day and update the index of the next candle to be lit
day += 1
next_candle += 1
if next_candle > 8:
next_candle = 0
# quit pygame
pygame.quit()
זה תמיד הופך את זה בשליחה באתר הזה אבל זה קוד בפייתון שיוצר מנורה ומדליק נרות עם גרפיקה
# initialize pygame
pygame.init()
# set the window size and title
screen = pygame.display.set_mode((400, 600))
pygame.display.set_caption("menorah")
# load the candle images
candle_img = pygame.image.load("candle.png")
lit_candle_img = pygame.image.load("lit_candle.png")
# set the position and size of each candle
candle_positions = [
(50, 50, 50, 200),
(100, 50, 50, 200),
(150, 50, 50, 200),
(200, 50, 50, 200),
(250, 50, 50, 200),
(300, 50, 50, 200),
(75, 300, 50, 300),
(125, 300, 50, 300),
(175, 300, 50, 300),
]
# set the current day and the index of the next candle to be lit
day = 1
next_candle = 6
# main game loop
running = true
while running:
# handle events
for event in pygame.event.get():
if event.type == pygame.quit:
running = false
# clear the screen
screen.fill((0, 0, 0))
# draw the candles
for i, position in enumerate(candle_positions):
if i < next_candle:
screen.blit(lit_candle_img, position)
else:
screen.blit(candle_img, position)
# draw the shamash (center candle)
screen.blit(lit_candle_img, (125, 300, 50, 300))
# update the display
pygame.display.flip()
# increment the day and update the index of the next candle to be lit
day += 1
next_candle += 1
if next_candle > 8:
next_candle = 0
# quit pygame
pygame.quit()
זה תמיד הופך את זה בשליחה באתר הזה אבל זה קוד בפייתון שיוצר מנורה ומדליק נרות עם גרפיקה
שואל השאלה:
אמאלה תודה תודה תודה
אמאלה תודה תודה תודה
אנונימית
באותו הנושא: