Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/pebble-mario.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenis Dzyubenko <shadone@gmail.com>2013-04-17 02:42:46 +0400
committerDenis Dzyubenko <shadone@gmail.com>2013-04-17 02:45:42 +0400
commitae3c401f0ca59e887dc6bf2c8045fcb5d99dbf84 (patch)
treecd609e06e714e742cc352d7d3b51fd6d80a0e4a4 /src
parente9055aa8bf443876f21472eb1f6ebaab674bd4bb (diff)
Made blocks rounded
Diffstat (limited to 'src')
-rw-r--r--src/pebble-mario.c66
1 files changed, 24 insertions, 42 deletions
diff --git a/src/pebble-mario.c b/src/pebble-mario.c
index 7c533d0..65980fa 100644
--- a/src/pebble-mario.c
+++ b/src/pebble-mario.c
@@ -72,46 +72,24 @@ PropertyAnimation minute_animation_slide_in;
#define BLOCK_SIZE 50
#define BLOCK_LAYER_EXTRA 3
#define BLOCK_SQUEEZE 10
+#define BLOCK_SPACING -1
#define MARIO_JUMP_DURATION 50
#define CLOCK_ANIMATION_DURATION 150
#define GROUND_HEIGHT 26
void draw_block(GContext *ctx, GRect rect, uint8_t width)
{
- GPoint p1;
- GPoint p2;
-
- int16_t x = rect.origin.x;
- int16_t y = rect.origin.y;
- int16_t w = rect.size.w;
- int16_t h = rect.size.h;
-
- for (; width != 0; --width) {
- // top
- p1 = GPoint(x, y);
- p2 = GPoint(x + w, y);
- graphics_draw_line(ctx, p1, p2);
-
- // left
- p1 = GPoint(x, y);
- p2 = GPoint(x, y + h);
- graphics_draw_line(ctx, p1, p2);
-
- // right
- p1 = GPoint(x + w, y);
- p2 = GPoint(x + w, y + h);
- graphics_draw_line(ctx, p1, p2);
-
- // bottom
- p1 = GPoint(x, y + h);
- p2 = GPoint(x + w, y + h);
- graphics_draw_line(ctx, p1, p2);
-
- x += 1;
- y += 1;
- w -= 2;
- h -= 2;
- }
+ static const uint8_t radius = 1;
+
+ graphics_context_set_fill_color(ctx, GColorBlack);
+ graphics_fill_rect(ctx, rect, radius, GCornersAll);
+
+ rect.origin.x += width;
+ rect.origin.y += width;
+ rect.size.w -= width*2;
+ rect.size.h -= width*2;
+ graphics_context_set_fill_color(ctx, GColorWhite);
+ graphics_fill_rect(ctx, rect, radius, GCornersAll);
}
void blocks_update_callback(Layer *layer, GContext *ctx)
@@ -126,17 +104,21 @@ void blocks_update_callback(Layer *layer, GContext *ctx)
GRect block_rect[2];
GRect dot_rect;
- block_rect[0] = GRect(layer->bounds.origin.x, layer->bounds.origin.y + BLOCK_LAYER_EXTRA,
- BLOCK_SIZE - 1, layer->frame.size.h - BLOCK_LAYER_EXTRA - 1);
- block_rect[1] = GRect(layer->bounds.origin.x + BLOCK_SIZE, layer->bounds.origin.y + BLOCK_LAYER_EXTRA,
- BLOCK_SIZE - 1, layer->frame.size.h - BLOCK_LAYER_EXTRA - 1);
+ block_rect[0] = GRect(layer->bounds.origin.x,
+ BLOCK_SIZE,
+ layer->frame.size.h - BLOCK_LAYER_EXTRA);
+ block_rect[1] = GRect(layer->bounds.origin.x + BLOCK_SIZE + BLOCK_SPACING,
+ layer->bounds.origin.y + BLOCK_LAYER_EXTRA,
+ BLOCK_SIZE,
+ layer->frame.size.h - BLOCK_LAYER_EXTRA);
for (uint8_t i = 0; i < 2; ++i) {
GRect *rect = block_rect + i;
- graphics_context_set_stroke_color(ctx, GColorBlack);
draw_block(ctx, *rect, 4);
+ graphics_context_set_fill_color(ctx, GColorBlack);
+
// top left dot
dot_rect = GRect(rect->origin.x + offset, rect->origin.y + offset,
dot_width, dot_height);
@@ -210,9 +192,9 @@ void handle_init(AppContextRef ctx)
hour_up_rect = GRect(5, -10, 40, 40);
hour_normal_rect = GRect(5, 5 + BLOCK_LAYER_EXTRA, 40, 40);
hour_down_rect = GRect(5, BLOCK_SIZE + BLOCK_LAYER_EXTRA, 40, 40);
- minute_up_rect = GRect(55, -10, 40, 40);
- minute_normal_rect = GRect(55, 5 + BLOCK_LAYER_EXTRA, 40, 40);
- minute_down_rect = GRect(55, BLOCK_SIZE + BLOCK_LAYER_EXTRA, 40, 40);
+ minute_up_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, -10, 40, 40);
+ minute_normal_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, 5 + BLOCK_LAYER_EXTRA, 40, 40);
+ minute_down_rect = GRect(5+BLOCK_SIZE+BLOCK_SPACING, BLOCK_SIZE + BLOCK_LAYER_EXTRA, 40, 40);
layer_init(&blocks_layer, blocks_down_rect);
layer_init(&mario_layer, mario_down_rect);