Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LOG("__debug__ initGame");
- float tileWidth = 173.0/12.0;
- float tileOffset = tileWidth / 2.0;
- float xOffset = -(173.0/2.0);
- float yOffset = -(173.0/2.0);
- Marker* gameboardMarker = MarkerManager::getInstance()->getMarker(MARKER_GAMEBOARD);
- Renderer* renderer = gameboardMarker->getRenderer();
- // init game
- game = new Game();
- int floorLength = env->GetArrayLength(floor);
- jclass cls = env->FindClass("de/hs/ghosthuntar/jni/Data");
- jfieldID xField = env->GetFieldID(cls, "x", "I");
- jfieldID yField = env->GetFieldID(cls, "y", "I");
- jfieldID ghostField = env->GetFieldID(cls, "ghost", "Z");
- jfieldID cardField = env->GetFieldID(cls, "card", "Z");
- jfieldID amuletteField = env->GetFieldID(cls, "amulette", "Z");
- jfieldID coinField = env->GetFieldID(cls, "coin", "Z");
- jfieldID isRoomField = env->GetFieldID(cls, "isRoom", "Z");
- jfieldID wField = env->GetFieldID(cls, "w", "I");
- jfieldID hField = env->GetFieldID(cls, "h", "I");
- jfieldID entranceXField = env->GetFieldID(cls, "entranceX", "I");
- jfieldID entranceYField = env->GetFieldID(cls, "entranceY", "I");
- for(int i = 0; i < floorLength; i++) {
- jobject tile = env->GetObjectArrayElement(floor, i);
- int x = env->GetIntField(tile, xField);
- int y = env->GetIntField(tile, yField);
- bool ghost = env->GetBooleanField(tile, ghostField);
- bool card = env->GetBooleanField(tile, cardField);
- bool amulette = env->GetBooleanField(tile, amuletteField);
- bool coin = env->GetBooleanField(tile, coinField);
- Tile* t = new Tile(x, y, ghost, card, amulette, coin);
- PositionRenderable* p = new PositionRenderable(textures[17], textures[19]);
- p->setPosition(Vec3(tileWidth*(float)x + tileOffset + xOffset, -(tileWidth*(float)y + tileOffset + yOffset), 0));
- p->hide();
- t->setPositionRenderable(p);
- renderer->add(p);
- game->addTile(t);
- }
- int roomLength = env->GetArrayLength(rooms);
- for(int i = 0; i < roomLength; i++) {
- jobject room = env->GetObjectArrayElement(rooms, i);
- int x = env->GetIntField(room, xField);
- int y = env->GetIntField(room, yField);
- int w = env->GetIntField(room, wField);
- int h = env->GetIntField(room, hField);
- int entranceX = env->GetIntField(room, entranceXField);
- int entranceY = env->GetIntField(room, entranceYField);
- bool ghost = env->GetBooleanField(room, ghostField);
- bool card = env->GetBooleanField(room, cardField);
- bool amulette = env->GetBooleanField(room, amuletteField);
- bool coin = env->GetBooleanField(room, coinField);
- Room* r = new Room(x, y, w, h, entranceX, entranceY, amulette, ghost, coin, card);
- PositionRenderable* p = new PositionRenderable(textures[18], textures[19]);
- p->translate(Vec3(tileWidth*(float)(x+(w/2.0)) + xOffset, -(tileWidth*(float)(y+(h/2.0)) + yOffset), 0));
- p->scaleX(w);
- p->scaleY(h);
- p->hide();
- r->setPositionRenderable(p);
- renderer->add(p);
- game->addRoom(r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement