Skip to content

Commit c4624d0

Browse files
committed
Changes done in this file are -Threshold = 0.7
# Moving Average of last 10 values of powerData. # Ball Speed = 30 # Adding the font title "Force Ball Game" # Sleep of 1 sec so that game reset properly
1 parent 457e55e commit c4624d0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

applications/game.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
player1_pos = [50, HEIGHT // 2 - player_height // 2]
4848
player2_pos = [WIDTH - 50 - player_width, HEIGHT // 2 - player_height // 2]
4949

50+
# Font settings
51+
font_size = 50
52+
font = pygame.font.Font(None, font_size)
53+
title_text = "Force Ball Game"
54+
55+
title_surface = font.render(title_text, True, WHITE)
56+
title_rect = title_surface.get_rect(center=(800 // 2, font_size)) # Center at the top middle
57+
5058
clock = pygame.time.Clock()
5159

5260
eeg_queue = queue.Queue() # Initialize EEG queue
@@ -85,6 +93,7 @@ def eeg_data_thread(eeg_queue):
8593
return
8694

8795
inlet = StreamInlet(streams[0])
96+
channel_assignments = {0:'Player A', 1:'Player B'}
8897
sampling_frequency = 500
8998
bands = {'Alpha': [8, 13],'Beta': [13, 30]}
9099
buffer_length = sampling_frequency * 1
@@ -188,8 +197,8 @@ def update_ball_position(force_player1, force_player2, threshold=0.7):
188197
print(f"Force Player 1: {average_force1:.2f}, Force Player 2: {average_force2:.2f}, Net Force: {net_force:.2f}")
189198

190199
def draw_buttons(paused, first_attempt): # Button dimensions and positions
191-
button_width = 120
192-
button_height = 40
200+
button_width = 140
201+
button_height = 50
193202
button_radius = 15 # Radius for rounded corners
194203

195204
# Button positions (y-position is moved up slightly for a better fit)
@@ -249,6 +258,7 @@ def main():
249258

250259
while True:
251260
screen.fill(BLACK)
261+
screen.blit(title_surface, title_rect) # For Title of the game
252262

253263
pygame.draw.circle(screen, ball_color, (int(ball_pos[0]), int(ball_pos[1])), ball_radius) # Draw the ball
254264

@@ -313,4 +323,6 @@ def main():
313323

314324
# Threshold = 0.7
315325
# Moving Average of last 10 values of powerData.
316-
# Ball Speed = 30
326+
# Ball Speed = 30
327+
# Adding the font title "Force Ball Game"
328+
# Sleep of 1 sec so that game reset properly

0 commit comments

Comments
 (0)