From a94dfbedcf3fe5a78f0364ad116f711a3f598a4f Mon Sep 17 00:00:00 2001
From: frank
Date: Tue, 1 Nov 2022 20:26:12 -0400
Subject: [PATCH] adjust platform and boss health hud for smaller resolution,
add donation button to web site
---
NS.py | 32 +++++++++++++++++++++++---------
config | 2 +-
resource/HUD_boss.png | Bin 978 -> 1917 bytes
resource/scores | 3 +++
www/index.php | 11 +++++++++++
5 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/NS.py b/NS.py
index 924d1aa..e3bc23b 100644
--- a/NS.py
+++ b/NS.py
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
-#
# [SCRAPEBOARD] is an arcade game in development by [@diskmem] & [@snakesandrews]
#
# It requires custom hardware to play but can be tested in keyboard mode without
-# the hardware. For more information on setting up and running the game, see the
-# README, or for the game in general, visit https://scrape.nugget.fun/
-#
+# the hardware. For more information on setting up and running the game, see
+# README.md, or for the game in general, visit .
import argparse, pathlib, operator, subprocess, sys
from random import randint, choice, random
@@ -151,11 +149,14 @@ class NS(Game, Animation):
parser.add_argument("--no-serial", action="store_true")
parser.add_argument("--show-config", action="store_true")
arguments = parser.parse_known_args()[0]
+
# Pre-initialize the mixer to use the specified buffer size in bytes. The default is set to 1024 to prevent lagging
# on the Raspberry Pi.
pygame.mixer.pre_init(44100, -16, 2, 1024)
+
# Pygame will be loaded in here.
Game.__init__(self)
+
# Add type declarations for non-string config name/value pairs that aren't in the default PGFW config dict.
self.get_configuration().type_declarations.add_chart(
{
@@ -196,24 +197,30 @@ class NS(Game, Animation):
},
"pads":
{
- "int-list": "center"
+ "int": "center_y"
}
})
+
# If a serial port was passed on the command line, override the config file setting
if arguments.serial_port is not None:
self.get_configuration().set("input", "arduino-port", arguments.serial_port)
+
# Command line flag requesting minimal load time overrides config file setting
if arguments.minimize_load_time:
self.get_configuration().set("system", "minimize-load-time", True)
+
# Turn off effects if minimal load time is requested. Minimal load time setting overrides display effects setting.
if self.get_configuration("system", "minimize-load-time"):
self.get_configuration().set("display", "effects", False)
+
# Apply the no serial flag from the command line if requested
if arguments.no_serial:
self.get_configuration().set("input", "serial", False)
+
# Print the configuration if requested on the command line
if arguments.show_config:
print(self.get_configuration())
+
# Initialize the serial reader and launch a thread for reading from the serial port
if self.serial_enabled():
from serial import Serial, SerialException
@@ -238,14 +245,18 @@ class NS(Game, Animation):
self.reset_arduino()
self.serial_thread = Thread(target=self.read_serial)
self.serial_thread.start()
+
Animation.__init__(self, self)
+
# All events will pass through self.respond
self.subscribe(self.respond, KEYDOWN)
self.subscribe(self.respond, KEYUP)
self.subscribe(self.respond)
ds = self.get_display_surface()
+
# Child objects for managing more specific parts of the game
- self.platform = Platform(self, self.get_configuration("pads", "center"))
+ platform_cx = self.get_display_surface().get_width() // 2
+ self.platform = Platform(self, (platform_cx, self.get_configuration("pads", "center_y")))
self.tony = Tony(self)
self.logo = Logo(self)
self.title = Title(self)
@@ -255,6 +266,7 @@ class NS(Game, Animation):
self.boss = Boss(self)
self.level_select = LevelSelect(self)
self.ending = Ending(self)
+
self.last_press = get_ticks()
self.register(self.blink_score, interval=500)
self.register(self.close_pop_up)
@@ -1945,7 +1957,7 @@ class Timer(Meter):
dsr = self.get_display_surface().get_rect()
background = load(self.get_resource("HUD_timer.png")).convert()
rect = background.get_rect()
- rect.bottomright = dsr.right - 6, dsr.bottom - 4
+ rect.bottomright = dsr.right - 4, dsr.bottom - 4
self.setup(background, rect, 53, (0, 0, 255),
self.get_configuration("time", "timer-start-level-1"), "scrapeIcons/scrapeIcons_07.png")
@@ -2942,6 +2954,9 @@ class Sword(Animation):
class Health(Meter):
+ """
+ Track the boss's health and display the meter
+ """
OFFSET = 4
@@ -2960,8 +2975,7 @@ class Health(Meter):
icon_index = 17
elif level_index == 2:
icon_index = 19
- Meter.setup(self, self.background, self.rect, 52, (255, 0, 255), 100,
- "scrapeIcons/scrapeIcons_%i.png" % icon_index)
+ Meter.setup(self, self.background, self.rect, 52, (255, 0, 255), 100, "scrapeIcons/scrapeIcons_%i.png" % icon_index)
def reset(self):
self.setup()
diff --git a/config b/config
index a7e5c7a..91449e0 100644
--- a/config
+++ b/config
@@ -92,4 +92,4 @@ nw_color = #00FF88
ne_color = #FF88FF
se_color = #2222FF
sw_color = #FF2222
-center = 427, 376
+center_y = 376
diff --git a/resource/HUD_boss.png b/resource/HUD_boss.png
index dba91a4d34e063214bc690b8eb1231544e42c28e..74145a2b522c14f7de3dbe9059400b877bcc7da8 100644
GIT binary patch
literal 1917
zcmZWp2~?6x8zw!K;npsp85y_REtRfW5@w=T6Zho0hq>d53z|w%X=<99DW<5U*l&`!
zk$Z_+=B?by6cGi{tnj*ARM6bD`*HvCpYxw{&zX7WnP+C+cb=Jd=H6u+Ges~I3<7}^
z%`qle5J(mRV0F12fMxc)_y!Qv>-Nr(SkGu!7%>zd5bO(!B!&6Hd}9LeAW#giGAAG%
z{)@t;9}y`RWk#Q$S1Q-l%l*1+_6>WbtmI=J+9ks#t(qn(t=ro4d*&XKY@L;F#whW*
z;95^?*O0ugosIZFqSb%-E&7l_wB4Gd-P;sG6MnyV27bpS#GSVEO$|=l-xWc3BG!Zw
zN%?;w^im{sJv5;sGxUfpnY>h3JsyE#)dv`ny9A7+R4!OmU*;IqwJnUS5cKNO+vE`m
z<|%0+Q~zC&g%w5b7wf>f0JnvrxKk$)Q9V8JLP{diNu82tl2v+w5XI2>DZzJsZ`?y#
z^poz8mL5egq%fht3Yk_Eet*$dCKQV$}N%{8}c?Tlo
z%Lh~TYdKnoiGkHGUo?@zm*=Oo;JTU?F(w244B~--G7h%oQf2*F2m$%hh-DgI6hW;L
zT%Q^(=8o>@_nUlfclQD0TAePbYapQ3iuUVFaOy#9z*LPx4%7Ks{e63W%{9I@Kl-mG
zeiqO4>`l+5tPvWcuK*fblA7nmj)(p+`{3AQ-9G&ubXqogM0p!r_Xz$xCR_PsWUjEQ
z6zo0Huk_eF2_iRbyue@dSvH#8*_hCDo2q*II8~|XM?4NSc{O9bQ?$LFw6>1CmfJUE
zbEvQgZ?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