void ribi::xnz::SpriteEnemyMedium::Shoot(std::vector<boost::shared_ptr<Sprite> >& newSprites)
{
  ++mTimer;
  if (mTimer % mTimeShoot == 0)
  {
    const int missileY = GetY() + GetHeight();
    const int missileX = GetX()
      + (GetWidth() / 2)
      + (mTurretDirection == turretDownLeft  ? -2 : 0)
      + (mTurretDirection == turretDownRight ?  2 : 0);
    const int dx = 0
      + (mTurretDirection == turretDownLeft  ? -1 : 0)
      + (mTurretDirection == turretDownRight ?  1 : 0);
    const int dy = 1;
    boost::shared_ptr<Sprite> missile(new SpriteMissile(missileX,missileY,dx,dy,2));
    newSprites.push_back(missile);

  }
  else
  {
    mTurretDirection = static_cast<EnumTurretDirection>(std::rand() % 3);
    switch(mTurretDirection)
    {
      case turretDownLeft:  SetGraphic(GetSpriteShootDownLeft()); break;
      case turretDown:      SetGraphic(GetSpriteShootDown()); break;
      case turretDownRight: SetGraphic(GetSpriteShootDownRight()); break;
      default: assert(!"Should not get here");
    }
  }
}
Пример #2
0
	// T H E   P L A Y E R (entity)
	Player::Player(int x, int y) : Entity(), 
		FRICTION_GROUND(800),
		FRICTION_AIR(400),
		GRAVITY(300),
                JUMP(120.0f),
                MAXSPEED_GROUND(60.0f),
		MAXSPEED_AIR(100.0f),
		ACCELERATION(800),
                WALLJUMP(160.0f),
		doubleJump(false),
		cling(0),
		onGround(false)
	{
		position = Vector2(x, y);

		AddTag("PLAYER");
		SetCollider(new RectangleCollider(8, 8));

		sprite = new SpriteAnimation("player.png", FILTER_NONE, 8, 8);
		sprite->Add("stand", 0, 0, 0);
		sprite->Add("run", 0, 3, 12.0f);
		sprite->Add("jumpUp", 8, 8, 0);
		sprite->Add("jumpDown", 9, 9, 0);
		sprite->Play("run");

		SetLayer(-1);
		SetGraphic(sprite);

		direction = true;
	}
Пример #3
0
LinkComp::LinkComp (Line* line) {
    if (line != nil) {
        Coord x0, y0, x1, y1;
        float fx0, fy0, fx1, fy1;

        line->GetOriginal(x0, y0, x1, y1);
        Transformer* t = line->GetTransformer();
        Graphic* parent = new Picture(line);
        parent->SetTransformer(nil);

        if (t == nil) {
            fx0 = x0; fy0 = y0; fx1 = x1; fy1 = y1;
        } else {
            t->Transform(float(x0), float(y0), fx0, fy0);
            t->Transform(float(x1), float(y1), fx1, fy1);
        }
        delete line;
        line = new Line(0, 0, 1, 1);
        InitLine(line, fx0, fy0, fx1, fy1);

        PinGraphic* pg1 = new PinGraphic;
        PinGraphic* pg2 = new PinGraphic;
        pg1->SetBrush(psnonebr);
        pg2->SetBrush(psnonebr);
        pg1->Translate(fx0, fy0);
        pg2->Translate(fx1, fy1);

        _conn1 = new PinComp(pg1);
        _conn2 = new PinComp(pg2);

        parent->Append(line, pg1, pg2);
        SetGraphic(parent);
    }
}
Пример #4
0
void LinkComp::Read (istream& in) {
    GraphicComp::Read(in);

    Line* line = new Line(0, 0, 1, 1);

    Transformer* t = ReadTransformer(in);
    line->SetTransformer(t);
    Unref(t);

    _conn1 = (Connector*) unidraw->GetCatalog()->ReadComponent(in);
    _conn2 = (Connector*) unidraw->GetCatalog()->ReadComponent(in);

    Graphic* parent = new Picture;
    parent->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    parent->SetColors(fg, bg);
    parent->SetBrush(ReadBrush(in));

    t = ReadTransformer(in);
    parent->SetTransformer(t);
    Unref(t);

    parent->Append(line, _conn1->GetGraphic(), _conn2->GetGraphic());
    SetGraphic(parent);
}
Пример #5
0
void StencilComp::Read (istream& in) {
    GraphicComp::Read(in);
    Bitmap* image = ReadBitmap(in);
    Bitmap* mask = nil;

    Skip(in);
    int m;
    in >> m;

    if (m == valid_mask) {
        mask = ReadBitmap(in);
    } else if (m == mask_equals_image) {
        mask = image;
    }

    UStencil* stencil = new UStencil(image, mask);
    stencil->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    stencil->SetColors(fg, bg);

    Transformer* t = ReadTransformer(in);
    stencil->SetTransformer(t);
    Unref(t);

    SetGraphic(stencil);
    _filename = ReadString(in);
}
Пример #6
0
	FringeTile::FringeTile()
		: Entity(), tileID(0), sprite(NULL)
	{
		//AddTag("FringeTile");
		sprite = new Sprite();
		SetGraphic(sprite);

		RefreshTexture();
	}
Пример #7
0
void BitmapComp::Read (istream& in) {
    GraphicComp::Read(in);
    Catalog* catalog = unidraw->GetCatalog();
    ClassId id;
    in >> id;
    BitmapGraphic* g = (BitmapGraphic*) catalog->GetCreator()->Create(id);
    g->Read(in);
    SetGraphic(g);
}
Пример #8
0
Graphic* BitmapView::GetGraphic () {
    Graphic* g = GraphicView::GetGraphic();

    if (g == nil) {
        g = GetGraphicComp()->GetGraphic()->Copy();
        SetGraphic(g);
    }
    return g;
}
Пример #9
0
void cGameStateCredits::initialize(){

  SCROLL_MSG msg;
 // msg = ;
  m_msg.push_back(SetGraphic(-1, 1006));//credits graphic
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(SetMessage(-1,F_V20, 180, 0, 0, "Team \"Pacific - Atlantic Gameworks\" "));
  m_msg.push_back(ClearMessage());
  m_msg.push_back(SetGraphic(50, 1009));//large cloud
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(SetMessage(500,F_V20, 0, 70, 0, "www.gameinstitute.com"));
  m_msg.push_back(SetMessage(500,F_V20, 0, 70, 0, "  Game Challenge 10"));
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(SetMessage(-1,F_V20, 0, 0, 0, "Editor Programmed by Chuck Bolin"));
  m_msg.push_back(SetMessage(-1,F_V16, 0, 0, 0, "January 2009"));
  m_msg.push_back(ClearMessage());
  m_msg.push_back(SetGraphic(712, 1010));//credits graphic
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());
  m_msg.push_back(ClearMessage());

  m_timer.initialize(); 
  m_scrollValue = 0;

  //used to show several images in the background
  m_secondTimer.initialize();
  m_secondCount = 0;

  //used for fading
  m_red = 255;//255;
  m_green =255;//255;
  m_blue = 255;//255;
  m_fadeTimer.initialize();
  
}
Пример #10
0
Graphic* LineView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();

    if (graphic == nil) {
        LineComp* lineComp = GetLineComp();
        graphic = lineComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #11
0
	FringeTile::FringeTile(const FringeTile &fringeTile)
		: Entity(fringeTile), tileID(fringeTile.tileID), sprite(NULL)
	{
		//AddTag("FringeTile");
		sprite = new Sprite();
		sprite->blend = fringeTile.sprite->blend;
		SetGraphic(sprite);
		
		RefreshTexture();
	}
Пример #12
0
Graphic* RectView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();
    
    if (graphic == nil) {
        RectComp* rectComp = GetRectComp();
        graphic = rectComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #13
0
Graphic* EllipseView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();

    if (graphic == nil) {
        EllipseComp* ellipseComp = GetEllipseComp();
        graphic = ellipseComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #14
0
Graphic* PinView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();

    if (graphic == nil) {
        PinComp* pinComp = GetPinComp();
        graphic = pinComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #15
0
Graphic* PadView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();

    if (graphic == nil) {
        PadComp* padComp = GetPadComp();
        graphic = padComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #16
0
Graphic* TextView::GetGraphic () {
    TextComp* textComp;
    Graphic* graphic = GraphicView::GetGraphic();

    if (graphic == nil) {
        textComp = GetTextComp();
        graphic = textComp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #17
0
Graphic* TextOvView::GetGraphic () {
    TextOvComp* ovtextcomp;
    Graphic* graphic = OverlayView::GetGraphic();

    if (graphic == nil) {
        ovtextcomp = GetTextOvComp();
        graphic = ovtextcomp->GetGraphic()->Copy();
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #18
0
Graphic* StencilView::GetGraphic () {
    Graphic* graphic = GraphicView::GetGraphic();
    
    if (graphic == nil) {
        StencilComp* stencilComp = GetStencilComp();
        Bitmap* image, *mask;
        stencilComp->GetStencil()->GetOriginal(image, mask);
        graphic = new UStencil(image, mask, stencilComp->GetGraphic());
        SetGraphic(graphic);
    }
    return graphic;
}
Пример #19
0
	// T H E   C O I N (entity)
	Coin::Coin(int x, int y, Sprite *sprite) : Entity(), collected(false), start(x, y), reset(false)
	{
		position = Vector2(x, y);
		SetLayer(-1);
		SetGraphic(sprite);

		AddTag("COIN");
		SetCollider(new RectangleCollider(8, 8));

		while(Collide("WALL"))
		{
			position = Vector2(((int) rand() % 160 / 8) * 8 + 4, ((int) rand() % 120 / 8) * 8 + 4);
			start = Vector2(position.x, position.y);
		}
	}
Пример #20
0
ViewerView::ViewerView (GraphicView* g, UPage* page, Grid* grid, Viewer* v) {
    Picture* p = new Picture;

    if (grid != nil) {
        p->Append(grid->GetGraphic());
    }
    p->Append(page->GetGraphic());
    p->Append(_vg = new ViewerGraphic(g));

    SetGraphic(p);
    _vg->SetTag(this);

    _viewer = v;
    Update();
}
Пример #21
0
	SelectionImage::SelectionImage(const std::string &image, int size)
		: Entity()
	{
		Sprite *sprite = NULL;
		SetGraphic(sprite = new Sprite(image));
		if (sprite->width > sprite->height)
		{
			sprite->height = (sprite->height/sprite->width) * size;
			sprite->width = size;
		}
		else
		{
			sprite->width = (sprite->width/sprite->height) * size;
			sprite->height = size;
		}
	}
Пример #22
0
void ArrowLineComp::Read (istream& in) {
    LineComp::Read(in);
    Line* line = GetLine();
    Coord x0, y0, x1, y1;
    int h, t;
    float scale;
    
    line->GetOriginal(x0, y0, x1, y1);

    in >> h >> t >> scale;

    ArrowLine* arrow = new ArrowLine(x0, y0, x1, y1, h, t, scale, line);
    arrow->SetPattern(ReadPattern(in));

    SetGraphic(arrow);
    delete line;
}
Пример #23
0
void ArrowMultiLineComp::Read (istream& in) {
    MultiLineComp::Read(in);
    SF_MultiLine* ml = GetMultiLine();
    Coord* x, *y;
    int count, h, t;
    float scale;

    const Coord* cx, * cy;
    count = ml->GetOriginal(cx, cy);
    x = (Coord*)cx; y = (Coord*)cy;

    in >> h >> t >> scale;

    ArrowMultiLine* aml = new ArrowMultiLine(x, y, count, h, t, scale, ml);

    SetGraphic(aml);
    delete ml;
}
Пример #24
0
void ArrowSplineComp::Read (istream& in) {
    SplineComp::Read(in);
    SFH_OpenBSpline* spl = GetSpline();
    Coord* x, *y;
    int count, h, t;
    float scale;

    const Coord* cx, * cy;
    count = spl->GetOriginal(cx, cy);
    x = (Coord*)cx; y = (Coord*)cy;

    in >> h >> t >> scale;

    ArrowOpenBSpline* as = new ArrowOpenBSpline(x, y, count, h, t, scale, spl);

    SetGraphic(as);
    delete spl;
}
Пример #25
0
void LineComp::Read (istream& in) {
    GraphicComp::Read(in);
    Coord x0, y0, x1, y1;

    in >> x0 >> y0 >> x1 >> y1;
    Line* line = new Line(x0, y0, x1, y1);

    line->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    line->SetColors(fg, bg);
    line->SetBrush(ReadBrush(in));

    Transformer* t = ReadTransformer(in);
    line->SetTransformer(t);
    Unref(t);

    SetGraphic(line);
}
Пример #26
0
Player::Player(Vector2 pos)
    : Entity()
{
    position = pos;
    SetLayer(-10);

    AddTag("Player");

    SetCollider(new RectangleCollider(40, 64));

    sprite = new Sprite("Graphics/Player.png", FILTER_NONE, 64, 64);
    SetGraphic(sprite);

    speed = 100.0f;
    gravity = 0.25f;
    velocity = Vector2(0.0f, 0.0f);
    jump = 8.0f;
    maxSpeed = 4.0f;
    leanAmount = 1.5f;
}
Пример #27
0
void RectComp::Read (istream& in) {
    GraphicComp::Read(in);
    Coord x0, y0, x1, y1;

    in >> x0 >> y0 >> x1 >> y1;
    SF_Rect* rect = new SF_Rect(x0, y0, x1, y1);

    rect->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    rect->SetColors(fg, bg);
    rect->SetBrush(ReadBrush(in));
    rect->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    rect->SetTransformer(t);
    Unref(t);

    SetGraphic(rect);
}
Пример #28
0
void EllipseComp::Read (istream& in) {
    GraphicComp::Read(in);
    Coord x0, y0;
    int r1, r2;

    in >> x0 >> y0 >> r1 >> r2;
    SF_Ellipse* ellipse = new SF_Ellipse(x0, y0, r1, r2);

    ellipse->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    ellipse->SetColors(fg, bg);
    ellipse->SetBrush(ReadBrush(in));
    ellipse->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    ellipse->SetTransformer(t);
    Unref(t);

    SetGraphic(ellipse);
}
Пример #29
0
void TextComp::Read (istream& in) {
    GraphicComp::Read(in);
    int lineHt;

    in >> lineHt;
    char* string = ReadString(in);
    TextGraphic* text = new TextGraphic(string, lineHt);
    delete string;

    text->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    text->SetColors(fg, bg);
    text->SetFont(ReadFont(in));

    Transformer* t = ReadTransformer(in);
    text->SetTransformer(t);
    Unref(t);

    SetGraphic(text);
}
Пример #30
0
void PadComp::Read (istream& in) {
    Connector::Read(in);
    Coord l, b, r, t;
    int mobility;

    in >> l >> b >> r >> t >> mobility;
    PadGraphic* pad = new PadGraphic(l, b, r, t);
    _mobility = Mobility(mobility);
    
    pad->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    pad->SetColors(fg, bg);
    pad->SetBrush(ReadBrush(in));

    Transformer* xf = ReadTransformer(in);
    pad->SetTransformer(xf);
    Unref(xf);

    SetGraphic(pad);
}