python blit_python - pygame screen.blit()从非零y坐标 - 堆栈内存溢出

我想在特定水平[y]上绘制屏幕草,在那些下面我只希望显示灰尘。 这几乎是我所有的代码,删除的只是无关的东西

import pygame

from pygame import *

pygame.init()

width, height = 640, 480

screen = pygame.display.set_mode((width, height))

height_of_grass = 150

run = True

speed_of_player = 1

player = pygame.image.load("images/steve.png")

grass = pygame.image.load("images/grass_block.jpg")

dirt = pygame.image.load("images/dirt_block.jpg")

sky = pygame.image.load("images/sky.png")

clouds = pygame.image.load("images/cloud.png")

oak_wood_log = pygame.image.load("images/oak_wood_log.png")

oak_leaves = pygame.image.load("images/oak_leaves.png")

keys = [False, False, False, False]

player_position = [100, 100]

while run:

screen.fill((50, 168, 158))

screen.blit(player, player_position)

for x in range(int(width/grass.get_width()) + 1):

screen.blit(grass, (x*grass.get_width(), height_of_grass))

x = 0

for x in range(int(width/dirt.get_width()) + 1):

for y in range(height_of_grass, int(height / grass.get_height()) + 1):

screen.blit(dirt, (x*dirt.get_width, y*dirt.get_height))

pygame.display.flip()

for event in pygame.event.get():

if event == pygame.QUIT:

run = False

if player_position[0] < -16 or player_position[0] > (width + 16) or player_position[1] < -16 or player_position[1] > (height + 16):

print("You´ve broke the game! Congratilations")

exit(-1)

这只是我有问题的代码的一部分。 我的pygame窗口没有显示波纹管。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值