0
import pygame

#intialize the pygame
pygame.init()

# create the screen
screen = pygame.display.set_mode((800,600))
# Title and Icon
pygame.display.set_caption("Space Invader")
icon = pygame.image.load('spaceship (1).png')
pygame.display.set_icon(icon)

# Player
playerImg = pygame.image.load('ship.png.png')
playerX = 400
playerY = 490

def player(x,y):
    screen.blit(playerImg, (x, y))

# game Loop
running = True
while running:
    # RGB - Red, Green, Blue
    screen.fill((0, 0, 0))
    playerX += .1

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    player(playerX, playerY)
    pygame.display.update()
Kingsley
  • 14,398
  • 5
  • 31
  • 53
  • What error are you getting? – Donnie Nov 04 '19 at 23:51
  • I fixed the question-text formatting, and it works for me. Maybe it was the indentation of the call to `player(playerX, playerY)` and `pygame.display.update()` ? – Kingsley Nov 04 '19 at 23:52
  • {import pygame} {pygame.init()} {screen = pygame.display.set_mode((800,600))} {pygame.display.set_caption("Space Invader")}{icon = pygame.image.load('spaceship (1).png')}{pygame.display.set_icon(icon)}{playerImg = pygame.image.load('ship.png.png')}{playerX = 400}{playerY = 490}{def player(x,y):} {screen.blit(playerImg, (x, y))}{running = True}{while running:} {screen.fill((0, 0, 0))} { playerX += .1for event in pygame.event.get()}: { if event.type == pygame.QUIT:} running = False {player(playerX, playerY)} {pygame.display.update() } – Adam Johnson Nov 04 '19 at 23:53
  • it say "DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python. screen.blit(playerImg, (x, y))" – Adam Johnson Nov 04 '19 at 23:54
  • Information that is critical to your question must be edited into the question. As you can see, comments are virtually useless for code. – Prune Nov 04 '19 at 23:57
  • You can get rid of the warning by `screen.blit(playerImg, (round(x), round(y)))` – Rabbid76 Nov 05 '19 at 05:58
  • thankyou for you help Rabbid76 and all of you guys! – Adam Johnson Nov 06 '19 at 01:42

1 Answers1

0

it say

"DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python. screen.blit(playerImg, (x, y))"

The warning is related to the coordinate parameter of blit(). Floating point coordinates, would mean that the origin of the Surface is somewhere in between to pixels in the window. That doesn't make much sense. The coordinates are automatically, implicitly truncated and that is indicated by the warning.
Use either int or round to convert the floating point coordinates to integral numbers:

def player(x,y):
    screen.blit(playerStand, (round(x), round(y)))
Rabbid76
  • 202,892
  • 27
  • 131
  • 174