Skip to content

Commit

Permalink
Change trigger of Step 0 workflow (#137)
Browse files Browse the repository at this point in the history
`create` -> `push` to `main`
  • Loading branch information
sinsukehlab authored Apr 30, 2024
1 parent eb258a9 commit b4773f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/0-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ name: Step 0, Welcome
# This will run every time we create push a commit to `main`.
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows

This comment has been minimized.

Copy link
@shivamjoshi633

shivamjoshi633 Dec 8, 2024

import pygame
import sys
import random

Initialize Pygame

pygame.init()

Set up the game window

width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Move the Player Game with Obstacles")

Set up colors

WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)

Player settings

player_width, player_height = 50, 50
player_x, player_y = width // 2, height // 2
player_speed = 5

Obstacle settings

obstacle_width, obstacle_height = 60, 60
obstacle_x = random.randint(0, width - obstacle_width)
obstacle_y = random.randint(0, height - obstacle_height)

Game loop flag

running = True

Game loop

while running:
# Handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False # Exit the game

# Get key states (for movement)
keys = pygame.key.get_pressed()

if keys[pygame.K_LEFT]:  # Left arrow key
    player_x -= player_speed
if keys[pygame.K_RIGHT]:  # Right arrow key
    player_x += player_speed
if keys[pygame.K_UP]:  # Up arrow key
    player_y -= player_speed
if keys[pygame.K_DOWN]:  # Down arrow key
    player_y += player_speed

# Collision detection (if player hits the obstacle)
if (player_x < obstacle_x + obstacle_width and
    player_x + player_width > obstacle_x and
    player_y < obstacle_y + obstacle_height and
    player_y + player_height > obstacle_y):
    print("Game Over! You hit the obstacle!")
    running = False  # End the game

# Fill the screen with white
screen.fill(WHITE)

# Draw the player (a red rectangle)
pygame.draw.rect(screen, RED, (player_x, player_y, player_width, player_height))

# Draw the obstacle (a green rectangle)
pygame.draw.rect(screen, GREEN, (obstacle_x, obstacle_y, obstacle_width, obstacle_height))

# Update the display
pygame.display.flip()

# Set the frame rate (FPS)
pygame.time.Clock().tick(60)

Quit the game

pygame.quit()
sys.exit()

on:
create:
workflow_dispatch:
push:
branches:
- main

# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication

This comment has been minimized.

Copy link
@JUNED332

JUNED332 Dec 13, 2024

asasassas

permissions:
Expand Down

3 comments on commit b4773f8

@ahmedmankola
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@TYHRGEGEGEGEGEG
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@to867
Copy link

@to867 to867 commented on b4773f8 Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello

Please sign in to comment.