restared made hybrid using two differnet sources to challenge myself

This commit is contained in:
Stephen Deaton 2024-07-15 18:35:30 -04:00
parent 64f4e2fa2a
commit b128e60872
2 changed files with 25 additions and 7 deletions

View File

@ -1,6 +1,7 @@
# https://www.youtube.com/watch?v=f4coFYbYQzw&list=PLjcN1EyupaQkAQyBCYKyf1jt1M1PiRJEp
import os
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
from pygame.sprite import Group
import pygame
from pygame.locals import *
import random
@ -12,11 +13,25 @@ WINDOW_SIZE = (WIDTH, HEIGHT)
FPS = 60
# 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():
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)
@ -35,19 +50,22 @@ clock = pygame.time.Clock()
running = True
while running:
clock.tick(FPS)
#draw background
draw_bg()
# event handlers
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB