小编Red*_*227的帖子

为什么"打印"和"回声"功能不需要括号围绕它们

就是想.

谢谢.

而我只是把这个放到30个字符,忽略这一点:)

php printing brackets function echo

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

在 pygame 中每 x (milli) 秒做一些事情

我正在学习 Python 和 Pygame,我制作的第一件事是一个简单的 Snake 游戏。我试图让蛇每 0.25 秒移动一次。这是我循环的代码部分:

while True:
    check_for_quit()

    clear_screen()

    draw_snake()
    draw_food()

    check_for_direction_change()

    move_snake() #How do I make it so that this loop runs at normal speed, but move_snake() only executes once every 0.25 seconds?

    pygame.display.update()
Run Code Online (Sandbox Code Playgroud)

我希望所有其他函数都能正常运行,但 move_snake() 每 0.25 秒只发生一次。我查了一下,找到了一些答案,但对于制作第一个 Python 脚本的人来说,它们似乎都太复杂了。

是否有可能实际获得我的代码应该是什么样子的示例,而不仅仅是告诉我需要使用哪个函数?谢谢!

python pygame function milliseconds seconds

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

获取函数被调用的行?

我看了这个,我知道答案可能涉及使用debug_backtrace(),但我正在努力如何使用它或它究竟是做什么.

基本上,如果这是index.php:

<?php
//some code
//some more code

require "functions.php";

print_line();

//some code

print_line();
?>
Run Code Online (Sandbox Code Playgroud)

和functions.php是:

<?php
function print_line(){
    $line="[line that this function was called at]";
    print "This function was called from line $line of index.php<br />";
}
?>
Run Code Online (Sandbox Code Playgroud)

设置的正确方法是什么,$line以便输出为:

This function was called from line 7 of index.php
This function was called from line 11 of index.php
Run Code Online (Sandbox Code Playgroud)

php function call line

2
推荐指数
1
解决办法
1918
查看次数

Why is my pause system not working? (Pygame)

Here's my check_for_pause() function:

#Check if the user is trying to pause the game
def check_for_pause():
   keys=pygame.key.get_pressed() #Get status of all keys
   if keys[K_SPACE]: #The space bar is held down
       global paused #Make global so it can be edited
       if paused==True: #It was paused, so unpause it
           paused=False
       elif paused==False: #It was playing, so pause it
           paused=True

        #Don't let the main loop continue until the space bar has been released again, otherwise the variable will flicker between True and False …
Run Code Online (Sandbox Code Playgroud)

python pygame

0
推荐指数
1
解决办法
2056
查看次数

标签 统计

function ×3

php ×2

pygame ×2

python ×2

brackets ×1

call ×1

echo ×1

line ×1

milliseconds ×1

printing ×1

seconds ×1