Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MotionSensor
Diff: Title/Title.cpp
- Revision:
- 32:fe6359ef9916
- Child:
- 33:4f3948dcd2f7
diff -r ab24d028ddfd -r fe6359ef9916 Title/Title.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Title/Title.cpp Mon May 06 08:56:48 2019 +0000
@@ -0,0 +1,116 @@
+#include "Title.h"
+
+Title::Title()
+{
+ title_count = 0;
+ cursor_timer = 20;
+ title_option = 0;
+}
+
+int Title::get_seed()
+{
+ return title_count;
+}
+
+void Title::main(N5110 &lcd, Gamepad &gamepad, float &global_contrast)
+{
+ Player player(5, 36);
+ while(1){ // Title Screen Loop
+ title_option = 0;
+ while(!gamepad.check_event(Gamepad::A_PRESSED)){
+ lcd.clear();
+ draw_title_screen(lcd);
+ lcd.refresh();
+
+ title_options_joystick(gamepad);
+
+ title_count++;
+ wait_ms(1000/40); // 1s/framerate
+ }
+ while(gamepad.check_event(Gamepad::A_PRESSED)){}
+ if(title_option == 0) {
+ break;
+ } else if (title_option == 1) {
+ title_option_option(lcd, gamepad, player, global_contrast);
+ } else if (title_option == 2) {
+ title_option_credit(lcd, gamepad);
+ } else if (title_option == 3) {
+ title_option_hi_scores(lcd);
+ }
+ }
+}
+
+void Title::draw_title_screen(N5110 &lcd)
+{
+ lcd.drawSprite(11, 4, 15, 44, (int *)title_name_0);
+ lcd.drawSpriteTransparent(19, 14, 17, 53, (int *)title_name_1);
+ lcd.drawCircle(79, 7, 10, FILL_BLACK);
+ lcd.drawCircle(81, 5, 8, FILL_WHITE);
+ lcd.drawSprite(56, 6, 11, 5, (int *)star_sprite[abs(((title_count/20) % 7) - 3)]);
+ lcd.drawSprite(12, 34, 8, 8, (int *)button_A_sprite);
+ lcd.drawSprite(22, 37, 3, 2, (int *)arrow_left_sprite);
+ lcd.drawSprite(59, 37, 3, 2, (int *)arrow_right_sprite);
+ lcd.drawSprite(69, 31, 12, 6, (int *)sprite_player[(title_count/40) % 4][(title_count/10) % 4]);
+ lcd.drawSprite(26, 35, 9, 32, (int *)title_options_sprite[title_option]);
+}
+
+void Title::title_options_joystick(Gamepad &gamepad)
+{
+ if ((gamepad.get_direction() == 3) && (cursor_timer > 20)) { // Detect Joystick going right
+ cursor_timer = 0;
+ if (title_option >= 3) {
+ title_option = 0;
+ } else {
+ title_option++;
+ }
+ } else if ((gamepad.get_direction() == 7) && (cursor_timer > 20)) { // Detect Joystick going left
+ cursor_timer = 0;
+ if (title_option <= 0) {
+ title_option = 3;
+ } else {
+ title_option--;
+ }
+ }
+ cursor_timer++;
+}
+
+void Title::title_option_option(N5110 &lcd, Gamepad &gamepad, Player &player, float &global_contrast)
+{
+ while(!gamepad.check_event(Gamepad::A_PRESSED)) {
+ global_contrast = gamepad.read_pot();
+ lcd.setContrast(global_contrast);
+ lcd.clear();
+ lcd.printString("Set contrast", 0, 0);
+ lcd.printString("using the", 0, 1);
+ lcd.printString("potentiometer", 0, 2);
+ player.draw(lcd);
+ lcd.refresh();
+ player.move(1, 0, (int *)level_map[0][0], (bool *)sprite_transparent_player);
+ player.buttons(false, true, false, false);
+ player.update_bullets((int *)level_map[0][0], (bool *)sprite_transparent_player);
+ wait_ms(1000/40);
+ }
+ wait(0.05);
+ while(gamepad.check_event(Gamepad::A_PRESSED)) {
+ }
+}
+
+void Title::title_option_credit(N5110 &lcd, Gamepad &gamepad)
+{
+ lcd.clear();
+ lcd.printString("Made by:", 0, 0);
+ lcd.printString("Steven Mahasin", 0, 1);
+ lcd.printString("201192939", 0, 2);
+ lcd.refresh();
+ wait(0.05);
+ while(!gamepad.check_event(Gamepad::A_PRESSED)) {
+ }
+ wait(0.05);
+ while(gamepad.check_event(Gamepad::A_PRESSED)) {
+ }
+}
+
+void Title::title_option_hi_scores(N5110 &lcd)
+{
+
+}