Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
2.0 kB
2
Indexable
Never
int main() {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(CELL_SIZE * MAP_WIDTH * SCREEN_RESIZE, (FONT_HEIGHT + CELL_SIZE * MAP_HEIGHT) * SCREEN_RESIZE), "Pac-Man");

    // Create the menu
    Menu menu(window.getSize().x, window.getSize().y);

    bool inMenu = true;
    while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            }

            if (inMenu) {
                if (event.type == sf::Event::KeyPressed) {
                    if (event.key.code == sf::Keyboard::Up) {
                        menu.MoveUp();
                    } else if (event.key.code == sf::Keyboard::Down) {
                        menu.MoveDown();
                    } else if (event.key.code == sf::Keyboard::Return) {
                        int selectedItem = menu.GetPressedItem();
                        if (selectedItem == 0) {
                            inMenu = false; // Start the game
                        } else if (selectedItem == 1) {
                            // Show tutorial (you can implement this as a separate screen)
                            // For simplicity, just printing it here
                            std::cout << "Tutorial: Use arrow keys to move Pac-Man. Use the mouse to modify the maze." << std::endl;
                        } else if (selectedItem == 2) {
                            window.close(); // Quit the game
                        }
                    }
                }
            } else {
                // Handle game events and logic
                if (event.type == sf::Event::Closed) {
                    window.close();
                }
                // Add your game loop code here
            }
        }

        window.clear();

        if (inMenu) {
            menu.draw(window);
        } else {
            // Add your game rendering code here
        }

        window.display();
    }

    return 0;
}
Leave a Comment