MineCraft-One-Week-Challenge icon indicating copy to clipboard operation
MineCraft-One-Week-Challenge copied to clipboard

The program crashes upon pressing the W key after launch

Open NicholasHwang opened this issue 8 months ago • 1 comments

Program: ...eCraft-One-Week-Challenge\x64\Debug\mc-one-week-challenge.exe File: E:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\array Line: 535

Expression: array subscript out of range

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

any idea?

NicholasHwang avatar Mar 30 '25 11:03 NicholasHwang

May I ask if you have used Chinese input method Please switch to English input method for keyboard input If you don't want to do this It can be found in Keyboard.cpp

void Keyboard::update(sf::Event e)
{
    m_recentlyReleased = sf::Keyboard::KeyCount;
    //Add this if judgment condition
    //Determine whether e.key.code is within the valid range
    if (e.key.code >= 0 && e.key.code < sf::Keyboard::KeyCount)
    {
        switch (e.type)
        {
            case sf::Event::KeyReleased:
                m_keys[e.key.code] = false;
                break;

            case sf::Event::KeyPressed:
                m_recentlyReleased = e.key.code;
                m_keys[e.key.code] = true;
                break;

            default:
                break;
        }
    }
}

Perhaps it can solve your problem

COSMICAL-CONTAINER avatar Apr 14 '25 07:04 COSMICAL-CONTAINER