我正在尝试在按住键的同时移动图片,但它总是只移动一个像素。在类似的问题中,我看到这是对的,但它对我不起作用。
import pygame, sys
x = 0
y = 0
class Ship:
def __init__(self, image):
self.image = pygame.image.load(image)
def Play(self, screen, x, y):
self.screen = screen
self.screen.blit(self.image, [x, y])
if __name__ == "__main__":
ship = Ship('Lod.png')
while True:
window = pygame.display.set_mode([1000, 1000])
window.fill([0, 105, 148])
Key = pygame.key.get_pressed()
if Key[pygame.K_LEFT]:
x -= 1
if Key[pygame.K_RIGHT]:
x += 1
ship.Play(window, x, y)
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
pygame.display.flip()
答案 0 :(得分:0)
将<asp:PlaceHolder ID="myPlaceHolder" runat="server">
<hr id="someElement" runat="server" />
</asp:PlaceHolder>
protected void Page_Init(object sender, EventArgs e)
{
myPlaceHolder.SetRenderMethodDelegate(ClosingRenderMethod);
}
protected void ClosingRenderMethod(HtmlTextWriter output, Control container)
{
var voidTags = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) { "br", "hr", "link", "img" };
foreach (Control child in container.Controls)
{
var generic = child as HtmlGenericControl;
if (generic != null && voidTags.Contains(generic.TagName))
{
output.WriteBeginTag(generic.TagName);
output.WriteAttribute("id", generic.ClientID);
generic.Attributes.Render(output);
output.Write(HtmlTextWriter.SelfClosingTagEnd);
}
else
{
child.RenderControl(output);
}
}
}
移出循环有帮助。谢谢!