restared made hybrid using two differnet sources to challenge myself
This commit is contained in:
parent
64f4e2fa2a
commit
b128e60872
|
@ -1,6 +1,7 @@
|
||||||
# https://www.youtube.com/watch?v=f4coFYbYQzw&list=PLjcN1EyupaQkAQyBCYKyf1jt1M1PiRJEp
|
# https://www.youtube.com/watch?v=f4coFYbYQzw&list=PLjcN1EyupaQkAQyBCYKyf1jt1M1PiRJEp
|
||||||
import os
|
import os
|
||||||
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
|
from pygame.sprite import Group
|
||||||
import pygame
|
import pygame
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
import random
|
import random
|
||||||
|
@ -12,11 +13,25 @@ WINDOW_SIZE = (WIDTH, HEIGHT)
|
||||||
FPS = 60
|
FPS = 60
|
||||||
|
|
||||||
# load background image
|
# load background image
|
||||||
bg = pygame.image.load("PyGame\practice\gameprac\img")
|
bg = pygame.image.load("img/bg.png") # FUCK THIS IN THE ASS FIXXED IT FUCK YEA
|
||||||
|
|
||||||
def draw_bg():
|
def draw_bg():
|
||||||
screen.blit(bg, 0, 0)
|
screen.blit(bg, (0, 0))
|
||||||
|
|
||||||
|
# create spaceship class
|
||||||
|
class Spaceship(pygame.sprite.Sprite):
|
||||||
|
def __init__(self,x ,y):
|
||||||
|
pygame.sprite.Sprite.__init__(self) # review init function
|
||||||
|
self.image = pygame.image.load("img/spaceship.png")
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
|
self.rect.center = [x,y]
|
||||||
|
|
||||||
|
|
||||||
|
# create sprite groups
|
||||||
|
spaceship_group = pygame.sprite.Group()
|
||||||
|
|
||||||
|
# create player
|
||||||
|
spaceship = Spaceship(int(WIDTH / 2), HEIGHT - 100)
|
||||||
|
spaceship_group.add(spaceship)
|
||||||
|
|
||||||
|
|
||||||
WHITE = (255, 255, 255)
|
WHITE = (255, 255, 255)
|
||||||
|
@ -35,19 +50,22 @@ clock = pygame.time.Clock()
|
||||||
|
|
||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
|
clock.tick(FPS)
|
||||||
|
|
||||||
#draw background
|
#draw background
|
||||||
draw_bg()
|
draw_bg()
|
||||||
|
|
||||||
# event handlers
|
# event handlers
|
||||||
clock.tick(FPS)
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
running = False
|
running = False
|
||||||
|
|
||||||
|
|
||||||
screen.fill(BLACK)
|
# draw sprite groups on screen
|
||||||
|
spaceship_group.draw(screen)
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.update() # Go over it again FLIP vs UPDATE Which to use When
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
PyGame/practice/gameprac/img/spaceship.png
Normal file
BIN
PyGame/practice/gameprac/img/spaceship.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue
Block a user