summaryrefslogtreecommitdiffstats
path: root/apps/game_falldown/platform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/game_falldown/platform.cpp')
-rw-r--r--apps/game_falldown/platform.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/game_falldown/platform.cpp b/apps/game_falldown/platform.cpp
new file mode 100644
index 0000000..810f469
--- /dev/null
+++ b/apps/game_falldown/platform.cpp
@@ -0,0 +1,41 @@
+#include "platform.hpp"
+
+Platform::Platform() {
+ m_position_y = DISPLAY_HEIGHT-1;
+ m_speed = 1;
+
+ create_tiles();
+}
+
+Platform::Platform(int y, int speed) {
+ m_position_y = y;
+ m_speed = speed;
+
+ create_tiles();
+}
+
+void Platform::create_tiles() {
+ // example of platform creation
+ for (size_t i = 1; i < m_tiles_solid.size(); i += 2) {
+ m_tiles_solid.set(i);
+ }
+}
+
+void Platform::update() {
+ m_position_y -= m_speed * 1;
+}
+
+void Platform::draw(Api *app_api) {
+ // display_draw_line(int x1, int y1, int x2, int y2, int bRender);
+ // for each tile
+ // FIXME: Is broken
+ int position_x = 0;
+ for (size_t i = 0; i < m_tiles_solid.size(); ++i) {
+ if (m_tiles_solid[i]) {
+ int tile_start_x = PLATFORM_TILE_SIZE * i;
+ int tile_end_x = tile_start_x + PLATFORM_TILE_SIZE;
+
+ app_api->display_draw_line(tile_start_x, m_position_y, tile_end_x, m_position_y, 1);
+ }
+ }
+} \ No newline at end of file