/** * For debugging, makes a square room on the map. * @param x1 * @param y1 * @param x2 * @param y2 */ void Area::boxRoom(const int x1, const int y1, const int x2, const int y2) { // Floor fill(x1+1, y1+1, x2-1, y2-1, TILE_FLOOR); // Top side fill(x1+1, y1, x2-1, y1, TILE_WALL, true, -90.0f); // Left side fill(x1, y1+1, x1, y2-1, TILE_WALL, true); // Right side fill(x2, y1+1, x2, y2-1, TILE_WALL, true, 180.0f); // Bottom side fill(x1+1, y2, x2-1, y2, TILE_WALL, true, 90.0f); // TL setTile(x1, y1, new Tile(TILE_INNERCORNER)); setRotation(x1, y1, -90.0f); setSolid(x1, y1); // BL setTile(x1, y2, new Tile(TILE_INNERCORNER)); setSolid(x1, y2); // TR setTile(x2, y1, new Tile(TILE_INNERCORNER)); setRotation(x2, y1, -180.0f); setSolid(x2, y1); // BR setTile(x2, y2, new Tile(TILE_INNERCORNER)); setRotation(x2, y2, 90.0f); setSolid(x2, y2); }
ToiletBlock::ToiletBlock(int id, Material const& material) : RotatableBlock("blockToilet", id, material) { setSolid(false); setSoundType(Block::SOUND_STONE); setDestroyTime(1.0F); tex = getTextureUVCoordinateSet("quartz_block", 0); }
Mainframe::Mainframe() { setSolid(true); setStatic(true); compTexture.loadFromFile("img/mastermind.png"); computer.setTexture(compTexture); computer.setOrigin(121, 97); computer.setRotation(90); setRotation(90); Rect* r = new Rect(vec::Vector2(-121, -97), vec::Vector2(121, 97)); col.addShape(r); col.rotateTo(toRadians(90)); maxHealth = 500; curHealth = maxHealth; state = HEALTHY; setTag(sf::String("Boss")); Global::objective = getPosition(); }
SmashBall::SmashBall(float x1, float y1) : Item(x1,y1, 40000,TYPE_WIELD) { moveTime = 0; speed = 1; hittable = true; unHittableTime = 0; health = 10; active = true; itemNo = Global::ITEM_SMASHBALL; readyFire = null; Animation*anim; anim = new Animation("normal", 5, 8, 1); anim->addFrame("Images/Game/Items/SmashBall/smashball.png"); addAnimation(anim); anim = new Animation("hit", 6, 2, 1); anim->addFrame("Images/Game/Items/SmashBall/smashball_hit.png"); addAnimation(anim); addFileResource("Images/Game/Items/SmashBall/finalsmash_fire.png"); changeAnimation("normal",FORWARD); ignoreGoThroughPlatforms(true); setSolid(true); canBeCarried(false); }
MicrowaveBlock::MicrowaveBlock(int id, Material const& material) : RotatableBlock("blockMicrowave", id, material) { tex = getTextureUVCoordinateSet("quartz_block", 0); secondary_tex = getTextureUVCoordinateSet("stone", 0); terciary_tex = getTextureUVCoordinateSet("wool", 15); setSoundType(Block::SOUND_WOOD); setSolid(false); }
void Chest::logic() { if (!mInitialized) { mInitialized = true; if (!mDropped) { GameState* gameState = mRoom->getGame()->getGameState(); if(gameState->getInt(buildGameStateVariableString()) == 1) { mUsed = true; setSolid(false); return; } } setSolid(true); } if (mOpen) { mOpenFrameCount++; return; } std::vector<Entity*> collisions = mRoom->collidesWith(this, Entity::PLAYER, 2); if (collisions.size() > 0 && mRoom->getKeyState()->isActionPressed()) { mOpen = true; setSolid(false); mRoom->freeze(100); mRoom->addTextCutScene("Received " + mItem->getName(), 100); mRoom->startCutScenes(); if (!mDropped) { GameState* gameState = mRoom->getGame()->getGameState(); gameState->put(buildGameStateVariableString(), 1); } mRoom->getPlayer()->getInventory()->add(mItem); mItem = 0; } }
ChairBlock::ChairBlock(int id, std::string name, FurnitureBlockAttributes attributes, int item) : RotatableBlock("blockChair", id, attributes.realMaterial) { setSolid(false); setSoundType(attributes.sounds); setDestroyTime(attributes.hardness); tex = attributes.primary_tex; secondary_tex = attributes.secondary_tex; this->droppedItem = item; }
TvBlock::TvBlock(int id, Material const& material) : FurnitureBlock("blockTv", id, material) { tex = getTextureUVCoordinateSet("log", 0); secondary_tex = getTextureUVCoordinateSet("planks", 0); terciary_tex = getTextureUVCoordinateSet("wool", 15); setSoundType(Block::SOUND_WOOD); setSolid(false); }
/** * Fills an area with tiles. * @param x1 Start x coordinate. * @param y1 Start y coordinate. * @param x2 End x coordinate. * @param y2 End y coordinate. * @param filename Tile's model filename. * @param solidness The tile's solid state. * @param rotation Tile's rotation. */ void Area::fill(const int x1, const int y1, const int x2, const int y2, const string filename, const bool solidity, const float rotation) { for(int y = y1; y <= y2; y++) { for(int x = x1; x <= x2; x++) { setTile(x, y, new Tile(filename)); setRotation(x, y, rotation); setSolid(x, y, solidity); } } }
SmallTreeObject::SmallTreeObject(tank::Vectorf pos) : Object(pos) { makeGraphic<tank::Image>(MainState::smallrock); tank::Rectd hb = { 18, static_cast<double>(Tile::TILE_SIZE) - 8, 28, 9 }; hb.y -= hb.h; setHitbox(hb); setSolid(true); }
int AscFile::load(char *filename) { FILE *fp; fp = fopen(filename, "r"); if(fp == NULL) { return -1; } float version; fscanf(fp, "ASCII-Paint v%g", &version); fscanf(fp, "%i %i", &width, &height); setSize(width, height); // Scan until we hit #(the marker for the start of image data) while(fgetc(fp) != '#'); for(int x = 0; x < width; x++) { for(int y = 0; y < height; y++) { char c = fgetc(fp); int fr = fgetc(fp); int fg = fgetc(fp); int fb = fgetc(fp); int br = fgetc(fp); int bg = fgetc(fp); int bb = fgetc(fp); int solid = fgetc(fp); int walkable = fgetc(fp); setChar(x, y, c); setFore(x, y, fr, fg, fb); setBack(x, y, br, bg, bb); setSolid(x, y, solid); setSolid(x, y, walkable); } } fclose(fp); return 1; }
void TimgFilterLogoaway::Tplane::process(const TlogoawaySettings *cfg) { createBorder(cfg,TlogoawaySettings::NORTH,cfg->bordn_mode); createBorder(cfg,TlogoawaySettings::EAST ,cfg->borde_mode); createBorder(cfg,TlogoawaySettings::SOUTH,cfg->bords_mode); createBorder(cfg,TlogoawaySettings::WEST ,cfg->bordw_mode); saveLogoBorder(TlogoawaySettings::NORTH); saveLogoBorder(TlogoawaySettings::SOUTH); saveLogoBorder(TlogoawaySettings::EAST ); saveLogoBorder(TlogoawaySettings::WEST ); switch (cfg->mode) { case TlogoawaySettings::MODE_XY: setAverageVH(cfg); for (int i=1; i<=cfg->blur; i++) { blurLogotemp(false); } break; case TlogoawaySettings::MODE_UGLARM: uwe(cfg); break; case TlogoawaySettings::MODE_SOLIDFILL: setSolid(cfg); break; case TlogoawaySettings::MODE_SHAPEXY: if (parambitmapdata) { renderShapeXY(cfg); for (int i=1; i<=cfg->blur; i++) { blurLogotemp(true); } break; } else { return; } case TlogoawaySettings::MODE_SHAPEUGLARM: if (parambitmapdata) { renderShapeUwe(cfg); for (int i=1; i<=cfg->blur; i++) { blurLogotemp(true); } break; } else { return; } } loadLogo(cfg, cfg->bordn_mode==TlogoawaySettings::BM_INTERPOLATE, cfg->borde_mode==TlogoawaySettings::BM_INTERPOLATE, cfg->bords_mode==TlogoawaySettings::BM_INTERPOLATE, cfg->bordw_mode==TlogoawaySettings::BM_INTERPOLATE); }
Jerk::Jerk(Game* game, AssetManager* assetManager) : game(game), dir(0,0) { setSolid(true); setMovable(true); setZHeight(24); float fps = 8; addAnimation("stand_down", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_down.png")); addAnimation("stand_downleft", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_downleft.png")); addAnimation("stand_downright", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_downright.png")); addAnimation("stand_left", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_left.png")); addAnimation("stand_right", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_right.png")); addAnimation("stand_up", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_up.png")); addAnimation("stand_upleft", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_upleft.png")); addAnimation("stand_upright", new Animation(fps, 1, 1, assetManager, "characters/jerk/stand_upright.png")); addAnimation("walk_down", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_down.png")); addAnimation("walk_downleft", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_downleft.png")); addAnimation("walk_downright", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_downright.png")); addAnimation("walk_left", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_left.png")); addAnimation("walk_right", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_right.png")); addAnimation("walk_up", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_up.png")); addAnimation("walk_upleft", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_upleft.png")); addAnimation("walk_upright", new Animation(fps, 1, 4, assetManager, "characters/jerk/walk_upright.png")); }
void StaticObject::setSprite() { this->objSprite.setTexture(assManager->retrieveTexture()); switch (objType){ case 1: this->objSprite.setTextureRect(sf::IntRect(32, 32, 26, 26)); this->isSolid = true; break; case 2: this->objSprite.setTextureRect(sf::IntRect(128, 0, 32, 32)); this->isSolid = true; break; case 3: this->objSprite.setTextureRect(sf::IntRect(32, 32, 26, 26)); this->isSolid = true; break; case 4: this->objSprite.setTextureRect(sf::IntRect(128, 0, 32, 32)); this->isSolid = true; break; case 5: this->objSprite.setTextureRect(sf::IntRect(96, 0, 32, 32)); this->isSolid = false; break; case 6: this->objSprite.setTextureRect(sf::IntRect(128, 0, 32, 32)); this->isSolid = false; break; } setSolid(this->isSolid); setSize(); this->objSprite.setOrigin(objSize.x / 2, objSize.y / 2); this->objSprite.setPosition(sf::Vector2f(position.x, position.y)); }
/** * Sets the size of the area. * @param width The width. * @param height The heigh. */ void Area::setSize(int width, int height) { DEBUG_M("Entering function..."); int old_width = width_; int old_height = height_; #warning ['TODO']: Decide when tiles are unloaded DEBUG_H("\tUnloading dropped tiles..."); // Unload any tiles that are dropped if(width < old_width) { DEBUG_H("\tWidth is less than old width, scrubbing lost tiles..."); for(int y = 0; y < height; y++) { for(int x = old_width; x < width; x++) { delete getTile(x, y); setSolid(x, y, false); } } } if(height < old_height) { DEBUG_H("\tHeight is less than old width, scrubbing lost tiles..."); for(int y = old_height; y < height; y++) { for(int x = 0; x < old_width; x++) { delete getTile(x, y); setSolid(x, y, false); } } } width_ = width; height_ = height; DEBUG_H("\tRealPosition tile space..."); tiles_ = (Tile***)regrowArray_((void***)tiles_, old_width, old_height, width, height); DEBUG_H("\tRealPosition blocker space..."); walkblockers_ = (RigidBody***)regrowArray_((void***)walkblockers_, old_width, old_height, width, height); DEBUG_H("\tAllocated..."); // If we are freeing the Area if(!width || !height) { return; } if(!tiles_) { ERROR("Failed to allocate memory for tile map."); return; } #warning ['TODO']: This function should be split up some more, also shouldn't need to NULL tiles befoure setting them. // Set new tiles to default if(width > old_width) { DEBUG_H("\tWidth is > than old width, making new tiles..."); for(int y = 0; y < height; y++) { for(int x = old_width; x < width; x++) { DEBUG_H("\t\tsetting %dx%d...", x, y); tiles_[x][y] = NULL; walkblockers_[x][y] = NULL; } } } if(height > old_height) { DEBUG_H("\theight is > than old height, making new tiles..."); for(int y = old_height; y < height; y++) { for(int x = 0; x < width; x++) { DEBUG_H("\t\tsetting %dx%d...", x, y); tiles_[x][y] = NULL; walkblockers_[x][y] = NULL; } } } float x_offset = (old_width - width_) * (TILEWIDTH / 2.0f); float z_offset = (old_height - height_) * (TILEWIDTH / 2.0f); for(ChildrenIterator iter = getChildBegin(); iter != getChildEnd(); iter++) { Object* object = dynamic_cast<Object*>(*iter); if(!object) { continue; } object->setX(object->getX() - x_offset); object->setZ(object->getZ() - z_offset); } DEBUG_H("\tFunction finished, area now %d, %d...", getWidth(), getHeight()); }