After decimating the enemy forces that have attacked your ship, you are charged with taking out as many of the remaining enemy fighters as possible. 3d space fighter game was initially written while I was testing some 3d routines I was implementing for a flight simulator, but my daughter started playing it and seemed to enjoy it so I added a few sound effects, explosions etc. and so this little game was born.

Dependencies:   mbed

Committer:
taylorza
Date:
Sun Feb 08 01:38:18 2015 +0000
Revision:
4:b857db213f10
Parent:
0:01829868570e
Removed duty lookup table

Who changed what in which revision?

UserRevisionLine numberNew contents of line
taylorza 0:01829868570e 1 #include "mbed.h"
taylorza 0:01829868570e 2 #include "Bitmap1bpp.h"
taylorza 0:01829868570e 3
taylorza 0:01829868570e 4 Bitmap1bpp::Bitmap1bpp(uint16_t width, uint16_t height):
taylorza 0:01829868570e 5 _width(width),
taylorza 0:01829868570e 6 _height(height),
taylorza 0:01829868570e 7 _stride((width >> 3) + ((width & 0x07) ? 1 : 0)),
taylorza 0:01829868570e 8 _pBitmapData(new uint8_t[_stride * height])
taylorza 0:01829868570e 9 {
taylorza 0:01829868570e 10
taylorza 0:01829868570e 11 }
taylorza 0:01829868570e 12
taylorza 0:01829868570e 13 Bitmap1bpp::~Bitmap1bpp()
taylorza 0:01829868570e 14 {
taylorza 0:01829868570e 15 if (_pBitmapData != NULL)
taylorza 0:01829868570e 16 {
taylorza 0:01829868570e 17 delete []_pBitmapData;
taylorza 0:01829868570e 18 _pBitmapData = NULL;
taylorza 0:01829868570e 19 }
taylorza 0:01829868570e 20 }
taylorza 0:01829868570e 21
taylorza 0:01829868570e 22 void Bitmap1bpp::clear()
taylorza 0:01829868570e 23 {
taylorza 0:01829868570e 24 memset(_pBitmapData, 0, _stride * _height);
taylorza 0:01829868570e 25 }
taylorza 0:01829868570e 26
taylorza 0:01829868570e 27 void Bitmap1bpp::setPixel(int16_t x, int16_t y, uint16_t color)
taylorza 0:01829868570e 28 {
taylorza 0:01829868570e 29 if (x < 0 || x >= _width || y < 0 || y >= _height) return;
taylorza 0:01829868570e 30
taylorza 0:01829868570e 31 uint8_t mask = 1 << (7 - (x % 8));
taylorza 0:01829868570e 32 uint8_t *p = _pBitmapData + ((y * _stride) + (x / 8));
taylorza 0:01829868570e 33
taylorza 0:01829868570e 34 if (color) *p |= mask; else *p &= ~mask;
taylorza 0:01829868570e 35 }