2 877
Repost from N/a
بهترین کانال های برنامه نویسی 👩💻
https://t.me/addlist/o0vXuFHF1hdkNTE0
23 ژوئن 2024, 14:19
24 ژوئن 2024, ~03:18
نیوریک | هوش مصنوعی فراتر از خبر ، Neuric.ir : سایت گروه : @IRdeveloperchat لینکدین : ارتباط : @Neuric_Support
نمایش بیشتر.box{
Transform: translateX(300px)
}
💥 دقت کنید که گفتم translateX 300px بمعنایی اینکه از روی محور x حرکت کنه شکل و چون قیمتی که ما دادیم مثبت هست پس میره به سمت راست. و به همین صورت
و در قسمت محور y هم به همین شکل است ولی اگر قسمت منفی بدید میره به سمت بالا اگر قیمت مثبت بدید میره به سمت پایین
امیدوارم که فهمیده باشید❤️
خاصیت های بعدی را در پست های بعدی میگم
#css #html #animation #transform #translate
Channel • @Cafe_Of_Code
Group • @Cafe_Code_Gapimport os
shut down=input("do you want to shutdown your computer(yes/no):")
:'if shutdown=='yes
os.system("shutdown/s/t1")
:else
print('shutdown is not requested')
💥پیش از اجرای این برنامه، باید از ذخیره کردن اسناد و برنامهها اطمینان حاصل کرد و از آنها خارج شد. زیرا پس از اجرای این برنامه، کامپیوتر خاموش میشود و ممکن است دادههای ذخیره نشده از بین بروند
#programming #python
Channel • @Cafe_Of_Code
Group • @IRdeveloperchatimport pygame
import random
# تعریف رنگها
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# تنظیمات پنجره
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
# تعداد دایرهها
NUM_CIRCLES = 10
# ایجاد صفحه
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption('Drawing Circles with Pygame')
clock = pygame.time.Clock()
# تعریف تابع برای رسم دایره
def draw_circle(surface, color, pos, radius):
pygame.draw.circle(surface, color, pos, radius)
# حلقه اصلی برنامه
running = True
circle_info = []
for _ in range(NUM_CIRCLES):
circle_color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
circle_pos = (random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT))
circle_radius = random.randint(10, 50)
circle_speed = [random.uniform(-1, 1), random.uniform(-1, 1)]
circle_info.append({"color": circle_color, "pos": circle_pos, "radius": circle_radius, "speed": circle_speed})
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(WHITE)
# رسم دایرهها و حرکت آنها
for circle in circle_info:
draw_circle(screen, circle["color"], circle["pos"], circle["radius"])
circle["pos"] = (circle["pos"][0] + circle["speed"][0], circle["pos"][1] + circle["speed"][1])
if circle["pos"][0] > SCREEN_WIDTH or circle["pos"][0] < 0:
circle["speed"][0] *= -1
if circle["pos"][1] > SCREEN_HEIGHT or circle["pos"][1] < 0:
circle["speed"][1] *= -1
pygame.display.flip()
clock.tick(60)
pygame.quit()
1⃣طبق همیشه اول میایم کتابخانه رو امپورت میکنیم
بعد میایم رنگ ها رو تعریف میکنم.
NUM_CIRCLES = 10به این بخش میایم تعداد دایره ها مونو مینویسیم من 10 تا دایره را تعیین کردم 2⃣و بعد میایم میایم یک تابع تعریف میکنیم
def draw_circle(surface, color, pos, radius):
pygame.draw.circle(surface, color, pos, radius)
که چهار قیمت داره این تابع برای رسم دایره ها بکار میره
بعد میایم دایره ها رو رسم میکنیم به هر کدوم یک قیمت یک اندازه یک حالت و یک رنگ رو میدیم
بعد دایره ها رو به حالت شناور تغییر میدیم
for circle in circle_info:
draw_circle(screen, circle["color"], circle["pos"], circle["radius"])
circle["pos"] = (circle["pos"][0] + circle["speed"][0], circle["pos"][1] + circle["speed"][1])
if circle["pos"][0] > SCREEN_WIDTH or circle["pos"][0] < 0:
circle["speed"][0] *= -1
if circle["pos"][1] > SCREEN_HEIGHT or circle["pos"][1] < 0:
circle["speed"][1] *= -1
pygame.display.flip()
clock.tick(60)
این بود از این جلسه
راستی بعد از هر بار اجرا رنگ و اندازه دایره ها تغییر میکنه
اگه مشکلی بود تو کامنت ها بپرسید
#پایتون #پایگیم #جلسه_چهارم_پایگیم
#python #pygame #part_4_pygame
#Ah_sear
Channel ° @Cafe_Of_Code
Group ° @IRdeveloperchat