mirror of
https://github.com/csd4ni3l/shatterstack.git
synced 2025-11-05 05:58:18 +01:00
add combos, use Roboto instead of Proton Strike, update for better constants, add break sound effect
This commit is contained in:
6
CREDITS
6
CREDITS
@@ -1,3 +1,9 @@
|
||||
The Roboto Black font used in this project is licensed under the Open Font License. Read assets/fonts/OFL.txt for more information.
|
||||
|
||||
Thanks to Freesound.org / kevinkac for the Crate Break 1 sound effect! (https://freesound.org/people/kevinkace/sounds/66777/)
|
||||
Licensed under the Creative Commons Zero v1.0 Universal (CC0 1.0) Public Domain Dedication
|
||||
https://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
Thanks to OpenGameArt and pixelsphere.org / The Cynic Project for the music! (https://opengameart.org/content/crystal-cave-mysterious-ambience-seamless-loop)
|
||||
|
||||
Huge Thanks to Python for being the programming language used in this game.
|
||||
|
||||
93
assets/fonts/OFL.txt
Normal file
93
assets/fonts/OFL.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
Copyright 2011 The Roboto Project Authors (https://github.com/googlefonts/roboto-classic)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
BIN
assets/fonts/Roboto-Black.ttf
Normal file
BIN
assets/fonts/Roboto-Black.ttf
Normal file
Binary file not shown.
BIN
assets/sound/break.wav
Normal file
BIN
assets/sound/break.wav
Normal file
Binary file not shown.
64
game/play.py
64
game/play.py
@@ -1,9 +1,8 @@
|
||||
import os
|
||||
import arcade, arcade.gui, random, math, json
|
||||
import os, arcade, arcade.gui, random, math, json, time
|
||||
|
||||
from game.sprites import Shape
|
||||
from utils.constants import SHAPES, CELL_SIZE, ROWS, COLS, menu_background_color, OUTLINE_WIDTH, COLORS, button_style
|
||||
from utils.preload import button_texture, button_hovered_texture, click_sound
|
||||
from utils.constants import SHAPES, CELL_SIZE, ROWS, COLS, OUTLINE_WIDTH, COLORS, COMBO_TIME, button_style
|
||||
from utils.preload import button_texture, button_hovered_texture, click_sound, break_sound
|
||||
|
||||
class Game(arcade.gui.UIView):
|
||||
def __init__(self, pypresence_client):
|
||||
@@ -17,10 +16,10 @@ class Game(arcade.gui.UIView):
|
||||
self.shapes = []
|
||||
|
||||
self.shape_to_place = random.choice(list(SHAPES.keys()))
|
||||
self.shape_color = random.choice(list(COLORS.values()))
|
||||
self.shape_color = random.choice(COLORS)
|
||||
|
||||
self.next_shape_to_place = random.choice(list(SHAPES.keys()))
|
||||
self.next_shape_color = random.choice(list(COLORS.values()))
|
||||
self.next_shape_color = random.choice(COLORS)
|
||||
|
||||
self.start_x = self.window.width / 2 - (COLS * (CELL_SIZE + OUTLINE_WIDTH)) / 2 + (CELL_SIZE / 2)
|
||||
self.start_y = self.window.height - (ROWS * (CELL_SIZE + OUTLINE_WIDTH)) - (CELL_SIZE / 2)
|
||||
@@ -32,6 +31,8 @@ class Game(arcade.gui.UIView):
|
||||
self.high_score = 0
|
||||
|
||||
self.score = 0
|
||||
self.combo = 0
|
||||
self.last_combo = time.perf_counter()
|
||||
|
||||
self.anchor = self.add_widget(arcade.gui.UIAnchorLayout())
|
||||
|
||||
@@ -57,17 +58,20 @@ class Game(arcade.gui.UIView):
|
||||
self.setup_grid()
|
||||
|
||||
self.mouse_shape = Shape(0, 0, self.shape_to_place, self.shape_color, self.mouse_shape_list)
|
||||
self.next_shape_ui = Shape(self.window.width - (CELL_SIZE * 4), self.window.height - (CELL_SIZE * 4), self.next_shape_to_place, self.next_shape_color, self.shape_list)
|
||||
self.next_shape_ui = Shape(self.window.width - (CELL_SIZE * 3), self.window.height - (CELL_SIZE * 3), self.next_shape_to_place, self.next_shape_color, self.shape_list)
|
||||
|
||||
self.score_box = self.anchor.add(arcade.gui.UIBoxLayout(space_between=10, vertical=False), anchor_x="center", anchor_y="top")
|
||||
|
||||
self.score_label = self.score_box.add(arcade.gui.UILabel(text="Score: 0", font_name="Protest Strike", font_size=24))
|
||||
self.high_score_label = self.score_box.add(arcade.gui.UILabel(text=f"High Score: {self.high_score}", font_name="Protest Strike", font_size=24))
|
||||
self.score_label = self.score_box.add(arcade.gui.UILabel(text="Score: 0", font_name="Roboto", font_size=24))
|
||||
self.high_score_label = self.score_box.add(arcade.gui.UILabel(text=f"High Score: {self.high_score}", font_name="Roboto", font_size=24))
|
||||
|
||||
self.back_button = arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text='<--', style=button_style, width=100, height=50)
|
||||
self.back_button.on_click = lambda e: self.main_exit()
|
||||
self.anchor.add(self.back_button, anchor_x="left", anchor_y="top", align_x=5, align_y=-5)
|
||||
|
||||
|
||||
self.combo_label = self.anchor.add(arcade.gui.UILabel(text=f"Combo X{self.combo}", font_name="Roboto", font_size=32), anchor_x="center", anchor_y="center")
|
||||
self.combo_label.visible = False
|
||||
|
||||
self.pypresence_client.update(state='In Game', details='Shattering Stacks', start=self.pypresence_client.start_time)
|
||||
|
||||
self.window.set_mouse_visible(False)
|
||||
@@ -75,6 +79,7 @@ class Game(arcade.gui.UIView):
|
||||
def setup_grid(self):
|
||||
for row in range(ROWS):
|
||||
self.occupied[row] = {}
|
||||
|
||||
for col in range(COLS):
|
||||
self.occupied[row][col] = 0
|
||||
center_x = self.start_x + col * (CELL_SIZE + OUTLINE_WIDTH)
|
||||
@@ -117,7 +122,12 @@ class Game(arcade.gui.UIView):
|
||||
|
||||
for col in range(COLS):
|
||||
self.occupied[row_idx][col] = 0
|
||||
self.score += 25
|
||||
self.score += 25 + (10 * self.combo)
|
||||
|
||||
break_sound.play()
|
||||
|
||||
self.combo += 1
|
||||
self.last_combo = time.perf_counter()
|
||||
|
||||
for col in range(COLS):
|
||||
column = [row[col] for row in self.occupied.values()]
|
||||
@@ -127,14 +137,30 @@ class Game(arcade.gui.UIView):
|
||||
|
||||
for row_idx in range(ROWS):
|
||||
self.occupied[row_idx][col] = 0
|
||||
self.score += 25
|
||||
self.score += 25 + (10 * self.combo)
|
||||
|
||||
break_sound.play()
|
||||
self.combo += 1
|
||||
self.last_combo = time.perf_counter()
|
||||
|
||||
def update_game(self):
|
||||
self.check_collisions()
|
||||
|
||||
self.score_label.text = f"Score: {self.score}"
|
||||
|
||||
if self.score > self.high_score:
|
||||
self.high_score = self.score
|
||||
self.high_score_label.text = f"High Score: {self.high_score}"
|
||||
|
||||
if time.perf_counter() - self.last_combo >= COMBO_TIME:
|
||||
self.combo = 0
|
||||
|
||||
if self.combo > 1:
|
||||
self.combo_label.text = f"Combo X{self.combo}"
|
||||
self.combo_label.visible = True
|
||||
else:
|
||||
self.combo_label.visible = False
|
||||
|
||||
self.check_game_over()
|
||||
|
||||
def check_game_over(self):
|
||||
@@ -144,10 +170,11 @@ class Game(arcade.gui.UIView):
|
||||
if can_place:
|
||||
return
|
||||
|
||||
self.game_over_label = self.anchor.add(arcade.gui.UILabel(text="GAME OVER", font_name="Protest Strike", font_size=64), anchor_x="center", anchor_y="center")
|
||||
self.game_over_label = self.anchor.add(arcade.gui.UILabel(text="GAME OVER", font_name="Roboto", font_size=64), anchor_x="center", anchor_y="center")
|
||||
|
||||
self.shape_list.clear()
|
||||
self.mouse_shape_list.clear()
|
||||
self.anchor.remove(self.combo_label)
|
||||
|
||||
self.window.set_mouse_visible(True)
|
||||
|
||||
@@ -159,15 +186,15 @@ class Game(arcade.gui.UIView):
|
||||
def on_mouse_press(self, x: int, y: int, button: int, modifiers: int) -> bool | None:
|
||||
super().on_mouse_press(x, y, button, modifiers)
|
||||
|
||||
if self.settings_dict.get("sfx", True):
|
||||
click_sound.play(volume=self.settings_dict.get("sfx_volume", 50) / 100)
|
||||
|
||||
grid_col = math.ceil((x - self.start_x + (CELL_SIZE / 2)) // (CELL_SIZE + OUTLINE_WIDTH))
|
||||
grid_row = math.ceil((y - self.start_y + (CELL_SIZE / 2)) // (CELL_SIZE + OUTLINE_WIDTH))
|
||||
|
||||
can_place, center_x, center_y = self.check_occupation(grid_col, grid_row)
|
||||
|
||||
if can_place:
|
||||
if self.settings_dict.get("sfx", True):
|
||||
click_sound.play(volume=self.settings_dict.get("sfx_volume", 50) / 100)
|
||||
|
||||
shape = Shape(center_x, center_y, self.shape_to_place, self.shape_color, self.shape_list)
|
||||
self.shapes.append(shape)
|
||||
|
||||
@@ -188,10 +215,11 @@ class Game(arcade.gui.UIView):
|
||||
self.update_game()
|
||||
|
||||
self.next_shape_to_place = random.choice(list(SHAPES.keys()))
|
||||
self.next_shape_color = random.choice(list(COLORS.values()))
|
||||
self.next_shape_color = random.choice(COLORS)
|
||||
self.next_shape_ui.update(self.next_shape_to_place, self.next_shape_color)
|
||||
|
||||
def on_draw(self):
|
||||
super().on_draw()
|
||||
self.window.clear()
|
||||
self.shape_list.draw()
|
||||
self.mouse_shape_list.draw()
|
||||
self.ui.draw()
|
||||
@@ -1,5 +1,5 @@
|
||||
import arcade, random
|
||||
from utils.constants import SHAPES, COLORS, CELL_SIZE, OUTLINE_WIDTH
|
||||
import arcade
|
||||
from utils.constants import SHAPES, CELL_SIZE, OUTLINE_WIDTH
|
||||
|
||||
class Shape():
|
||||
def __init__(self, x, y, shape_type, shape_color, sprite_list: arcade.SpriteList):
|
||||
|
||||
@@ -40,8 +40,6 @@ class Main(arcade.gui.UIView):
|
||||
self.pypresence_client = FakePyPresence()
|
||||
self.pypresence_client.start_time = start_time
|
||||
|
||||
self.pypresence_client.update(state='In Menu',
|
||||
details=f'In Main Menu', start=self.pypresence_client.start_time)
|
||||
else: # game has started, but the user has disabled RPC in the settings.
|
||||
self.pypresence_client = FakePyPresence()
|
||||
self.pypresence_client.start_time = time.time()
|
||||
@@ -51,7 +49,7 @@ class Main(arcade.gui.UIView):
|
||||
def on_show_view(self):
|
||||
super().on_show_view()
|
||||
|
||||
self.title_label = self.box.add(arcade.gui.UILabel(text="ShatterStack", font_name="Protest Strike", font_size=48))
|
||||
self.title_label = self.box.add(arcade.gui.UILabel(text="ShatterStack", font_name="Roboto", font_size=48))
|
||||
|
||||
self.play_button = self.box.add(arcade.gui.UITextureButton(text="Play", texture=button_texture, texture_hovered=button_hovered_texture, width=self.window.width / 2, height=150, style=button_style))
|
||||
self.play_button.on_click = lambda event: self.play()
|
||||
|
||||
@@ -82,7 +82,7 @@ class Settings(arcade.gui.UIView):
|
||||
self.value_layout.clear()
|
||||
|
||||
for setting in settings[category]:
|
||||
label = arcade.gui.UILabel(text=setting, font_name="Protest Strike", font_size=28, text_color=arcade.color.WHITE )
|
||||
label = arcade.gui.UILabel(text=setting, font_name="Roboto", font_size=28, text_color=arcade.color.WHITE )
|
||||
self.key_layout.add(label)
|
||||
|
||||
setting_dict = settings[category][setting]
|
||||
@@ -196,18 +196,18 @@ class Settings(arcade.gui.UIView):
|
||||
self.pypresence_client = FakePyPresence()
|
||||
self.pypresence_client.start_time = start_time
|
||||
|
||||
self.ui_cleanup()
|
||||
self.ui_cleanup()
|
||||
|
||||
self.ui = arcade.gui.UIManager()
|
||||
self.ui.enable()
|
||||
self.ui = arcade.gui.UIManager()
|
||||
self.ui.enable()
|
||||
|
||||
self.create_layouts()
|
||||
self.create_layouts()
|
||||
|
||||
self.back_button = arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text='<--', style=button_style, width=100, height=50)
|
||||
self.back_button.on_click = lambda e: self.main_exit()
|
||||
self.top_box.add(self.back_button)
|
||||
self.back_button = arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text='<--', style=button_style, width=100, height=50)
|
||||
self.back_button.on_click = lambda e: self.main_exit()
|
||||
self.top_box.add(self.back_button)
|
||||
|
||||
self.display_categories()
|
||||
self.display_categories()
|
||||
|
||||
self.display_category(self.current_category)
|
||||
|
||||
@@ -273,7 +273,7 @@ class Settings(arcade.gui.UIView):
|
||||
else:
|
||||
font_size = 12
|
||||
|
||||
self.credits_label = arcade.gui.UILabel(text=text, text_color=arcade.color.WHITE, font_name="Protest Strike", font_size=font_size, align="center", multiline=True)
|
||||
self.credits_label = arcade.gui.UILabel(text=text, text_color=arcade.color.WHITE, font_name="Roboto", font_size=font_size, align="center", multiline=True)
|
||||
|
||||
self.key_layout.add(self.credits_label)
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ menu_background_color = (30, 30, 47)
|
||||
log_dir = 'logs'
|
||||
discord_presence_id = 1360953272843632680
|
||||
|
||||
CELL_SIZE = 48
|
||||
ROWS = 14
|
||||
COLS = 14
|
||||
COMBO_TIME = 10
|
||||
CELL_SIZE = 80
|
||||
ROWS = 8
|
||||
COLS = 8
|
||||
OUTLINE_WIDTH = 2
|
||||
SHAPES = {
|
||||
"I": [(0, 0), (1, 0), (2, 0), (3, 0)],
|
||||
@@ -32,20 +33,30 @@ SHAPES = {
|
||||
"LINE3": [(0, 0), (1, 0), (2, 0)],
|
||||
}
|
||||
|
||||
COLORS = {
|
||||
"red": (255, 90, 90, 255),
|
||||
"blue": (100, 180, 255, 255),
|
||||
"green": (100, 255, 160, 255),
|
||||
"yellow": (255, 230, 100, 255),
|
||||
"purple": (200, 100, 255, 255),
|
||||
"orange": (255, 160, 90, 255),
|
||||
"teal": (100, 255, 255, 255),
|
||||
}
|
||||
COLORS = [
|
||||
(255, 90, 90, 255),
|
||||
(100, 180, 255, 255),
|
||||
(100, 255, 160, 255),
|
||||
(255, 230, 100, 255),
|
||||
(200, 100, 255, 255),
|
||||
(255, 160, 90, 255),
|
||||
(100, 255, 255, 255),
|
||||
(255, 120, 200, 255),
|
||||
(160, 255, 100, 255),
|
||||
(90, 150, 255, 255),
|
||||
(255, 100, 180, 255),
|
||||
(255, 200, 120, 255),
|
||||
(180, 255, 220, 255),
|
||||
(150, 100, 255, 255),
|
||||
(255, 255, 150, 255),
|
||||
(100, 255, 200, 255),
|
||||
(255, 140, 140, 255),
|
||||
]
|
||||
|
||||
button_style = {'normal': UITextureButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK), 'hover': UITextureButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK),
|
||||
'press': UITextureButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK), 'disabled': UITextureButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK)}
|
||||
dropdown_style = {'normal': UIFlatButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'hover': UIFlatButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK, bg=Color(49, 154, 54)),
|
||||
'press': UIFlatButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'disabled': UIFlatButtonStyle(font_name="Protest Strike", font_color=arcade.color.BLACK, bg=Color(128, 128, 128))}
|
||||
button_style = {'normal': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'hover': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK),
|
||||
'press': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK), 'disabled': UITextureButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK)}
|
||||
dropdown_style = {'normal': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'hover': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(49, 154, 54)),
|
||||
'press': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128)), 'disabled': UIFlatButtonStyle(font_name="Roboto", font_color=arcade.color.BLACK, bg=Color(128, 128, 128))}
|
||||
|
||||
slider_default_style = UISliderStyle(bg=Color(128, 128, 128), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
slider_hover_style = UISliderStyle(bg=Color(49, 154, 54), unfilled_track=Color(128, 128, 128), filled_track=Color(49, 154, 54))
|
||||
|
||||
@@ -5,3 +5,4 @@ button_hovered_texture = arcade.gui.NinePatchTexture(64 // 4, 64 // 4, 64 // 4,
|
||||
|
||||
theme_sound = arcade.Sound("assets/sound/music.ogg")
|
||||
click_sound = arcade.Sound("assets/sound/click.wav")
|
||||
break_sound = arcade.Sound("assets/sound/break.wav")
|
||||
|
||||
Reference in New Issue
Block a user