forked from ndyer/pygame-dvd
Compare commits
3 Commits
afe503bee4
...
399092238e
Author | SHA1 | Date | |
---|---|---|---|
399092238e | |||
dbd78bb5c5 | |||
31f6593ae0 |
@ -1 +0,0 @@
|
|||||||
from . import dvd_screen
|
|
Binary file not shown.
Before Width: | Height: | Size: 63 KiB |
@ -1,4 +1,4 @@
|
|||||||
import dvd_bounce
|
import steam_saver
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -11,4 +11,4 @@ if __name__ == '__main__':
|
|||||||
if arg == '--window':
|
if arg == '--window':
|
||||||
windowed_mode = True
|
windowed_mode = True
|
||||||
|
|
||||||
dvd_bounce.main.main(windowed_mode)
|
steam_saver.main.main(windowed_mode)
|
@ -1,11 +1,11 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import dvd_bounce.surfaces as surfaces
|
import steam_saver.surfaces as surfaces
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
SCREEN_SIZE = (1920, 1080)
|
SCREEN_SIZE = (1920, 1080)
|
||||||
FPS = 60
|
FPS = 60
|
||||||
VALID_SURFACES = [
|
VALID_SURFACES = [
|
||||||
'dvd_screen'
|
'steam_screen'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ def main(windowed_mode=False):
|
|||||||
else:
|
else:
|
||||||
window = pygame.display.set_mode(SCREEN_SIZE, pygame.FULLSCREEN)
|
window = pygame.display.set_mode(SCREEN_SIZE, pygame.FULLSCREEN)
|
||||||
|
|
||||||
# Starts the program with the surface 'dial' as the default
|
# Starts the program with the surface 'steam_screen' as the default
|
||||||
surface = getattr(globals()['surfaces'], 'dvd_screen').Surface(SCREEN_SIZE)
|
surface = getattr(globals()['surfaces'], 'steam_screen').Surface(SCREEN_SIZE)
|
||||||
running = True
|
running = True
|
||||||
while running:
|
while running:
|
||||||
clock.tick(FPS)
|
clock.tick(FPS)
|
1
steam_saver/surfaces/__init__.py
Normal file
1
steam_saver/surfaces/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from . import steam_screen
|
BIN
steam_saver/surfaces/resources/steam_logo.png
Normal file
BIN
steam_saver/surfaces/resources/steam_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
@ -3,15 +3,15 @@ import os
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
LOGO_SCALING = 0.1
|
LOGO_SCALING = .5
|
||||||
|
|
||||||
|
|
||||||
class DVDLogo(pygame.sprite.Sprite):
|
class SteamLogo(pygame.sprite.Sprite):
|
||||||
"""
|
"""
|
||||||
A Pygame sprite representing a DVD logo that moves around the screen.
|
A Pygame sprite representing a Steam logo that moves around the screen.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
base_image (pygame.Surface): The original image of the DVD logo.
|
base_image (pygame.Surface): The original image of the Steam logo.
|
||||||
x_speed (int): Current speed in the X axis.
|
x_speed (int): Current speed in the X axis.
|
||||||
y_speed (int): Current speed in the Y axis.
|
y_speed (int): Current speed in the Y axis.
|
||||||
max_x (int): Maximum X position on the screen.
|
max_x (int): Maximum X position on the screen.
|
||||||
@ -20,7 +20,7 @@ class DVDLogo(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
def __init__(self, window_size: tuple):
|
def __init__(self, window_size: tuple):
|
||||||
"""
|
"""
|
||||||
Initialize DVDLogo sprite with given window size.
|
Initialize SteamLogo sprite with given window size.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
window_size (tuple): Size of the game window (width, height).
|
window_size (tuple): Size of the game window (width, height).
|
||||||
@ -28,10 +28,11 @@ class DVDLogo(pygame.sprite.Sprite):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Load and scale original logo image
|
# Load and scale original logo image
|
||||||
self.base_image = pygame.image.load(SCRIPT_DIR + '/resources/dvd.png')
|
self.base_image = pygame.image.load(SCRIPT_DIR + '/resources/steam_logo.png')
|
||||||
self.base_image.convert_alpha()
|
self.base_image.convert_alpha()
|
||||||
self.base_image = pygame.transform.scale(self.base_image, (self.base_image.get_width() * LOGO_SCALING,
|
self.base_image = pygame.transform.smoothscale(self.base_image,
|
||||||
self.base_image.get_height() * LOGO_SCALING))
|
(self.base_image.get_width() * LOGO_SCALING,
|
||||||
|
self.base_image.get_height() * LOGO_SCALING))
|
||||||
|
|
||||||
# Copy the base image and store it in a separate instance variable; this is the image that will be drawn.
|
# Copy the base image and store it in a separate instance variable; this is the image that will be drawn.
|
||||||
self.image = self.base_image.copy()
|
self.image = self.base_image.copy()
|
||||||
@ -68,7 +69,7 @@ class DVDLogo(pygame.sprite.Sprite):
|
|||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
Update DVDLogo sprite's position and speed based on its current state.
|
Update SteamLogo sprite's position and speed based on its current state.
|
||||||
|
|
||||||
This method is called each frame during game execution to move the logo around
|
This method is called each frame during game execution to move the logo around
|
||||||
the screen and to handle collision/color changes.
|
the screen and to handle collision/color changes.
|
||||||
@ -121,9 +122,9 @@ class Surface(pygame.Surface):
|
|||||||
|
|
||||||
pygame.mouse.set_visible(False)
|
pygame.mouse.set_visible(False)
|
||||||
|
|
||||||
# Create a DVDLogo sprite instance and add it to the sprite group.
|
# Create a SteamLogo sprite instance and add it to the sprite group.
|
||||||
dvd_logo = DVDLogo(window_size)
|
steam_logo = SteamLogo(window_size)
|
||||||
self.all_sprites = pygame.sprite.Group(dvd_logo)
|
self.all_sprites = pygame.sprite.Group(steam_logo)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
@ -146,4 +147,4 @@ class Surface(pygame.Surface):
|
|||||||
self.all_sprites.update()
|
self.all_sprites.update()
|
||||||
|
|
||||||
# Draw all sprites onto this surface.
|
# Draw all sprites onto this surface.
|
||||||
self.all_sprites.draw(self)
|
self.all_sprites.draw(self)
|
Loading…
Reference in New Issue
Block a user