[Game]Lost (Update V0.4)

UpdateV0.4 new title and changeable degree of diffculty. (I think that can help me step to step facing a mass of bullets)

Update V0.3:
optimize objects collision detection method (Thanks Pharap) (That means it diffcult better than before. try to live more time:smirk: )

Hi, This my first little game in Pokitto.
Itā€™s a avoiding bullets game using aircraft.
Im a fresh in C++.
So, I wish some advises eveyone here. especially about code.

I found some question:
1 How to set C++11 in mbed.com, I found its not support ā€œautoā€ and constructor using ā€œ= defaultā€
2 How to upload and download files in mbed.com
3 About how to objects crashed each other, I just used a stupid method: one by one pix compares, What method is more effective?

My game:
V0.4
LostV4.bin (52.1 KB)

old:
V0.3
LostV03.bin (52.0 KB)

GIF:

Thanks everyone here!!!

My code shared in there:
https://os.mbed.com/teams/Pokitto-Community-Team/code/Pokitto_Game_Lost

4 Likes

28 sec so far, nice little game :smile:

I would remove Pokitto in front of the name, if the loader is used it only displays Pokitto~1.bin. So the actual name is not displayed.

2 Likes

@79859899 (WTW) has earned his first Game Maker badge.

Now add some more gameplay to get the next level Game Publisher badge!

2 Likes

mbed doesnā€™t support C++11 sadly.

Glad to hear you are trying to use C++11 features though.

Rectangle and circle collisions are easier than pixel-by-pixel.

Spherical collision is the easiest, it takes about 5 minutes to implement:

uint16_t SquareDistance(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
{
  int16_t x = x2 - x1;
  int16_t y = y2 - y1;
  // The squaring cancels out the sign, so this can't be negative
  return static_cast<uint16_t>(x * x + y * y);
}

struct Circle
{
  int16_t x;
  int16_t y;
  uint16_t radius;
};

bool AreIntersecting(const Circle & a, const Circle & b)
{
  uint16_t radius = a.radius + b.radius;
  uint16_t squareDistance = SquareDistance(a.x, b.x, a.y, b.y)
  return squareDistance < (radius * radius);
}

Rectangle detection is more useful but a bit more complicated:

struct Rectangle
{
  int16_t x;
  int16_t y;
  uint16_t width;
  uint16_t height;

  int16_t getLeft(void) const { return x; }
  int16_t getTop(void) const { return y; }
  int16_t getRight(void) const { return x + width; }
  int16_t getBottom(void) const { return y + height; }
};

bool AreIntersecting(const Rectangle & a, const Rectangle & b)
{
    return
    !(
        (a.getTop() > b.getBottom()) || (a.getLeft() > b.getRight()) ||
        (a.getRight() < b.getLeft()) || (a.getBottom() < b.getTop())
    );
}
1 Like

Thanks a lot.:wink:
Ive optimized my game using your method.

1 Like

Thanks a lot. Ive changed game fileā€™s name and update v0.3.
Try again, itā€™s more diffcult now, haha.:joy:

lol, i got up to 13 sec max now. Might i suggest a teleport option ?
Like in astroids as a last resort to save the ship ? Currently the ship tends to get caught between bullets, and this would extend playtime a little.

OKļ¼Œ I ll try to think about this great suggestion.
But now I must take seriously to learn ā€œC++ primerā€
Its so complicated!!!:joy: Inner peace Inner peace

2 Likes

Itā€™s complicated because itā€™s powerful.

To me the Chinese is more complicated than the C++. :P

If you have any questions specifically about the C++ language, we have a C++ section.


If you want some more resources, one of my favourite tutorials is this one:
https://www.cprogramming.com/tutorial/c++-tutorial.html

And my favourite reference is this one:
http://en.cppreference.com/w/cpp

1 Like

Thanks Pharap
These can help me a lot!!!

2 Likes

@79859899 :

Hi! Made the title a bit shorter to fit the new Games page layout better.

Any progress?

As you wish.
I have a new idea about a new game, but too busy recently.
I will go on my project as long as having spare time.

2 Likes