gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
can you code an 2d pygame about how hard is it to be a dog, make one demo quest
- User
can you code an 2d pygame about how hard is it to be a dog, make one demo quest
- Assistant
Certainly! Here's a simplified version of a 2D Pygame game about the challenges of being a dog, along with a demo quest. This code assumes you have Pygame installed.
import pygame # Window dimensions WIDTH, HEIGHT = 800, 600 # Colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) # Initialize Pygame pygame.init() window = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Hard Life of a Dog") # Player properties player_image = pygame.image.load("dog.png") player_rect = player_image.get_rect() player_rect.center = (WIDTH // 2, HEIGHT // 2) player_speed = 5 # Quest properties quest_image = pygame.image.load("bone.png") quest_rect = quest_image.get_rect() quest_rect.center = (WIDTH - 100, HEIGHT - 100) quest_complete = False clock = pygame.time.Clock() def game_loop(): running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Player movement keys = pygame.key.get_pressed() if keys[pygame.K_LEFT]: player_rect.x -= player_speed if keys[pygame.K_RIGHT]: player_rect.x += player_speed if keys[pygame.K_UP]: player_rect.y -= player_speed if keys[pygame.K_DOWN]: player_rect.y += player_speed # Check if player collected the quest item if player_rect.colliderect(quest_rect): quest_complete = True # Draw the game elements window.fill(WHITE) window.blit(player_image, player_rect) if not quest_complete: window.blit(quest_image, quest_rect) pygame.display.update() clock.tick(60) pygame.quit() if __name__ == "__main__": game_loop()