![]() |
допустим ты написал код 2д игры на python. где запускать эту игру? на примере ты создал змейку, как открыть ее как полноценную игру? как здесь:
0b0fa54d-a5ac-4720-9633-c4318d765226.jpgkwzInside · 17 Май 2023 в 16:29' data-fancybox="lb-post-1311796" data-lb-caption-extra-html="" data-lb-sidebar-href="" data-single-image="1" data-src="https://www.blast.hk/attachments/201842/" style="cursor: pointer;" title="0b0fa54d-a5ac-4720-9633-c4318d765226.jpg"> https://forum.antichat.xyz/attachmen...73f80b0aec.png |
если ты пишешь на pygame, тебе нужно получить текущий размер экрана, и с помощью функции pygame.display.set_mode, с флагом pygame.NOFRAME написать вот такой код:
Python: Код:
window_flagsp.s. чтобы получить текущий размер экрана с помощью pygame пишешь вот этот код: Python: Код:
info |
1684335398848.pngtfornik · 17 Май 2023 в 17:57' data-fancybox="lb-post-1311868" data-lb-caption-extra-html="" data-lb-sidebar-href="" data-single-image="1" data-src="https://www.blast.hk/attachments/201847/" style="cursor: pointer;" title="1684335398848.png">
https://forum.antichat.xyz/attachmen...7ecd8d8639.png Тыкаешь сюда( там где у тебя py-файл ) и вводишь команду python *название*.py Это если у тебя python скачан на пк |
Цитата:
|
так чё тебе надо ты опиши нормально
|
Цитата:
|
Цитата:
|
скинь код свой
|
Цитата:
|
Цитата:
[CODE] import random import pygame as pg WSIZE = ( 720 , 480 ) screen = pg . display . set_mode ( WSIZE ) TSIDE = 30 MSIZE = WSIZE [ 0 ] // TSIDE , WSIZE [ 1 ] // TSIDE start_pos = MSIZE [ 0 ] // 2 , MSIZE [ 1 ] // 2 snake = [ start_pos ] alive = True direction = 0 directions = [ ( 1 , 0 ) , ( 0 , 1 ) , ( - 1 , 0 ) , ( 0 , - 1 ) ] apple = random . randint ( 0 , MSIZE [ 0 ] - 1 ) , random . randint ( 0 , MSIZE [ 1 ] - 1 ) fps = 5 clock = pg . time . Clock ( ) pg . font . init ( ) font_score = pg . font . SysFont ( "Arial" , 25 ) font_gameover = pg . font . SysFont ( "Arial" , 45 ) font_space = pg . font . SysFont ( "Arial" , 18 ) running = True while running : clock . tick ( fps ) screen . fill ( "black" ) for event in pg . event . get ( ) : if event . type == pg . QUIT : running = False if event . type == pg . KEYDOWN : if alive : if event . key == pg . K_RIGHT and direction != 2 : direction = 0 if event . key == pg . K_DOWN and direction != 3 : direction = 1 if event . key == pg . K_LEFT and direction != 0 : direction = 2 if event . key == pg . K_UP and direction != 1 : direction = 3 else : if event . key == pg . K_SPACE : alive = True snake = [ start_pos ] apple = random . randint ( 0 , MSIZE [ 0 ] - 1 ) , random . randint ( 0 , MSIZE [ 1 ] - 1 ) fps = 5 [ pg . draw . rect ( screen , "green" , ( x * TSIDE , y * TSIDE , TSIDE - 1 , TSIDE - 1 ) ) for x , y in snake ] pg . draw . rect ( screen , "red" , ( apple [ 0 ] * TSIDE , apple [ 1 ] * TSIDE , TSIDE - 1 , TSIDE - 1 ) ) if alive : new_pos = snake [ 0 ] [ 0 ] + directions [ direction ] [ 0 ] , snake [ 0 ] [ 1 ] + directions [ direction ] [ 1 ] if not ( 0 |
| Время: 03:26 |