当我运行以下代码时,出现白屏,然后迅速消失。我在VSCode终端上使用pip3安装了pygame(我在Mac上),现在终于可以导入pygame了,对于每个名为“ clock”或“ pygame.KEYDOWN”的函数,我都会遇到多个错误。他们说“模块'pygame'没有'KEYDOWN'成员” [E1101]。 “ init”成员也出现错误。
我看过其他文章,告诉我将某些内容复制并粘贴到json设置中,但是当我尝试进行操作时,遇到了更多错误。
#Game
#By Robert Smith
#Initialize python
import pygame
pygame.init()
#Set the screen
screen = pygame.display.set_mode((640, 480))
background = pygame.Surface(screen.get_size())
background.fill((255,255,255))
background = background.convert()
screen.blit(background, (0 , 0))
#Make the window exitable
for event in pygame.event.get():
if event.type == pygame.QUIT:
mainloop == False #close the window
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
mainloop = False
#Set the framerate
milliseconds = clock.tick(60)#DO NOT GO FASTER THAN THIS FRAMERATE
答案 0 :(得分:0)
尝试一下:
'use strict';
const aws = require('aws-sdk');
var newScore = 123;
var docClient = new AWS.DynamoDB.DocumentClient()
var params = {
TableName: "players",
Key: {
"email": "johndoe@gmail.com"
},
UpdateExpression: "set score = :num",
ConditionExpression: "score > :num",
ExpressionAttributeValues: {
":num": newScore
},
ReturnValues: "UPDATED_NEW"
};
docClient.update(params, function(err, data) {
if (err) console.log(err);
else console.log(data);
}
});
这:
keys = pygame.key.get_pressed()
for event in pygame.event.get():
if event.type == pygame.QUIT:
mainloop == False #close the window
elif event.type == keys[pygame.K_DOWN]:
if event.key == keys[pygame.K_ESCAPE]:
mainloop = False