Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - JZ

Pages: [1]
1
Graphics / Re: Enemy Sprites spawn but don't move and can't be killed
« on: September 29, 2024, 12:38:28 pm »
I figured out the problem. There is a bug in the github code and I believe in the book itself. In the Zombie.cpp file the m_Alive boolean is never initialized. All I had to do was set m_Alive = true; in the void Zombie::spawn() type like so:
void Zombie::spawn(float startX, float startY, int type, int seed)
{
        m_Alive = true;
        switch(type)
        {
        case 0:
                // Bloater
                m_Sprite = Sprite(TextureHolder::GetTexture("graphics/bloater.png"));
                m_Speed = BLOATER_SPEED;
                m_Health = BLOATER_HEALTH;
                break;

        case 1:
                // Chaser
                m_Sprite = Sprite(TextureHolder::GetTexture("graphics/chaser.png"));
                m_Speed = CHASER_SPEED;
                m_Health = CHASER_HEALTH;
                break;
               
        case 2:
                // Crawler
                m_Sprite = Sprite(TextureHolder::GetTexture("graphics/crawler.png"));
                m_Speed = CRAWLER_SPEED;
                m_Health = CRAWLER_HEALTH;
                break; 
        }

2
Graphics / Re: Enemy Sprites spawn but don't move and can't be killed
« on: September 21, 2024, 07:35:31 pm »
Hi Frank,

I have the exact same problem though I'm only in chapter 10 so I don't have as much of the code fleshed out as in your example. The code will compile correctly and the game will start but a seemingly random number of the enemy sprites will remain fixed to the arena walls and are unresponsive. To compare with my code I ran the sample code the publisher posted to github to check and see if I could identify any errors. When I ran the example the same problem appeared.

I'm not sure if the problem is in the code logic itself or if it's an artifact of something else. I'm using the g++ compiler in ubuntu using a makefile and writing my code in text files; I'm not using visual studio so I wonder if that could be the source of the problem.

If you have made any progress on this I'd be curious to hear about what you did.

Best,
JZ

Pages: [1]