diff --git a/appinfo.json b/appinfo.json index fb2b5a4..ba0e94b 100644 --- a/appinfo.json +++ b/appinfo.json @@ -84,7 +84,7 @@ "basalt" ], "uuid": "773e4473-32ba-405b-82cb-4d00c89d3f9a", - "versionLabel": "1.2", + "versionLabel": "2.0", "watchapp": { "watchface": false } diff --git a/src/Game.c b/src/Game.c index db0d652..743fe96 100644 --- a/src/Game.c +++ b/src/Game.c @@ -22,4 +22,18 @@ void initialiseGameState(GameState* state) state->highScore=0; } +} + +void printGameState(GameState* state) +{ + APP_LOG(APP_LOG_LEVEL_INFO, "======\nCurrent game state:\n======"); + APP_LOG(APP_LOG_LEVEL_INFO, "Game in play: %u", (unsigned int)state->gameInPlay); + APP_LOG(APP_LOG_LEVEL_INFO, "Game time: %d", state->game_time); + APP_LOG(APP_LOG_LEVEL_INFO, "Score: %u", (unsigned int)state->score); + APP_LOG(APP_LOG_LEVEL_INFO, "Speed: %d", (int)state->speed); + APP_LOG(APP_LOG_LEVEL_INFO, "Crash: %d", (int)state->crash); + APP_LOG(APP_LOG_LEVEL_INFO, "Time of Last Update: %d", state->timeOfLastUpdate); + APP_LOG(APP_LOG_LEVEL_INFO, "Time of Last Speed Increase: %d", state->timeOfLastSpeedIncrease); + APP_LOG(APP_LOG_LEVEL_INFO, "Delay: %d", (int)state->delay); + APP_LOG(APP_LOG_LEVEL_INFO, "Update Speed Frequency: %d", state->updateSpeedFrequency); } \ No newline at end of file diff --git a/src/Game.h b/src/Game.h index 9a9efeb..d670a6f 100644 --- a/src/Game.h +++ b/src/Game.h @@ -4,7 +4,7 @@ typedef struct { - int8_t gameInPlay; + bool gameInPlay; int game_time; uint16_t score; uint16_t highScore; @@ -17,4 +17,5 @@ typedef struct }GameState; -void initialiseGameState(GameState* state); \ No newline at end of file +void initialiseGameState(GameState* state); +void printGameState(GameState* state); \ No newline at end of file diff --git a/src/js/scorePusher.js b/src/js/scorePusher.js index e7c2d0f..eb06cfc 100644 --- a/src/js/scorePusher.js +++ b/src/js/scorePusher.js @@ -70,7 +70,8 @@ function sendScore(score) } // Construct URL - var url = "http://86.12.100.145:5000/json"; + //var url = "http://54.194.206.38:80/json"; + var url = "http://54.194.206.38:80/json"; // Push request to url xhrRequest(url, 'POST', scoreToPush, @@ -83,7 +84,8 @@ function sendScore(score) } function getUserName() { - var url = "http://86.12.100.145:5000/json"; + //var url = "http://54.194.206.38:80/json"; + var url = "http://54.194.206.38:80/json"; // Push request to url xhrRequestForUsername(url, 'POST', function(responseText) diff --git a/src/main.c b/src/main.c index 25a2a3d..77542e9 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ static MrGameAndWatch* mgw; static TextLayer *scoreLayer; static TextLayer *highScoreLayer; static TextLayer *nameLayer; +static TextLayer *restartTextLayer; static char scoreString[10]; static char highScoreString[10]; @@ -154,6 +155,8 @@ void triggerEndGame(Ball* object) renderCrash(game->crash); sendScore(game->score); text_layer_set_text(nameLayer, friendlyNameString); + text_layer_set_text(restartTextLayer, "Press Up to Restart ->"); + } void updateWorld() @@ -226,9 +229,19 @@ static void reset_game_handler(ClickRecognizerRef recognizer, void *context) { if (!game->gameInPlay) { - handle_deinit(); - handle_init(); - updateWorld(); + text_layer_set_text(restartTextLayer,""); + text_layer_set_text(nameLayer,""); + + initialiseGameState(game); + initialise_MisterGameAndWatch(mgw); + initialise_Ball(ball0, (int8_t)0, (int8_t)7, DIRECTION_RIGHT, 0); + initialise_Ball(ball1, (int8_t)0, (int8_t)9, DIRECTION_LEFT, 1); + initialise_Ball(ball2, (int8_t)0, (int8_t)11, DIRECTION_RIGHT, 2); + layer_mark_dirty(s_ball_layer); + + renderScores(); + + app_timer_register(game->delay, updateWorld, NULL); } } @@ -255,7 +268,7 @@ static void click_config_provider(void *context) // Register the ClickHandlers window_single_click_subscribe(BUTTON_ID_SELECT, up_click_handler); window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler); - //window_single_click_subscribe(BUTTON_ID_UP, reset_game_handler); + window_single_click_subscribe(BUTTON_ID_UP, reset_game_handler); } void handle_init(void) @@ -272,10 +285,12 @@ void handle_init(void) // initialise score layers scoreLayer = text_layer_create(GRect(0,0,60,20)); highScoreLayer = text_layer_create(GRect(144-30,0,30,20)); - nameLayer = text_layer_create(GRect(0,20,160,20)); + nameLayer = text_layer_create(GRect(0,40,160,20)); + restartTextLayer = text_layer_create(GRect(0,20,160,20)); text_layer_set_background_color(scoreLayer, GColorClear); text_layer_set_background_color(highScoreLayer, GColorClear); text_layer_set_background_color(nameLayer, GColorClear); + text_layer_set_background_color(restartTextLayer, GColorClear); // Load the images s_background = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG); @@ -312,6 +327,7 @@ void handle_init(void) layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(scoreLayer)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(highScoreLayer)); layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(nameLayer)); + layer_add_child(window_get_root_layer(my_window), text_layer_get_layer(restartTextLayer)); layer_set_update_proc(s_ball_layer, renderBalls); window_stack_push(my_window, true);