Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.86 KB | None | 0 0
  1. LOG("__debug__ initGame");
  2.  
  3.     float tileWidth = 173.0/12.0;
  4.     float tileOffset = tileWidth / 2.0;
  5.  
  6.     float xOffset = -(173.0/2.0);
  7.     float yOffset = -(173.0/2.0);
  8.  
  9.     Marker* gameboardMarker = MarkerManager::getInstance()->getMarker(MARKER_GAMEBOARD);
  10.     Renderer* renderer = gameboardMarker->getRenderer();
  11.  
  12.     // init game
  13.     game = new Game();
  14.  
  15.     int floorLength = env->GetArrayLength(floor);
  16.  
  17.     jclass cls = env->FindClass("de/hs/ghosthuntar/jni/Data");
  18.     jfieldID xField = env->GetFieldID(cls, "x", "I");
  19.     jfieldID yField = env->GetFieldID(cls, "y", "I");
  20.     jfieldID ghostField = env->GetFieldID(cls, "ghost", "Z");
  21.     jfieldID cardField = env->GetFieldID(cls, "card", "Z");
  22.     jfieldID amuletteField = env->GetFieldID(cls, "amulette", "Z");
  23.     jfieldID coinField = env->GetFieldID(cls, "coin", "Z");
  24.  
  25.     jfieldID isRoomField = env->GetFieldID(cls, "isRoom", "Z");
  26.     jfieldID wField = env->GetFieldID(cls, "w", "I");
  27.     jfieldID hField = env->GetFieldID(cls, "h", "I");
  28.     jfieldID entranceXField = env->GetFieldID(cls, "entranceX", "I");
  29.     jfieldID entranceYField = env->GetFieldID(cls, "entranceY", "I");
  30.  
  31.     for(int i = 0; i < floorLength; i++) {
  32.         jobject tile = env->GetObjectArrayElement(floor, i);
  33.         int x = env->GetIntField(tile, xField);
  34.         int y = env->GetIntField(tile, yField);
  35.         bool ghost = env->GetBooleanField(tile, ghostField);
  36.         bool card = env->GetBooleanField(tile, cardField);
  37.         bool amulette = env->GetBooleanField(tile, amuletteField);
  38.         bool coin = env->GetBooleanField(tile, coinField);
  39.  
  40.         Tile* t = new Tile(x, y, ghost, card, amulette, coin);
  41.         PositionRenderable* p = new PositionRenderable(textures[17], textures[19]);
  42.         p->setPosition(Vec3(tileWidth*(float)x + tileOffset + xOffset, -(tileWidth*(float)y + tileOffset + yOffset), 0));
  43.         p->hide();
  44.         t->setPositionRenderable(p);
  45.         renderer->add(p);
  46.         game->addTile(t);
  47.     }
  48.  
  49.     int roomLength = env->GetArrayLength(rooms);
  50.     for(int i = 0; i < roomLength; i++) {
  51.         jobject room = env->GetObjectArrayElement(rooms, i);
  52.         int x = env->GetIntField(room, xField);
  53.         int y = env->GetIntField(room, yField);
  54.         int w = env->GetIntField(room, wField);
  55.         int h = env->GetIntField(room, hField);
  56.         int entranceX = env->GetIntField(room, entranceXField);
  57.         int entranceY = env->GetIntField(room, entranceYField);
  58.         bool ghost = env->GetBooleanField(room, ghostField);
  59.         bool card = env->GetBooleanField(room, cardField);
  60.         bool amulette = env->GetBooleanField(room, amuletteField);
  61.         bool coin = env->GetBooleanField(room, coinField);
  62.  
  63.         Room* r = new Room(x, y, w, h, entranceX, entranceY, amulette, ghost, coin, card);
  64.         PositionRenderable* p = new PositionRenderable(textures[18], textures[19]);
  65.         p->translate(Vec3(tileWidth*(float)(x+(w/2.0)) + xOffset, -(tileWidth*(float)(y+(h/2.0)) + yOffset), 0));
  66.         p->scaleX(w);
  67.         p->scaleY(h);
  68.         p->hide();
  69.         r->setPositionRenderable(p);
  70.         renderer->add(p);
  71.         game->addRoom(r);
  72.  
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement