44from PySide6 .QtWidgets import QApplication , QWidget , QVBoxLayout , QHBoxLayout , QLabel , QPushButton , QGridLayout , QMainWindow
55from PySide6 .QtGui import QFont , QPixmap , QIcon , QFontDatabase , QLinearGradient , QBrush , QColor , QPainter , QPalette , QMovie
66from PySide6 .QtCore import Qt , QPropertyAnimation , QSequentialAnimationGroup , QRect , QTimer , QAbstractAnimation , QEasingCurve , QUrl , QPoint , QElapsedTimer
7-
87# Use system icons directory
98IMAGES_DIR = '/usr/share/HackerOS/ICONS'
10-
119# Game paths and commands (hardcoded as in original)
1210GAME_PATHS = {
1311 'starblaster' : '/usr/share/HackerOS/Scripts/HackerOS-Games/starblaster' ,
14- 'bit-jump' : '/usr/share/HackerOS/Scripts/HackerOS-Games/bit-jump.love ' ,
12+ 'bit-jump' : '/usr/share/HackerOS/Scripts/Bin/Bit-Jump.hacker ' ,
1513 'the-racer' : '/usr/share/HackerOS/Scripts/HackerOS-Games/the-racer'
1614}
1715LAUNCH_COMMANDS = {
1816 'starblaster' : [GAME_PATHS ['starblaster' ]],
19- 'bit-jump' : ['love ' , GAME_PATHS ['bit-jump' ]],
17+ 'bit-jump' : ['hackerc' , 'run ' , GAME_PATHS ['bit-jump' ]],
2018 'the-racer' : [GAME_PATHS ['the-racer' ]]
2119}
22-
2320class ParticleWidget (QWidget ):
2421 def __init__ (self , parent = None ):
2522 super ().__init__ (parent )
@@ -35,8 +32,7 @@ def __init__(self, parent=None):
3532 self .elapsed .start ()
3633 self .timer = QTimer (self )
3734 self .timer .timeout .connect (self .update )
38- self .timer .start (16 ) # ~60 FPS
39-
35+ self .timer .start (16 ) # ~60 FPS
4036 def paintEvent (self , event ):
4137 painter = QPainter (self )
4238 painter .setRenderHint (QPainter .Antialiasing )
@@ -57,22 +53,19 @@ def paintEvent(self, event):
5753 painter .setBrush (QBrush (p ['color' ]))
5854 painter .setPen (Qt .NoPen )
5955 painter .drawEllipse (int (cx_abs - p ['r' ]), int (cy_abs - p ['r' ]), int (p ['r' ]* 2 ), int (p ['r' ]* 2 ))
60-
6156class GameCard (QWidget ):
6257 def __init__ (self , game_name , image_file , color_class , parent = None ):
6358 super ().__init__ (parent )
6459 self .game_name = game_name
6560 layout = QVBoxLayout (self )
66- layout .setContentsMargins (40 , 40 , 40 , 40 ) # p-10
67-
61+ layout .setContentsMargins (40 , 40 , 40 , 40 ) # p-10
6862 # Image
6963 self .image_label = QLabel ()
7064 image_path = os .path .join (IMAGES_DIR , image_file )
7165 pixmap = QPixmap (image_path )
72- self .image_label .setPixmap (pixmap .scaledToHeight (320 , Qt .SmoothTransformation )) # h-80 approximate
66+ self .image_label .setPixmap (pixmap .scaledToHeight (320 , Qt .SmoothTransformation )) # h-80 approximate
7367 self .image_label .setAlignment (Qt .AlignCenter )
7468 layout .addWidget (self .image_label )
75-
7669 # Animate pixel-bounce
7770 self .bounce_anim = QPropertyAnimation (self .image_label , b'pos' )
7871 self .bounce_anim .setDuration (1400 )
@@ -83,14 +76,12 @@ def __init__(self, game_name, image_file, color_class, parent=None):
8376 self .bounce_anim .setKeyValueAt (0.5 , start_pos + QPoint (0 , - 25 ))
8477 self .bounce_anim .setKeyValueAt (1 , start_pos )
8578 self .bounce_anim .start ()
86-
8779 # Title
8880 title = QLabel (game_name .replace ('-' , ' ' ).title ())
89- title .setFont (QFont ('Press Start 2P' , 24 )) # text-4xl
81+ title .setFont (QFont ('Press Start 2P' , 24 )) # text-4xl
9082 title .setAlignment (Qt .AlignCenter )
9183 title .setStyleSheet ("color: white;" )
9284 layout .addWidget (title )
93-
9485 # Button
9586 button = QPushButton ('Launch' )
9687 button .setFont (QFont ('Press Start 2P' , 12 ))
@@ -109,7 +100,6 @@ def __init__(self, game_name, image_file, color_class, parent=None):
109100 """ )
110101 button .clicked .connect (self .launch_game )
111102 layout .addWidget (button )
112-
113103 # Card style
114104 shadow_color = self .get_shadow_color (color_class )
115105 self .setStyleSheet (f"""
@@ -118,46 +108,39 @@ def __init__(self, game_name, image_file, color_class, parent=None):
118108 border: 4px solid #ffffff55;
119109 box-shadow: 0 0 30px rgba(255, 255, 255, 0.5), { shadow_color } ;
120110 """ )
121-
122111 def get_neon_color (self , color_class ):
123112 if color_class == 'green' : return '#39ff14'
124113 if color_class == 'blue' : return '#00b7eb'
125114 if color_class == 'red' : return '#ff073a'
126115 return '#39ff14'
127-
128116 def get_dark_color (self , color_class ):
129117 if color_class == 'green' : return '#2ecc40'
130118 if color_class == 'blue' : return '#0099c9'
131119 if color_class == 'red' : return '#d90429'
132120 return '#2ecc40'
133-
134121 def get_shadow_color (self , color_class ):
135122 if color_class == 'green' : return '0 0 40px rgba(57, 255, 20, 0.7), 0 0 80px rgba(57, 255, 20, 0.5)'
136123 if color_class == 'blue' : return '0 0 40px rgba(0, 183, 235, 0.7), 0 0 80px rgba(0, 183, 235, 0.5)'
137124 if color_class == 'red' : return '0 0 40px rgba(255, 7, 58, 0.7), 0 0 80px rgba(255, 7, 58, 0.5)'
138125 return '0 0 40px rgba(57, 255, 20, 0.7), 0 0 80px rgba(57, 255, 20, 0.5)'
139-
140126 def launch_game (self ):
141127 command = LAUNCH_COMMANDS .get (self .game_name )
142128 if command :
143129 try :
144130 subprocess .Popen (command )
145131 except Exception as e :
146132 print (f"Error launching { self .game_name } : { e } " )
147-
148133class MainWindow (QMainWindow ):
149134 def __init__ (self ):
150135 super ().__init__ ()
151136 self .setWindowTitle ("HackerOS Games" )
152137 self .setGeometry (100 , 100 , 1280 , 900 )
153138 self .setWindowIcon (QIcon (os .path .join (IMAGES_DIR , 'HackerOS-Games.png' )))
154-
155139 # Central widget
156140 central = QWidget ()
157141 self .setCentralWidget (central )
158142 main_layout = QVBoxLayout (central )
159- main_layout .setContentsMargins (40 , 40 , 40 , 40 ) # p-10
160-
143+ main_layout .setContentsMargins (40 , 40 , 40 , 40 ) # p-10
161144 # Background gradient
162145 palette = central .palette ()
163146 gradient = QLinearGradient (0 , 0 , self .width (), self .height ())
@@ -166,50 +149,40 @@ def __init__(self):
166149 palette .setBrush (QPalette .Window , QBrush (gradient ))
167150 central .setPalette (palette )
168151 central .setAutoFillBackground (True )
169-
170152 # Title
171153 title = QLabel ("HackerOS Games" )
172- title .setFont (QFont ('Press Start 2P' , 48 )) # text-6xl
154+ title .setFont (QFont ('Press Start 2P' , 48 )) # text-6xl
173155 title .setAlignment (Qt .AlignCenter )
174156 title .setStyleSheet ("color: #39ff14; text-shadow: 0 0 10px #39ff14, 0 0 25px #39ff14, 0 0 50px #39ff14;" )
175157 main_layout .addWidget (title )
176-
177158 # Grid for games
178159 grid = QGridLayout ()
179- grid .setSpacing (48 ) # gap-12
180-
160+ grid .setSpacing (48 ) # gap-12
181161 # Starblaster
182162 starblaster = GameCard ('starblaster' , 'starblaster.png' , 'green' )
183163 grid .addWidget (starblaster , 0 , 0 )
184-
185164 # Bit-Jump
186165 bitjump = GameCard ('bit-jump' , 'Bit-Jump.png' , 'blue' )
187166 grid .addWidget (bitjump , 0 , 1 )
188-
189167 # The-Racer
190168 racer = GameCard ('the-racer' , 'The-Racer.png' , 'red' )
191169 grid .addWidget (racer , 0 , 2 )
192-
193170 main_layout .addLayout (grid )
194-
195171 # Logo
196172 self .logo = QLabel (central )
197173 logo_pixmap = QPixmap (os .path .join (IMAGES_DIR , 'HackerOS-Games.png' )).scaled (80 , 80 , Qt .KeepAspectRatio )
198174 self .logo .setPixmap (logo_pixmap )
199175 self .logo .setFixedSize (80 , 80 )
200- self .logo .move (self .width () - 100 , 24 ) # top-6 right-6
176+ self .logo .move (self .width () - 100 , 24 ) # top-6 right-6
201177 self .logo .raise_ ()
202-
203178 # Particles
204179 self .particles = ParticleWidget (central )
205180 self .particles .setGeometry (0 , 0 , self .width (), self .height ())
206181 self .particles .lower ()
207-
208182 def resizeEvent (self , event ):
209183 self .particles .setGeometry (0 , 0 , self .width (), self .height ())
210184 self .logo .move (self .width () - 100 , 24 )
211185 super ().resizeEvent (event )
212-
213186if __name__ == '__main__' :
214187 app = QApplication (sys .argv )
215188 # Assume 'Press Start 2P' font is installed system-wide; no need to load from file
0 commit comments