LoginSignup
0

More than 5 years have passed since last update.

TOPPERS活用アイデア・アプリケーション開発コンテスト受賞作品紹介(13)第六回(2016)がじぇるねIoTクラス 銀賞 Block to fall 小野寺大樹(個人)

Last updated at Posted at 2018-06-24

TOPPERS「活用アイデア」・「アプリケーション開発」コンテスト
は、2011年から毎年実施されています。
https://www.toppers.jp/contest.html

「アプケーション開発」は、ソースコードの公開を前提としています。
「活用アイデア」でも、その後実現したソースコードなどもある。探しながら紹介。

なお、この記事は、TOPPERSプロジェクトの公式見解ではなく、
小川清 の 技術者個人の考えに基づいています。

目的(purpose)

TOPPERS開発アイデア・アプリケーション開発コンテスト受賞作品には、良質な算譜、技術的に崇高な志向、目的を達成するための意思などが感じられる。広く、source codeを表示して紹介し、次の応募作品を促す。

成果(outcome)

応募作品の算譜を眺めると、その技術者の得意分野や技法を感じることができる。応募作品のソースコードを使ってみようという気になる。ソースコードを一度コンパイルしたくなる。自分も良い作品を作ろうという気になる。

TOPPERS活用アイデア・アプリケーション開発コンテスト受賞作品紹介(13)第六回(2016)がじぇるねIoTクラス 銀賞

Block to fall 小野寺大樹(個人)

応募資料(application material)等

コンテスト応募資料
https://www.toppers.jp/docs/contest/2016/Block_to_fall.pdf

Download

ソースコード
https://www.toppers.jp/docs/contest/2016/src_Block_to_fall.zip

関連資料(related URL)

算譜(source code)

/*
 * Block.c
 *
 *  Created on: 2016/06/03
 *      Author: ko-ueki
 */
#include <stdint.h>

extern void drawline(int16_t x0, int16_t y0, int16_t x1, int16_t y1,uint32_t color);
extern void drawPixel(int16_t x, int16_t y, uint32_t color);

/*
 * X方向の値を取得
 */
short getX(short x){
    switch(x){
    case 0:
        return 24;
    case 1:
        return 32;
    case 2:
        return 40;
    case 3:
        return 48;
    case 4:
        return 56;
    case 5:
        return 64;
    case 6:
        return 72;
    case 7:
        return 80;
    case 8:
        return 88;
    case 9:
        return 96;
    case 500:
    case 503:
    case 506:
    case 509:
    case 602:
    case 605:
    case 608:
    case 611:
    case 614:
        return 0;
    case 501:
    case 504:
    case 507:
    case 510:
    case 601:
    case 604:
    case 607:
    case 610:
    case 613:
        return 8;
    case 502:
    case 505:
    case 508:
    case 511:
    case 600:
    case 603:
    case 606:
    case 609:
    case 612:
        return 16;
    default:
        return 999;
    }
}

/*
 * Y方向の値を取得
 */
short getY(short flag, short y){
    if (flag == 1){
        switch(y){
        case 0:
            return 80;
        case 10:
        case 612:
        case 613:
        case 614:
            return 88;
        case 20:
        case 609:
        case 610:
        case 611:
            return 96;
        case 30:
        case 606:
        case 607:
        case 608:
            return 104;
        case 40:
        case 603:
        case 604:
        case 605:
            return 112;
        case 50:
        case 600:
        case 601:
        case 602:
            return 120;
        case 60:
        case 500:
        case 501:
        case 502:
            return 128;
        case 70:
        case 503:
        case 504:
        case 505:
            return 136;
        case 80:
        case 506:
        case 507:
        case 508:
            return 144;
        case 90:
        case 509:
        case 510:
        case 511:
            return 152;
        default:
            return 999;
        }
    }
    else if (flag == 0) {
        switch(y){
        case 0:
            return 0;
        case 10:
            return 8;
        case 20:
            return 16;
        case 30:
            return 24;
        case 40:
            return 32;
        case 50:
            return 40;
        case 60:
            return 48;
        case 70:
            return 56;
        case 80:
            return 64;
        case 90:
            return 72;
        default:
            return 999;
        }
    }
    else{
        return 999;
    }
}

/*
 * ブロックの描画
 */
void drawBlock(short index, int color, int cornerColor){
    short x1, x2, y1, y2, xIndex, yIndex;
    if (index < 300){
        xIndex = index % 10;
    }
    else {
        xIndex = index;
    }
    x1 = getX(xIndex);
    if (x1 == 999){
        return;
    }
    x2 = x1 + 7;
    if (index < 300){
        yIndex = index - xIndex;
        y1 = getY(yIndex / 100, yIndex % 100);
    }
    else {
        y1 = getY(1, index);
    }
    if (y1 == 999){
        return;
    }
    y2 = y1 + 7;
    drawline(x1, y1, x2, y1, color);
    drawline(x1, y2, x2, y2, color);
    drawline(x1, y1, x1, y2, color);
    drawline(x2, y1, x2, y2, color);
    drawline(x1, y1, x2, y2, color);
    drawPixel(x1, y1, cornerColor);
    drawPixel(x1, y2, cornerColor);
    drawPixel(x2, y1, cornerColor);
    drawPixel(x2, y2, cornerColor);
}

/*
 * ブロックの描画
 */
void drawBlock2(short index, int color){
    short x1, x2, y1, y2, xIndex, yIndex;
    if (index < 300){
        xIndex = index % 10;
    }
    else {
        xIndex = index;
    }
    x1 = getX(xIndex);
    if (x1 == 999){
        return;
    }
    x2 = x1 + 7;
    if (index < 300){
        yIndex = index - xIndex;
        y1 = getY(yIndex / 100, yIndex % 100);
    }
    else {
        y1 = getY(1, index);
    }
    if (y1 == 999){
        return;
    }
    y2 = y1 + 7;
    drawline(x1, y1, x2, y1, color);
    drawline(x1, y1 + 1, x2, y1 + 1, color);
    drawline(x1, y1 + 2, x2, y1 + 2, color);
    drawline(x1, y1 + 3, x2, y1 + 3, color);
    drawline(x1, y1 + 4, x2, y1 + 4, color);
    drawline(x1, y1 + 5, x2, y1 + 5, color);
    drawline(x1, y1 + 6, x2, y1 + 6, color);
    drawline(x1, y1 + 7, x2, y1 + 7, color);
}

/*
 * ぷよの描画
 */
void drawBlock3(short index, int color, int cornerColor){
    short x1, x2, y1, y2, xIndex, yIndex;
    if (index < 300){
        xIndex = index % 10;
    }
    else {
        xIndex = index;
    }
    x1 = getX(xIndex);
    if (x1 == 999){
        return;
    }
    x2 = x1 + 7;
    if (index < 300){
        yIndex = index - xIndex;
        y1 = getY(yIndex / 100, yIndex % 100);
    }
    else {
        y1 = getY(1, index);
    }
    if (y1 == 999){
        return;
    }
    y2 = y1 + 7;
    drawline(x1, y1, x2, y1, color);
    drawline(x1, y1 + 1, x2, y1 + 1, color);
    drawline(x1, y1 + 2, x2, y1 + 2, color);
    drawline(x1, y1 + 3, x2, y1 + 3, color);
    drawline(x1, y1 + 4, x2, y1 + 4, color);
    drawline(x1, y1 + 5, x2, y1 + 5, color);
    drawline(x1, y1 + 6, x2, y1 + 6, color);
    drawline(x1, y1 + 7, x2, y1 + 7, color);
    drawPixel(x1, y1, cornerColor);
    drawPixel(x1, y2, cornerColor);
    drawPixel(x2, y1, cornerColor);
    drawPixel(x2, y2, cornerColor);
    drawPixel(x1 + 1, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 2, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 5, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 6, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 1, y1 + 4, 0x000000);
    drawPixel(x1 + 2, y1 + 4, 0x000000);
    drawPixel(x1 + 5, y1 + 4, 0x000000);
    drawPixel(x1 + 6, y1 + 4, 0x000000);
    drawPixel(x1 + 1, y1 + 5, 0xFFFFFF);
    drawPixel(x1 + 2, y1 + 5, 0xFFFFFF);
    drawPixel(x1 + 5, y1 + 5, 0xFFFFFF);
    drawPixel(x1 + 6, y1 + 5, 0xFFFFFF);
}

/*
 * ぷよ(つぶれ)の描画
 */
void drawBlock4(short index, int color, int cornerColor){
    short x1, x2, y1, y2, xIndex, yIndex;
    if (index < 300){
        xIndex = index % 10;
    }
    else {
        xIndex = index;
    }
    x1 = getX(xIndex);
    if (x1 == 999){
        return;
    }
    x2 = x1 + 7;
    if (index < 300){
        yIndex = index - xIndex;
        y1 = getY(yIndex / 100, yIndex % 100);
    }
    else {
        y1 = getY(1, index);
    }
    if (y1 == 999){
        return;
    }
    y2 = y1 + 7;
    drawline(x1, y1, x2, y1, color);
    drawline(x1, y1 + 1, x2, y1 + 1, color);
    drawline(x1, y1 + 2, x2, y1 + 2, color);
    drawline(x1, y1 + 3, x2, y1 + 3, color);
    drawline(x1, y1 + 4, x2, y1 + 4, color);
    drawline(x1, y1 + 5, x2, y1 + 5, color);
    drawline(x1, y1 + 6, x2, y1 + 6, color);
    drawline(x1, y1 + 7, x2, y1 + 7, color);
    drawPixel(x1, y1, cornerColor);
    drawPixel(x1, y2, cornerColor);
    drawPixel(x2, y1, cornerColor);
    drawPixel(x2, y2, cornerColor);
    drawPixel(x1 + 1, y1 + 1, 0xFFFFFF);
    drawPixel(x1 + 2, y1 + 1, 0xFFFFFF);
    drawPixel(x1 + 5, y1 + 1, 0xFFFFFF);
    drawPixel(x1 + 6, y1 + 1, 0xFFFFFF);
    drawPixel(x1 + 1, y1 + 2, 0x000000);
    drawPixel(x1 + 2, y1 + 2, 0x000000);
    drawPixel(x1 + 5, y1 + 2, 0x000000);
    drawPixel(x1 + 6, y1 + 2, 0x000000);
    drawPixel(x1 + 1, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 2, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 5, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 6, y1 + 3, 0xFFFFFF);
    drawPixel(x1 + 4, y1 + 6, 0x000000);
    drawPixel(x1 + 5, y1 + 6, 0x000000);
    drawPixel(x1 + 3, y1 + 7, 0x000000);
    drawPixel(x1 + 4, y1 + 7, 0x000000);
    drawPixel(x1 + 5, y1 + 7, 0x000000);
    drawPixel(x1 + 6, y1 + 7, 0x000000);
}

/*
 * パック(点)の描画
 */
void drawBlock5(short index, int color, int centerColor){
    short x1, x2, y1, y2, xIndex, yIndex;
    if (index < 300){
        xIndex = index % 10;
    }
    else {
        xIndex = index;
    }
    x1 = getX(xIndex);
    if (x1 == 999){
        return;
    }
    x2 = x1 + 7;
    if (index < 300){
        yIndex = index - xIndex;
        y1 = getY(yIndex / 100, yIndex % 100);
    }
    else {
        y1 = getY(1, index);
    }
    if (y1 == 999){
        return;
    }
    y2 = y1 + 7;
    drawline(x1, y1, x2, y1, color);
    drawline(x1, y1 + 1, x2, y1 + 1, color);
    drawline(x1, y1 + 2, x2, y1 + 2, color);
    drawline(x1, y1 + 3, x2, y1 + 3, color);
    drawline(x1, y1 + 4, x2, y1 + 4, color);
    drawline(x1, y1 + 5, x2, y1 + 5, color);
    drawline(x1, y1 + 6, x2, y1 + 6, color);
    drawline(x1, y1 + 7, x2, y1 + 7, color);
    drawline(x1 + 4, y1 + 4, x1 + 5, y1 + 4, centerColor);
    drawline(x1 + 4, y1 + 5, x1 + 5, y1 + 5, centerColor);
}

source

参考資料(reference)

「TOPPERS活用アイデア・アプリケーション開発コンテスト受賞作品紹介」まとめ
https://qiita.com/kaizen_nagoya/items/72b882d96b2841f25faf

TOPPERS活用アイデア・アプリケーション開発コンテストを振り返る
https://researchmap.jp/joxkbxlck-1778110/
「応募すると何が嬉しい」TOPPERS活用アイデア・ アプリケーション開発コンテスト
https://www.slideshare.net/kaizenjapan/ss-78528931

「TOPPERS活用アイデア・アプリケーション開発コンテスト」への道

文書履歴(document history)

ver. 0.10 初稿 20180624

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0