I'm new to python/pygame and I'm trying to make a game. Basically it is a space ship floating around in space(it will be a scrolling background) pointing towards the mouse/crosshair. on clicking it will shoot bullets. there will be flying enemies which need AI and clinging enemies which need AI. Also liquids need to "flow." Collision detection for running into walls/bullets,enemies/floor. And lastly I will need a menu GUI (if i used gui in the right context.)
But right now, i would like to move the background (or for now the sprite) with keyboard controls. also how do I do a stretched image for the background?
This is what i've got:
import pygame, random, sys, time
pygame.init()
SIZE = [1000, 1000]
screen = pygame.display.set_mode(SIZE)
crosshair = pygame.image.load('crosshair.jpg')
player = pygame.image.load('spaceship.jpg')
pygame.display.set_caption("Solar Warfare")
WHITE = [255, 255, 255]
mouse_pos = []
spaceshipX = 0
spaceshipY = 0
done = False
pygame.mouse.set_visible(False)
while not done:
for event in pygame.event.get():
if event.type == pygame.MOUSEMOTION:
mouse_pos = pygame.mouse.get_pos([])
screen.blit(crosshair, (mouse_pos[0], mouse_pos[1]))
pygame.display.flip()#What is the other way to
#update the screen?
if event.type == pygame.QUIT:
done = True
if event.type == pygame.K_RIGHT:
spaceshipX += 1
screen.fill(WHITE)
screen.blit(player, (spaceshipX, spaceshipY))
screen.blit(crosshair, (mouse_pos))
pygame.display.flip()
pygame.quit()
I would like to add a scrolling background. I also need AI for the enemies, but thats later. Same with the Main Menu and levels and bosses/features etc... I talk alot XD