1
import pgzrun
import pygame



WIDTH = 850
HEIGHT = 425

#sprites

title = Actor('title.png')      #calling sprites and saying their pos
title.pos = 400, 212
cont = Actor('cont.png')
cont.pos = 470, 300
player = Actor('ship.png')
player.pos = 100, 56
foe = Actor('foe.png')
foe.pos = 200, 112
vel = 5


music.play("temp.mp3")

#controls

def draw():
    screen.clear()
    screen.fill((0, 0, 0))
    title.draw()
    cont.draw()
    foe.draw()
    player.draw()

def update():
    keys = pygame.key.get_pressed()
    x, y = player.pos
    x += (keys[pygame.K_d] - keys[pygame.K_a]) * vel
    y += (keys[pygame.K_s] - keys[pygame.K_w]) * vel
    player.pos = x, y
    if player.left > WIDTH: #if player hits right side of screen it takes the player to the other side of the screen
        player.right = 0


def otherimage():           #animation of ship
    player.image = 'ship.png'
    imagey()
def imagey():
    player.image = 'ship1.png'
    clock.schedule_unique(otherimage, 1.0) 

    
imagey()


pgzrun.go()

the animation section is the bit commented with "animation of ship". The wrapping bit is the bit labled "if player hits right side of screen it takes the player to the other side of the screen" as you can see i have go it working when the player hits the screen on the right side but every time i have tried getting it to work on the other sides it doesn't work. Please help! Thanks! Im new to coding and i am trying to understand this language. thanks again.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Whi_24
  • 41
  • 4

0 Answers0