Beispiel #1
0
QString MERFTag::getParam(QString msfName,QString param, QString* sarfMatches) {
    if(msf->name == msfName) {
        if(param  == "text") {
            return getText();
        }
        else if(param == "position") {
            return QString::number(getPOS());
        }
        else if(param == "number") {
            QString text = getText();
            NumNorm nn(&text);
            nn();
            int number = NULL;
            if(nn.extractedNumbers.count()!=0) {
                number = nn.extractedNumbers[0].getNumber();
                return QString::number(number);
            }
            else {
                return "NULL";
            }
        }
        else if(param == "length") {
            return QString::number(getLength());
        }
        else {
            return "NULL";
        }
    }
    else {
        return match->getParam(msfName,param);
    }
    return "";
}
Beispiel #2
0
static void maze_layer_update_callback(Layer *layer, GContext *ctx) {
  for(int i = 0; i < mazeWidth; i++){
    for(int j = 0; j < mazeHeight; j++){
      int currentPos = getPOS(j, i, mazeWidth);
      if(maze[currentPos].r == 1) {
        graphics_draw_line(ctx, GPoint(corridorSize*(i + 1), corridorSize*j), GPoint(corridorSize*(i + 1), corridorSize*(j + 1)));
      }
      if(maze[currentPos].b == 1) {
        graphics_draw_line(ctx, GPoint(corridorSize*i, corridorSize*(j + 1)), GPoint(corridorSize*(i + 1), corridorSize*(j + 1)));
      }
    }
  }
  graphics_draw_circle(ctx, GPoint((mazeWidth-1)*corridorSize+corridorSize/2,
                                   (mazeHeight-1)*corridorSize+corridorSize/2), corridorSize/2-1);
}
Beispiel #3
0
void MainScene::intersectsBallAndBlock() {
    // ブロックの数分回す
    for( int i = 1; i <= 40; i++ ){
        
        // ブロックのインスタンスを取得
        auto block = reinterpret_cast<BlockSprite*>(getChildByTag(i));
        
        if( block != nullptr ){
            
            // ブロックの Rect 取得
            auto blocksRect = block->getBoundingBox();
            
            auto ball = (Ball*)getChildByTag(T_Ball);
            if( ball != nullptr){
                // ボールがあれば Rect を作る
                auto ballRect = ball->getBoundingBox();
                // ボールとブロックの衝突判定
                if((ballRect.intersectsRect(blocksRect))){
                    
                    // 乱数でアイテム生成(現状0.3)、ブロックの消去
                    int random = (int)CCRANDOM_0_1() * 10;
                    if(random < 3){
                        itemGenerator->generate(block->getPOS());
                    }
                    block->remove();
                    
                    // ↓スコアの加算
                    
                    // ↑スコアの加算
                    
                }
            }

            
        }
    }
    
}
Beispiel #4
0
static void data_handler(void* out) {
  app_timer_register(30, data_handler, NULL);
  layer_mark_dirty(s_player_layer);
  
  
  //you win
  if (playerY == mazeHeight-1 && playerX == mazeWidth-1 && dx==0 && dy==0){
    vibes_short_pulse();
    load(mazeWidth,mazeHeight,corridorSize);
    return;
  }
  
  int speed = difficulty==1?2:1;
  if(dx!=0 || dy!=0) {
    if(dx<0) dx+=speed;
    if(dx>0) dx-=speed;
    if(dy<0) dy+=speed;
    if(dy>0) dy-=speed;
    
    return;
  }
  
  AccelData* data = malloc(sizeof(*data));
  accel_service_peek(data);
  

  if(data->x*data->x + data->y*data->y > 150*150) {
    //left, right, up, down, just like maze.c
    int xopts[4] = {-1,1,0,0};
    int yopts[4] = {0,0,-1,1};
    int bestopt=0, bestscore=0;
    int xmag = abs(data->x),
        ymag = abs(data->y);
    //app_log(APP_LOG_LEVEL_INFO,"main.c",1337,"mag %i %i",xmag,ymag);
    for(int i=0; i<4; i++) {
      int newx = playerX+xopts[i],
          newy = playerY+yopts[i];
      //bounds checking
      int curscore = (newx>=0 && newy>=0 && newx<mazeWidth && newy < mazeHeight) ? 1 : 0;
      //wall checking
      if(i<2) {//x
        curscore *= 1-maze[getPOS(playerY,(xopts[i]==1?playerX:newx),mazeWidth)].r;
        curscore *= xmag<50?0:xopts[i]*data->x;
      } else {//y
        curscore *= 1-maze[getPOS((yopts[i]==1?playerY:newy),playerX,mazeWidth)].b;
        curscore *= ymag<50?0:-yopts[i]*data->y;
      }
      //app_log(APP_LOG_LEVEL_INFO,"main.c",1338,"score %i %i",i,curscore);
      if(curscore > bestscore) {
        bestopt = i;
        bestscore = curscore;
      }
    }
    if(bestscore>0) {
      lightup();
      playerX += xopts[bestopt];
      playerY += yopts[bestopt];
      dx -= xopts[bestopt]*(corridorSize-speed);
      dy -= yopts[bestopt]*(corridorSize-speed);
    }
  }
  free(data);
}