Ray casting engine implemented on the mBuino platform using the ST7735 LCD controller.
Ray casting engine written to test performance of the LCD_ST7735 library I wrote as a learning exercise on the mbed platform.
Raycaster.h@3:e32f5c25a352, 2014-10-25 (annotated)
- Committer:
- taylorza
- Date:
- Sat Oct 25 04:23:24 2014 +0000
- Revision:
- 3:e32f5c25a352
- Parent:
- 1:fdbc2be25831
Updated the engine to use the latest LCD_ST7735 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
taylorza | 0:303768292f44 | 1 | #ifndef __RATYCASTER_H__ |
taylorza | 0:303768292f44 | 2 | #define __RATYCASTER_H__ |
taylorza | 0:303768292f44 | 3 | class Raycaster |
taylorza | 0:303768292f44 | 4 | { |
taylorza | 0:303768292f44 | 5 | public: |
taylorza | 0:303768292f44 | 6 | Raycaster(int left, int top, int width, int height, |
taylorza | 0:303768292f44 | 7 | int viewerDistance, int viewerHeight, |
taylorza | 0:303768292f44 | 8 | const uint8_t *pMap, int mapWidth, int mapHeight, |
taylorza | 0:303768292f44 | 9 | const uint16_t *pPalette); |
taylorza | 0:303768292f44 | 10 | |
taylorza | 0:303768292f44 | 11 | void renderFrame(); |
taylorza | 0:303768292f44 | 12 | |
taylorza | 0:303768292f44 | 13 | void setCellPosition(int x, int y); |
taylorza | 0:303768292f44 | 14 | void rotate(float radians); |
taylorza | 0:303768292f44 | 15 | void move(int distance); |
taylorza | 0:303768292f44 | 16 | |
taylorza | 1:fdbc2be25831 | 17 | ~Raycaster(); |
taylorza | 0:303768292f44 | 18 | private: |
taylorza | 0:303768292f44 | 19 | struct Sliver |
taylorza | 0:303768292f44 | 20 | { |
taylorza | 0:303768292f44 | 21 | uint8_t top; |
taylorza | 0:303768292f44 | 22 | uint8_t bottom; |
taylorza | 0:303768292f44 | 23 | uint16_t color; |
taylorza | 0:303768292f44 | 24 | }; |
taylorza | 0:303768292f44 | 25 | private: |
taylorza | 0:303768292f44 | 26 | LCD_ST7735 _display; |
taylorza | 0:303768292f44 | 27 | |
taylorza | 0:303768292f44 | 28 | const uint8_t *_pMap; |
taylorza | 0:303768292f44 | 29 | int _mapWidth; |
taylorza | 0:303768292f44 | 30 | int _mapHeight; |
taylorza | 0:303768292f44 | 31 | const uint16_t *_pPalette; |
taylorza | 0:303768292f44 | 32 | int _viewDistanceTimesHeight; |
taylorza | 0:303768292f44 | 33 | Sliver *_pSlivers; |
taylorza | 0:303768292f44 | 34 | |
taylorza | 0:303768292f44 | 35 | int _left; |
taylorza | 0:303768292f44 | 36 | int _right; |
taylorza | 0:303768292f44 | 37 | int _width; |
taylorza | 0:303768292f44 | 38 | int _halfWidth; |
taylorza | 0:303768292f44 | 39 | int _horizCenter; |
taylorza | 0:303768292f44 | 40 | |
taylorza | 0:303768292f44 | 41 | int _top; |
taylorza | 0:303768292f44 | 42 | int _bottom; |
taylorza | 0:303768292f44 | 43 | int _height; |
taylorza | 0:303768292f44 | 44 | int _halfHeight; |
taylorza | 0:303768292f44 | 45 | int _vertCenter; |
taylorza | 0:303768292f44 | 46 | |
taylorza | 0:303768292f44 | 47 | int _viewerDistance; |
taylorza | 0:303768292f44 | 48 | int _viewerHeight; |
taylorza | 0:303768292f44 | 49 | float _viewerDistanceHeightRatio; |
taylorza | 0:303768292f44 | 50 | float _viewVolume; |
taylorza | 0:303768292f44 | 51 | float _halfViewVolume; |
taylorza | 0:303768292f44 | 52 | |
taylorza | 0:303768292f44 | 53 | float _ainc; |
taylorza | 0:303768292f44 | 54 | int _heightRatio; |
taylorza | 0:303768292f44 | 55 | |
taylorza | 0:303768292f44 | 56 | float _playerX; |
taylorza | 0:303768292f44 | 57 | float _playerY; |
taylorza | 0:303768292f44 | 58 | float _playerViewAngle; |
taylorza | 0:303768292f44 | 59 | }; |
taylorza | 0:303768292f44 | 60 | #endif //__RATYCASTER_H__ |