# Why are the enemies not appearing on the screen?

**URL:** <https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403>\
**Category:** Game Development\
**Created:** [September 25, 2026, 4:35pm UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403 "2026-09-25T16:35:15Z")\
**Posts on this page:** 12\
**Page:** 5

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 16, 2026, 9:50am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/81 "2026-10-16T09:50:57Z")

</div>

What do I need to change to trigger the highscore entry screen?

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 16, 2026, 11:00am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/82 "2026-10-16T11:00:28Z")

</div>

Ok now I have access to the highscore entry screen, I did by not setting stage.score to 0 every time a new life was started. I will report back later.

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [October 16, 2026, 11:48am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/83 "2026-10-16T11:48:41Z")

</div>

> Ok I have it running now …

Are you compiling with `-fpermissive`? That is generally not a good idea because it allows a lot of incorrect code to compile.

Compilation errors and warnings are your friend. Don’t ignore them. If you use GCC I think you should at least use the [-Wall](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall) flag. [-Wextra](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-W) also enables many useful warnings. Fixing your code so that you get none of these warnings will prevent a lot of problems.

> … but I cant seem to trigger the highscore entry screen

Does the function `doNameInput` even get called? Why not? Is it because `newHighscore` is still null? Why does `addHighscore` leave `newHighscore` null? Is it because the score that gets passed to `addHighscore` is zero? Why is it zero? Do you do anything before calling this function that would reset it to zero?

_I’m being overly verbose here just to show the kind of questions that you should be asking yourself while debugging._

Right now `addHighscore` (and `initHighScores`) is being called every time you die. Is this what you want or should it only get called once when you run out of lives?

* * *

I also noticed that the game seems to continue to run in the background after you run out of lives because the lives continue to drop below zero if you wait at the highscore screen.

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 17, 2026, 10:05am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/84 "2026-10-17T10:05:35Z")

</div>

> [@Peter87](#):
>
> > 
> 
> Are you compiling with `-fpermissive`? That is generally not a good idea because it allows a lot

ok will fix that soon. In the meantime can you show me why the highscore entry program keeps repeating the text when its entered? Thanks.

> **[GitHub - Al88b/sidescrollingspaceshooter: game](https://github.com/Al88b/sidescrollingspaceshooter)**
>
> game

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [October 17, 2026, 10:36am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/85 "2026-10-17T10:36:51Z")

</div>

It’s probably because you never reset `dot.inputText` so `doNameInput` keeps adding the same text over and over.

Another problem is that if you receive two `SDL_TEXTINPUT` events in quick succession then `doNameInput` might only see the last one. To avoid this you probably want to concatenate the text input to `dot.inputText` rather than replacing it.

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 17, 2026, 12:03pm UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/86 "2026-10-17T12:03:34Z")

</div>

Please can I ask where I should reset dot.inputText?

Thank you

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 17, 2026, 12:25pm UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/87 "2026-10-17T12:25:57Z")

</div>

Also what line of code do I need to reset it?

Thanks

---

<div class="post-metadata">

**Author:** ![Peter87](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/f07891/32.png) [@Peter87](https://discourse.libsdl.org/u/Peter87)\
**Post date:** [October 17, 2026, 12:56pm UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/88 "2026-10-17T12:56:48Z")

</div>

Do it after you’re finished using it.

Alternatively, you could call `doNameInput` directly from the event loop when receiving the `SDL_TEXTINPUT` event. Then you could get rid of `dot.inputText` and pass `e.text.text` as an argument to the function instead. EDIT: In that case you might want to split up the function and handle the backspace and return keys in separate functions (e.g. that gets called in response to a `SDL_KEYDOWN` event).

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 18, 2026, 8:29am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/89 "2026-10-18T08:29:42Z")

</div>

I got it running and now I am trying to put theenterhighscore screen in a separate game state but its not responding to text input. Why is that? What am I missing?

> **[GitHub - Al88b/sidescrollingspaceshooter: game](https://github.com/Al88b/sidescrollingspaceshooter)**
>
> game

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 18, 2026, 9:41am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/90 "2026-10-18T09:41:55Z")

</div>

As far as I can tell I’m running doNameInput and drawNameInput when newHighscore != NULL

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 18, 2026, 9:58am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/91 "2026-10-18T09:58:18Z")

</div>

Ok that’s fixed. It was a typo in the logic. Now I’m getting a crash when switching my game state to HIGHSCORESCREEN when return is pressed. Can anyone tell me how to fix it.

Thank you kindly.

---

<div class="post-metadata">

**Author:** ![Al881](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@Al881](https://discourse.libsdl.org/u/Al881)\
**Post date:** [October 18, 2026, 10:27am UTC](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403/92 "2026-10-18T10:27:45Z")

</div>

Ok got that fixed, it was something to do with newHighScore being set to NULL so I changed the logic and it works.

[Previous page](https://discourse.libsdl.org/t/why-are-the-enemies-not-appearing-on-the-screen/69403.md?page=4)
