Initial commit

This commit is contained in:
2026-03-10 16:53:11 -04:00
commit 7c65eb4dcb
12 changed files with 946 additions and 0 deletions

138
src/c/main.c Normal file
View File

@@ -0,0 +1,138 @@
#include <pebble.h>
#include "palette_manip.h"
// declare general static pointers
static Window *s_main_window;
static BitmapLayer *s_guy_head_layer;
static BitmapLayer *s_guy_butt_layer;
// declare silly guy parts
static GColor8 s_random_color_current;
static GColor8 s_random_color_next;
static GBitmap *s_head_current;
static GBitmap *s_butt_current;
static GBitmap *s_head_next;
static GBitmap *s_butt_next;
// declare lookup tables
static const uint32_t randomHeadPool[] = {
RESOURCE_ID_H001, RESOURCE_ID_H002, RESOURCE_ID_H003,
RESOURCE_ID_H004, RESOURCE_ID_H005, RESOURCE_ID_H006,
RESOURCE_ID_H007, RESOURCE_ID_H008, RESOURCE_ID_H009,
RESOURCE_ID_H010, RESOURCE_ID_H011, RESOURCE_ID_H012,
RESOURCE_ID_H013, RESOURCE_ID_H014, RESOURCE_ID_H015,
RESOURCE_ID_H016, RESOURCE_ID_H017, RESOURCE_ID_H018,
RESOURCE_ID_H019, RESOURCE_ID_H020, RESOURCE_ID_H021,
RESOURCE_ID_H022
};
static const uint32_t randomButtPool[] = {
RESOURCE_ID_B001, RESOURCE_ID_B002, RESOURCE_ID_B003,
RESOURCE_ID_B004, RESOURCE_ID_B005, RESOURCE_ID_B006,
RESOURCE_ID_B007, RESOURCE_ID_B008, RESOURCE_ID_B009,
RESOURCE_ID_B010, RESOURCE_ID_B011, RESOURCE_ID_B012,
RESOURCE_ID_B013, RESOURCE_ID_B014, RESOURCE_ID_B015,
RESOURCE_ID_B016, RESOURCE_ID_B017, RESOURCE_ID_B018,
RESOURCE_ID_B019, RESOURCE_ID_B020, RESOURCE_ID_B021,
RESOURCE_ID_B022, RESOURCE_ID_XB001, RESOURCE_ID_XB002,
RESOURCE_ID_XB003, RESOURCE_ID_XB004
};
static const GColor8 darkBGColorPool[] = {
// Red
GColorFolly,
GColorRed,
// Orange
GColorOrange,
GColorRajah,
GColorSunsetOrange,
// Yellow
GColorChromeYellow,
GColorIcterine,
GColorPastelYellow,
GColorYellow,
// Green
GColorInchworm,
GColorJaegerGreen,
GColorKellyGreen,
GColorMintGreen,
// Blue
GColorElectricBlue,
GColorTiffanyBlue,
GColorVividCerulean,
// Purple
GColorLavenderIndigo,
GColorPurpureus,
GColorRichBrilliantLavender,
// Pink
GColorBrilliantRose,
GColorMelon,
// Brown
GColorRoseVale
};
// define contents of the Window upon load
static void main_window_load(Window *window) {
// format silly guy layers
s_guy_head_layer = bitmap_layer_create(GRect(PBL_IF_ROUND_ELSE(0, -30), PBL_IF_ROUND_ELSE(0, -16), 260, 115));
s_guy_butt_layer = bitmap_layer_create(GRect(PBL_IF_ROUND_ELSE(0, -30), PBL_IF_ROUND_ELSE(145, 129), 260, 115));
bitmap_layer_set_compositing_mode(s_guy_head_layer, GCompOpSet);
bitmap_layer_set_background_color(s_guy_head_layer, GColorBlack);
bitmap_layer_set_bitmap(s_guy_head_layer, s_head_current);
bitmap_layer_set_compositing_mode(s_guy_butt_layer, GCompOpSet);
bitmap_layer_set_background_color(s_guy_butt_layer, GColorBlack);
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt_current);
// add silly guy layers as children to window
Layer *window_layer = window_get_root_layer(window);
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_head_layer));
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_butt_layer));
}
// free memory on Window close;
// this means matching all "_create"'s from main_window_load with "_destroy"
static void main_window_unload(Window *window) {
bitmap_layer_destroy(s_guy_head_layer);
bitmap_layer_destroy(s_guy_butt_layer);
}
// set up the app on launch (don't put app logic in here);
static void init() {
// create main Window element and assign to pointer
s_main_window = window_create();
// set handlers to manage the elements inside the Window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
// load initial batch of silly guy parts into memory
s_head_current = gbitmap_create_with_resource(randomHeadPool[rand()%22]);
s_butt_current = gbitmap_create_with_resource(randomButtPool[rand()%26]);
s_head_next = gbitmap_create_with_resource(randomHeadPool[rand()%22]);
s_butt_next = gbitmap_create_with_resource(randomButtPool[rand()%26]);
// pick starting colors
s_random_color_current = darkBGColorPool[rand()%22];
s_random_color_next = darkBGColorPool[rand()%22];
replace_gbitmap_color(GColorGreen, s_random_color_current, s_head_current, NULL);
replace_gbitmap_color(GColorGreen, s_random_color_current, s_butt_current, NULL);
// show the Window on the watch, with animated=true
window_stack_push(s_main_window, true);
}
// free memory on app exit;
// this means matching all "_create"'s from init() with "_destroy"
static void deinit() {
gbitmap_destroy(s_head_current);
gbitmap_destroy(s_butt_current);
gbitmap_destroy(s_head_next);
gbitmap_destroy(s_butt_next);
window_destroy(s_main_window);
}
int main(void) {
init();
app_event_loop();
deinit();
}