diff --git a/BitCoin Mining/BitCoin_Mining.py b/BitCoin Mining/BitCoin_Mining.py index 3ec620c11c..6dcfbb6555 100644 --- a/BitCoin Mining/BitCoin_Mining.py +++ b/BitCoin Mining/BitCoin_Mining.py @@ -54,7 +54,7 @@ def mine(block_number, transactions, previous_hash, prefix_zeros): start = time.time() print("start mining") - previous_hash = input('Enter Previous has value : ') + previous_hash = input('Enter Previous hash value : ') # Calling mine function with all required parameters new_hash = mine(5, transactions, previous_hash, difficulty) diff --git a/Traffic-Sign-Detection/requirements.txt b/Traffic-Sign-Detection/requirements.txt index caa651861f..29b4950779 100644 --- a/Traffic-Sign-Detection/requirements.txt +++ b/Traffic-Sign-Detection/requirements.txt @@ -104,9 +104,9 @@ six==1.15.0 SoundFile==0.10.3.post1 tensorboard==2.4.1 tensorboard-plugin-wit==1.7.0 -tensorflow==2.7.2 +tensorflow==2.11.1 tensorflow-estimator==2.4.0 -tensorflow-gpu==2.7.2 +tensorflow-gpu==2.12.0 termcolor==1.1.0 terminado==0.9.2 testpath==0.4.4 diff --git a/pong-pygame/Assets/ball.png b/pong-pygame/Assets/ball.png new file mode 100644 index 0000000000..3ccf46a54a Binary files /dev/null and b/pong-pygame/Assets/ball.png differ diff --git a/pong-pygame/Assets/paddle.png b/pong-pygame/Assets/paddle.png new file mode 100644 index 0000000000..fe8375fc83 Binary files /dev/null and b/pong-pygame/Assets/paddle.png differ diff --git a/pong-pygame/README.md b/pong-pygame/README.md new file mode 100644 index 0000000000..ba18a9d9ea --- /dev/null +++ b/pong-pygame/README.md @@ -0,0 +1,14 @@ +# Pygame_pong + +useage: + +install python from ['https://www.python.org/downloads/'] + +>> pip install pygame + +``` +python main.py +``` + + +![Screenshot from 2023年01月01日 14-17-38](https://user-images.githubusercontent.com/68957369/210165478-2617e876-234c-4d95-b9fd-8289f8973ba2.png) diff --git a/pong-pygame/pong.py b/pong-pygame/pong.py new file mode 100644 index 0000000000..46edf7a61e --- /dev/null +++ b/pong-pygame/pong.py @@ -0,0 +1,83 @@ +import pygame +# Initialize pygame + +pygame.init() # Initialize pygame + +# Set the window size +screen = pygame.display.set_mode((600, 400)) # Set the window size + +# Set the title of the window +pygame.display.set_caption("Pong") # Set the title of the window + +# Set up the game clock +clock = pygame.time.Clock() # Set up the game clock + +# Load the images for the ball and paddles +ball_image = pygame.image.load("Assets/ball.png") +paddle_image = pygame.image.load("Assets/paddle.png") + +# Create the ball sprite +ball = pygame.sprite.Sprite() # Create the ball sprite +ball.image = ball_image # Load the ball image +ball.rect = ball.image.get_rect() # Get the ball's rects + +# Create the paddles +left_paddle = pygame.sprite.Sprite() # Create the left paddle +left_paddle.image = paddle_image # Load the left paddle image +left_paddle.rect = left_paddle.image.get_rect() # Get the left paddle's rect + +right_paddle = pygame.sprite.Sprite() # Create the right paddle +right_paddle.image = paddle_image # Load the right paddle image +right_paddle.rect = right_paddle.image.get_rect() # Get the right paddle's rect + +# Set the initial positions of the ball and paddles +ball.rect.center = (300, 200) # Set the ball's initial position +left_paddle.rect.left = 20 # Set the left paddle's initial position +left_paddle.rect.centery = 200 # Set the left paddle's initial position +right_paddle.rect.right = 580 # Set the right paddle's initial position +right_paddle.rect.centery = 200 # Set the right paddle's initial position + +# Set the ball's initial velocity +ball_vx = 5 # +ball_vy = 5 # + +# Game loop +while True: # + # Handle events + for event in pygame.event.get(): # Handle events + if event.type == pygame.QUIT: # Handle the QUIT event + pygame.quit() # Quit pygame + exit() # Exit the program + + # Update game state + ball.rect.x += ball_vx # Update the ball's x position + ball.rect.y += ball_vy # Update the ball's y position + + # Update game state + keys = pygame.key.get_pressed() # Get the keys that are pressed + if keys[pygame.K_UP]: # Check if the up key is pressed + right_paddle.rect.y -= 5 # Update the right paddle's y position + if keys[pygame.K_DOWN]: # Check if the down key is pressed + right_paddle.rect.y += 5 # Update the right paddle's y position + if keys[pygame.K_w]: # Check if the w key is pressed + left_paddle.rect.y -= 5 # Update the left paddle's y position + if keys[pygame.K_s]: # Check if the s key is pressed + left_paddle.rect.y += 5 # Update the left paddle's y position + + # Check for ball collision with paddles + if ball.rect.colliderect(left_paddle.rect) or ball.rect.colliderect(right_paddle.rect): # Check for ball collision with paddles + ball_vx = -ball_vx # Reverse the ball's x velocity + + # Check for ball collision with walls + if ball.rect.top < 0 or ball.rect.bottom> 400: # Check for ball collision with walls + ball_vy = -ball_vy # Reverse the ball's y velocity + + # Draw the screen + screen.fill((0, 0, 0)) # Fill the screen with black + screen.blit(ball.image, ball.rect) # Draw the ball + screen.blit(left_paddle.image, left_paddle.rect) # Draw the left paddle + screen.blit(right_paddle.image, right_paddle.rect) # Draw the right paddle + pygame.display.flip() # Update the display + + # Limit the frame rate + clock.tick(60)

AltStyle によって変換されたページ (->オリジナル) /