小编Bri*_*ian的帖子

Pygame display.info 给出错误的分辨率大小

我正在用 pygame 构建一个小游戏。我希望游戏的窗口是显示器分辨率的大小。我的电脑屏幕的分辨率是 1920x1080,display.info 说窗口大小也是 1920x1080,但是当我运行它时,它创建的窗口大约是我屏幕大小的一倍半。

import pygame, sys

def main():
    #set up pygame, main clock
    pygame.init()
    clock = pygame.time.Clock()

    #creates an object with the computers display information
    #current_h, current_w gives the monitors height and width
    displayInfo = pygame.display.Info()

    #set up the window
    windowWidth = displayInfo.current_w
    windowHeight = displayInfo.current_h
    window = pygame.display.set_mode ((windowWidth, windowHeight), 0, 32)
    pygame.display.set_caption('game')

    #gameLoop
    while True:
        window.fill((0,0,0))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        #draw the window onto the screen
        pygame.display.flip()
        clock.tick(60)

main()
Run Code Online (Sandbox Code Playgroud)

python pygame

4
推荐指数
1
解决办法
2210
查看次数

模板函数可以推导出lambda的参数吗?

带有函数指针的模板化函数可以推导出该函数指针的参数,如下所示:

template<class... Args>
void func(void (*ptr)(Args&& ...)) {
    //Do something useful knowing the Args...
}
Run Code Online (Sandbox Code Playgroud)

你可以用lambda作为参数吗?没有求助std::function或编写像function_traits这样的元编程特征类?即仅使用函数推导出参数.

c++ lambda function-pointers metaprogramming c++17

3
推荐指数
1
解决办法
196
查看次数