Need help with enemy spawn coords


(Pharap) #41

I’m saying try to understand some of it before you attempt other solutions.
If you want I can explain any specific parts you don’t understand or I can try to simplify it by removing some of the unnecessary stuff, all you have to do is ask.
Like I said, Enemy can be stripped down to just:

struct Enemy
{
uint8_t x;
uint8_t y;
};

And then you can add things as they’re needed.
For example, if you want enemies to have different sprites:

struct Enemy
{
uint8_t x;
uint8_t y;
const uint8_t * sprite;
};

@filmote is right, that should work.

I assume this means you did something similar to:

void loop()
{
Point coord;
coord.x = 0;
coord.x++;
}

In which case, coord.x is being set to 0 each time, but more importantly the coord gets destroyed by the end of the loop and next time around its recreated back at its default state. I believe you are trying to do something like this:

Point coord;

void loop()
{
coord.x++;
}

You can also set coord's x and y to a default value like so:

Point coord { 4, 7 };

void loop()
{
coord.x++;
}

(Cody) #42

What’s const uint8_t * sprite?


(Pharap) #43

As I said earlier:

So const uint8_t * is the same as const unsigned char *.

The field would be used to store a pointer to the sprite used for drawing the enemy, so different enemies could use different sprites.


(Cody) #44

Hello everyone just in case you all thought this was abandoned it is not. im still working on it but its just hard to make a game with my skills during school months and having lots of work so i hope to update after new year