/* ===================================================================== * Submarine explosion * =====================================================================*/ static void submarine_explosion() { GdkPixbuf *pixmap = NULL; if (submarine_destroyed) return; submarine_destroyed = TRUE; gamewon = FALSE; gc_sound_play_ogg("sounds/crash.wav", NULL); /* make the submarine die */ setSpeed(speed_ordered = submarine_horizontal_speed = 0.0); setBattery(battery = 0.0); setAir(air = 0.0); regleur = MAX_REGLEUR; weight = 2000.0; /* Stop the frigate */ goo_canvas_item_stop_animation (frigate_item); /* display the boken submarine */ pixmap = gc_pixmap_load("submarine/submarine-broken.png"); g_object_set(submarine_item, "pixbuf", pixmap, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif ok(); }
bool DS3231::begin(void) { Wire.begin(); setBattery(true, false); t.year = 2000; t.month = 1; t.day = 1; t.hour = 0; t.minute = 0; t.second = 0; t.dayOfWeek = 6; t.unixtime = 946681200; return true; }
// Called when a message is received from PebbleKitJS static void in_received_handler(DictionaryIterator *received, void *context) { bool ok = false; int status = 0; Tuple *tuple; tuple = dict_find(received, STATUS_KEY); if(tuple) { status = (int)tuple->value->uint32; //APP_LOG(APP_LOG_LEVEL_DEBUG, "Received Status: %d", (int)tuple->value->uint32); } if (status == 1) { /* tuple = dict_find(received, MESSAGE_KEY); if(tuple) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Received Message: %s", tuple->value->cstring); }*/ if (!initialized) { initialized = true; hide_loadscreen(); show_window(); } if (tupleInt(received, RECORDING) == 1) { vibes_double_pulse(); } mode = tupleInt(received, MODE); setMode(mode, tupleInt(received, RECORDING)); setBattery(tupleInt(received, BATTERY)); set_text(tupleStr(received, CURRENT), tupleStr(received, REMAIN)); } else { if (initialized) { initialized = false; hide_window(); show_loadscreen(); } set_loadText(status); } }
/* ===================================================================== * Periodically recalculate some submarine parameters, with a slow delay * =====================================================================*/ static gboolean update_timeout_very_slow() { /* charging */ if(!boardRootItem) return FALSE; if(board_paused) return TRUE; if (air_charging && depth < SURFACE_DEPTH+5.0) { air += 100.0*UPDATE_DELAY_VERY_SLOW/1000.0; setAir(air); } if (battery_charging && depth < SURFACE_DEPTH+5.0) { if (battery < 0.3*battery) battery += 500.0*UPDATE_DELAY_VERY_SLOW/1000.0; else if (battery < 0.6*battery) battery += 200.0*UPDATE_DELAY_VERY_SLOW/1000.0; else if (battery < 0.8*battery) battery += 100.0*UPDATE_DELAY_VERY_SLOW/1000.0; else battery += 50.0*UPDATE_DELAY_VERY_SLOW/1000.0; } /* battery */ battery -= submarine_horizontal_speed * submarine_horizontal_speed/3.0 * UPDATE_DELAY_VERY_SLOW/1000.0; if (battery < 0.0) { battery = 0.0; speed_ordered = 0; setSpeed(speed_ordered); } setBattery( battery ); /* bubbling */ if ( (ballast_av_purge_open && ballast_av_air > 0.0) || ( ballast_av_chasse_open && ballast_av_air == MAX_BALLAST ) ) { gc_item_absolute_move( bubbling[0], submarine_x + submarine_width/2, depth - 30.0); g_object_set ( bubbling[0] , "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); gc_sound_play_ogg ("sounds/bubble.wav", NULL); } else g_object_set ( bubbling[0] , "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); if ( (ballast_ar_purge_open && ballast_ar_air > 0.0) || ( ballast_ar_chasse_open && ballast_ar_air == MAX_BALLAST ) ) { gc_item_absolute_move( bubbling[2], submarine_x - submarine_width/2, depth - 30.0); gc_sound_play_ogg ("sounds/bubble.wav", NULL); g_object_set ( bubbling[2] , "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); } else g_object_set ( bubbling[2] , "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); if (regleur_purge_open && regleur < MAX_REGLEUR) { gc_item_absolute_move( bubbling[1], submarine_x, depth - 30.0); gc_sound_play_ogg ("sounds/bubble.wav", NULL); g_object_set ( bubbling[1] , "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); } else g_object_set ( bubbling[1] , "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); return TRUE; }