Beispiel #1
0
bool Player::canMoveRight(bool s = false) {
	bottomLeft = VECTOR2(getX(), getY() - 1 + getHeight() * getScale());
	bottomRight = VECTOR2(getX() - 1 + getWidth() * getScale(), getY() - 1 + getHeight() * getScale());
	topLeft = VECTOR2(getX(), getY());
	topRight = VECTOR2(getX() - 1 + getWidth() * getScale(), getY());
	return !(levelController->getTile(topRight.x + levelController->getMapX() * -1.0 + 1, topRight.y)->isSolid(s) || levelController->getTile(bottomRight.x + levelController->getMapX() * -1.0 + 1, bottomRight.y)->isSolid(s));
}
Beispiel #2
0
    //--------------------------------------------------------------------------------
    /// @brief      三角形を連続でリスト描画する(ワイヤー)
    /// @param[in]  verticies       頂点配列
    /// @param[in]  indicies        インデックス配列
    /// @param[in]  triangleNum     三角形の数
    /// @return     なし
    //--------------------------------------------------------------------------------
    void Renderer::DrawWiredTriangleList( const VECTOR4 verticies[], const unsigned int indicies[], unsigned int triangleNum )
    {
        assert( NULL != m_pGraphics );

        MATRIX4x4 mWVP = m_mWorld;

        Multiply( mWVP, m_mView );
        Multiply( mWVP, m_mProjection );

        const unsigned int polygonVerticies = 3;

        for( unsigned int triangleCnt = 0; triangleCnt < triangleNum; ++triangleCnt )
        {
            VECTOR4 vertex0 = verticies[indicies[triangleCnt * polygonVerticies]];
            VECTOR4 vertex1 = verticies[indicies[triangleCnt * polygonVerticies + 1]];
            VECTOR4 vertex2 = verticies[indicies[triangleCnt * polygonVerticies + 2]];

            Transform( vertex0, mWVP );
            Transform( vertex1, mWVP );
            Transform( vertex2, mWVP );
            m_pGraphics->DrawLine( VECTOR2( vertex0.x / vertex0.w, vertex0.y / vertex0.w ), VECTOR2( vertex1.x / vertex1.w, vertex1.y / vertex1.w ), m_color );
            m_pGraphics->DrawLine( VECTOR2( vertex1.x / vertex1.w, vertex1.y / vertex1.w ), VECTOR2( vertex2.x / vertex2.w, vertex2.y / vertex2.w ), m_color );
            m_pGraphics->DrawLine( VECTOR2( vertex2.x / vertex2.w, vertex2.y / vertex2.w ), VECTOR2( vertex0.x / vertex0.w, vertex0.y / vertex0.w ), m_color );
        }
    }
ItemController::ItemController(Graphics *graphics, TextureManager* iTxt) {
	itemTexture = new TextureManager();
	if (!itemTexture->initialize(graphics, TEXTURE_ITEM))
		throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing item texture"));
	crateList = new std::list<Crate*>();
	itemList = std::vector<Item*>();
	//init crate location first
	levelCrateLoc[0] = new std::list<VECTOR2>();
	levelCrateLoc[0]->push_back(VECTOR2(321, 568));		// crate 1.1
	levelCrateLoc[0]->push_back(VECTOR2(1152, 250));	// crate 2.1
	levelCrateLoc[0]->push_back(VECTOR2(2447, 250));	//crate 2.5.1
	levelCrateLoc[0]->push_back(VECTOR2(2688, 668));	// crate 3.1 
	levelCrateLoc[0]->push_back(VECTOR2(2815, 602));	// crate 3.2
	//init crate item second
	levelCrateItemType[0] = new std::list<int>();
	levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun);	// crate 1.1
	levelCrateItemType[0]->push_back(itemControllerNS::ItemType::shotGun);		// crate 2.1

	levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun);	// crate 2.5.1
	levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun);	// crate 3.1
	levelCrateItemType[0]->push_back(itemControllerNS::ItemType::shotGun);		// crate 3.2
	itemIconTexture = iTxt;
	gunTexture = new TextureManager();
	if (!gunTexture->initialize(graphics, TEXTURE_GUNS))
		throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing gun texture"));
	gunImage = new Image();
	gunImage->initialize(graphics, itemControllerNS::GUN_TEXTURE_WIDTH, itemControllerNS::GUN_TEXTURE_HEIGHT, 1, gunTexture);
	itemIconTexture = new TextureManager();
	if (!itemIconTexture->initialize(graphics, ITEM_ICON_TEXTURE))
		throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing item icon texture"));
}
Beispiel #4
0
// Initialize the game
void Purgatory::initialize(HWND hwnd)
{
	 Game::initialize(hwnd); // throws GameError
	 // 
	 scoreFont.initialize(graphics,25,false,false,"score");

	 if (!BgTexture.initialize(graphics,"ArtAssets\\Background.png"))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializingbackground"));
	//
	 if (!PlayerTextures.initialize(graphics,"ArtAssets\\Jeramiah.png"))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing player"));
	 //
	  if (!enemyTexture.initialize(graphics,"pictures\\ghoul.png"))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ENEMY"));
	//
	  for(int j=0;j<2;j++)
	  {
		if (!background[j].initialize(this, BgNS::WIDTH, BgNS::HEIGHT, &BgTexture))
		  throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bg"));
	  }
	//
	 if (!player1.initialize(this, BumNS::WIDTH, BumNS::HEIGHT, BumNS::TEXTURE_COLS, &PlayerTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bum"));
	 //
	 for(int i =0;i<3;i++)
	 {
	 if (!enemy[i].initialize(this, BumNS::WIDTH, BumNS::HEIGHT, BumNS::TEXTURE_COLS, &enemyTexture))
		throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing enemy"));
	 	 

	 enemy[i].setFrames(enemyNS::ENEMY_START_FRAME,enemyNS::ENEMY_END_FRAME);
	 enemy[i].setCurrentFrame(enemyNS::ENEMY_START_FRAME);
	 enemy[i].setColorFilter(SETCOLOR_ARGB(255,255,255,255));
	 enemy[i].setCollisionType(box);
	 enemy[i].setEdge(ENEMY);
	
	 enemy[i].setX(650);
	 enemy[i].setY(350);
	 }
	 enemy[0].setVelocity(VECTOR2(0,enemyNS::SPEED1));enemy[1].seteID(1);
	 enemy[1].setVelocity(VECTOR2(0,enemyNS::SPEED2));enemy[2].seteID(2);
	 //
	 player1.setFrames(BumNS::BUM_START_FRAME, BumNS::BUM_END_FRAME);
	 player1.setCurrentFrame(BumNS::BUM_START_FRAME);
	 player1.setColorFilter(SETCOLOR_ARGB(255,255,255,255));
	 player1.setCollisionType(box);
	  player1.setEdge(PLAYER);
	//
	 player1.setX(50);
	 player1.setY(350);
	 player1.setVelocity(VECTOR2(BumNS::JUMP_HEIGHT,BumNS::SPEED));
	 //
	playerScore=0;
	background[0].setX(0);
	background[1].setX(GAME_WIDTH-0);
	background[0].setY(0);
	background[1].setY(0);
	return;
}
Beispiel #5
0
//=============================================================================
// Initializes the game
// Throws GameError on error
//=============================================================================
void Spacewar::initialize(HWND hwnd)
{
    Game::initialize(hwnd); // throws GameError

    // nebula texture
    if (!nebulaTexture.initialize(graphics,NEBULA_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula texture"));

    // main game textures
    if (!gameTextures.initialize(graphics,TEXTURES_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing game textures"));

    // nebula image
    if (!nebula.initialize(graphics,0,0,0,&nebulaTexture))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula"));

    // planet
    if (!planet.initialize(this, planetNS::WIDTH, planetNS::HEIGHT, 2, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing planet"));

    // ship
    if (!ship1.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, true))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship1"));
    ship1.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
    ship1.setCurrentFrame(shipNS::SHIP1_START_FRAME);
    ship1.setX(GAME_WIDTH/4);
    ship1.setY(GAME_HEIGHT/4);
    ship1.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
    // ship2
    if (!ship2.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, true))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship2"));
    ship2.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
    ship2.setCurrentFrame(shipNS::SHIP2_START_FRAME);
    ship2.setX(GAME_WIDTH - GAME_WIDTH/4);
    ship2.setY(GAME_HEIGHT/4);
    ship2.setVelocity(VECTOR2(-shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
    //ship3 initalization. Do not rotate, start pointing north. This ship is controlled by the arrow keys.
    //ship3 ignores direction and will move in the direction of the key
    if (!ship3.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, false))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship3"));
    ship3.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
    ship3.setCurrentFrame(shipNS::SHIP1_START_FRAME);
    ship3.setX(GAME_WIDTH - GAME_WIDTH/4);
    ship3.setY(GAME_HEIGHT - GAME_HEIGHT/4);
    ship3.setDegrees(270);
    //ship3.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
    //ship4 initalization. Do not rotate, start pointing north. This ship is controlled by WASD
    //ship4 will rotate with A and D, and will move forward based on direction on W, and move backward based on direction on S.
    if (!ship4.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, false))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship4"));
    ship4.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
    ship4.setCurrentFrame(shipNS::SHIP2_START_FRAME);
    ship4.setX(GAME_WIDTH/4);
    ship4.setY(GAME_HEIGHT - GAME_HEIGHT/4);
    ship4.setDegrees(270);
    //ship4.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)

    return;
}
Beispiel #6
0
//=============================================================================
// コンストラクタ
//=============================================================================
CObject2DData::CObject2DData(void)
{
	object_2d_ = NULL;
	texture_name_ = "";
	position_ = VECTOR2(0.0f,0.0f);
	scale_ = VECTOR2(1.0f,1.0f);
	rotation_ = 0.0f;
	matrix_.SetIdentity();
}
Beispiel #7
0
//=============================================================================
// Draw DirectX line from X1,Y1 to X2,Y2. 
//    width defauts to 1. 
//    color defaults to graphicsNS::WHITE.
//=============================================================================
void Graphics::drawLine(float x1, float y1, float x2, float y2, float width, COLOR_ARGB color)
{
    VECTOR2 endpoints[] = { VECTOR2(x1, y1), VECTOR2(x2, y2) };

    if (width < 0.1f)
        width = 0.1f;
    line->SetWidth(width);              // SetWidth must be called before Begin
    line->Begin();                      // begin drawing lines
    line->Draw(endpoints, 2, color);    // draw line, 2 vertices
    line->End();                        // end drawing lines
}
Beispiel #8
0
//=============================================================================
// Initializes the game
// Throws GameError on error
//=============================================================================
void Spacewar::initialize(HWND hwnd)
{
    Game::initialize(hwnd); // throws GameError
	this->counterText = new TextDX();

	// initialize DirectX fonts
    // 15 pixel high Arial
    if(this->counterText->initialize(graphics, 15, true, false, "Arial") == false)
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing DirectX font"));

    // nebula texture
    if (!nebulaTexture.initialize(graphics,NEBULA_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula texture"));

    // main game textures
    if (!gameTextures.initialize(graphics,TEXTURES_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing game textures"));

    // nebula image
    if (!nebula.initialize(graphics,0,0,0,&nebulaTexture))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula"));

    // planet
    if (!planet.initialize(this, planetNS::WIDTH, planetNS::HEIGHT, 2, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing planet"));

    // ship
    if (!ship1.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship1"));
    ship1.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
    ship1.setCurrentFrame(shipNS::SHIP1_START_FRAME);
    ship1.setX(GAME_WIDTH/4);
    ship1.setY(GAME_HEIGHT/4);
    ship1.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
    // ship2
    if (!ship2.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship2"));
    ship2.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
    ship2.setCurrentFrame(shipNS::SHIP2_START_FRAME);
    ship2.setX(GAME_WIDTH - GAME_WIDTH/4);
    ship2.setY(GAME_HEIGHT/4);
    ship2.setVelocity(VECTOR2(-shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
	//ship3
	if (!ship3.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship3"));
    ship3.setFrames(shipNS::SHIP3_START_FRAME, shipNS::SHIP3_END_FRAME);
    ship3.setCurrentFrame(shipNS::SHIP3_START_FRAME);
    ship3.setX(GAME_WIDTH - GAME_WIDTH/6);
    ship3.setY(GAME_HEIGHT/6);
    ship3.setVelocity(VECTOR2(-shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)

    return;
}
Beispiel #9
0
//=============================================================================
// Compute corners of rotated box, projection edges and min and max projections
// 0---1  corner numbers
// |   |
// 3---2
//=============================================================================
void Entity::computeRotatedBox()
{
    if(rotatedBoxReady)
        return;
    float projection;

    VECTOR2 rotatedX(cos(spriteData.angle), sin(spriteData.angle));
    VECTOR2 rotatedY(-sin(spriteData.angle), cos(spriteData.angle));

    const VECTOR2 *center = getCenter();
    corners[0] = *center + rotatedX * ((float)edge.left*getScale())  +
                           rotatedY * ((float)edge.top*getScale());
    corners[1] = *center + rotatedX * ((float)edge.right*getScale()) + 
                           rotatedY * ((float)edge.top*getScale());
    corners[2] = *center + rotatedX * ((float)edge.right*getScale()) + 
                           rotatedY * ((float)edge.bottom*getScale());
    corners[3] = *center + rotatedX * ((float)edge.left*getScale())  +
                           rotatedY * ((float)edge.bottom*getScale());

    // corners[0] is used as origin
    // The two edges connected to corners[0] are used as the projection lines
    edge01 = VECTOR2(corners[1].x - corners[0].x, corners[1].y - corners[0].y);
    graphics->Vector2Normalize(&edge01);
    edge03 = VECTOR2(corners[3].x - corners[0].x, corners[3].y - corners[0].y);
    graphics->Vector2Normalize(&edge03);

    // this entities min and max projection onto edges
    projection = graphics->Vector2Dot(&edge01, &corners[0]);
    edge01Min = projection;
    edge01Max = projection;
    // project onto edge01
    projection = graphics->Vector2Dot(&edge01, &corners[1]);
    if (projection < edge01Min)
        edge01Min = projection;
    else if (projection > edge01Max)
        edge01Max = projection;
    // project onto edge03
    projection = graphics->Vector2Dot(&edge03, &corners[0]);
    edge03Min = projection;
    edge03Max = projection;
    projection = graphics->Vector2Dot(&edge03, &corners[3]);
    if (projection < edge03Min)
        edge03Min = projection;
    else if (projection > edge03Max)
        edge03Max = projection;

    rotatedBoxReady = true;
}
Beispiel #10
0
void Level::addHeart(int levelX, int levelY)
{
	Heart* newHeart = new Heart();
	newHeart->initialize(gamePointer, heartNS::SIZE, heartNS::SIZE, 1, &heartTexture);
	newHeart->setPosition(VECTOR2(levelX, levelY));
	hearts.push_back(newHeart);
}
Beispiel #11
0
Bool CTile::Initialise(Int8* _spritesheet, VECTOR2 _pos, ETileType _type)
{
	if (0 == m_sprite)
	{
		m_sprite = Sprite::CreateSprite(_spritesheet, 0, false);
		assert(m_sprite);
		m_sprite->AddRef();
	}
	m_sprite->SetScale(TILE_WIDTH, TILE_HEIGHT);
	m_clips.w = TILE_WIDTH;
	m_clips.h = TILE_HEIGHT;
	m_pos = _pos;
	m_type = _type;

	SetType(m_type);

	if (0 == m_actor)
	{
		m_actor = Physics::CreateStaticActor(m_pos, VECTOR2(static_cast<Float32>(TILE_WIDTH),static_cast<Float32>(TILE_HEIGHT)));
		assert(m_actor);
	}
	m_actor->SetActive(false);
	m_actor->AddRef();
	
	m_screenW = Renderer::activeRenderer->GetWidth();
	m_screenH = Renderer::activeRenderer->GetHeight();

	return true;
}
Beispiel #12
0
Bool CTile::Initialise(Int8* _spritesheet, VECTOR2 _pos, ETileType _type)
{
	m_sprite = Sprite::CreateSprite(_spritesheet, 0, false);
	assert(m_sprite);
	m_sprite->AddRef();
	m_sprite->SetScale(TILE_WIDTH, TILE_HEIGHT);
	m_clips.w = TILE_WIDTH;
	m_clips.h = TILE_HEIGHT;
	m_pos = _pos;

	SetType(_type);

	m_actor = Physics::CreateStaticActor(m_pos, VECTOR2(static_cast<Float32>(TILE_WIDTH),static_cast<Float32>(TILE_HEIGHT)));
	assert(m_actor);

	for (UInt16 i = 0; i < 8; ++i) { m_around[i] = _pos; }

	m_around[0].x -= TILE_WIDTH; // left
	m_around[1].x -= TILE_WIDTH; // top left
	m_around[1].y -= TILE_HEIGHT; 
	m_around[2].y -= TILE_HEIGHT; // top
	m_around[3].x += TILE_WIDTH; // top right
	m_around[3].y -= TILE_HEIGHT;
	m_around[4].x += TILE_WIDTH; // right
	m_around[5].x += TILE_WIDTH; // bottom right
	m_around[5].y += TILE_HEIGHT;
	m_around[6].y += TILE_HEIGHT; // bottom
	m_around[7].x -= TILE_WIDTH; // bottom left
	m_around[7].y += TILE_HEIGHT; 
	
	m_screenW = Renderer::activeRenderer->GetWidth();
	m_screenH = Renderer::activeRenderer->GetHeight();

	return true;
}
Beispiel #13
0
Player::Player(sf::Uint8 c) : Actor() {
    pos = VECTOR2(50,100);
    anchor = 0;
    frame = 0;
    radius = 15;
    color = c;
    state_ = nullptr;
    // Disk *d = new Disk();
    // d->radius = radius;
    // shape = d;

    nPol = new Polygon();
    nPol->points.emplace_back(radius,radius);
    nPol->points.emplace_back(-radius,radius);
    nPol->points.emplace_back(-radius,-radius);
    nPol->points.emplace_back(radius,-radius);
    shape = nPol;

    sPol = new Polygon();
    sPol->points.emplace_back(radius*2,radius*2);
    sPol->points.emplace_back(-radius*2,radius*2);
    sPol->points.emplace_back(-radius*2,-radius*2);
    sPol->points.emplace_back(radius*2,-radius*2);

    accel = 0.3;
    maxVel = 2.25;
    deccel = 0.15;
    classNum = 2;

    rotTarget = 0;

    res();
}
Beispiel #14
0
void Level::addBow(int tileX, int tileY, BowType type)
{
	Bow *bow = new Bow();
	bow->initialize(gamePointer, bowNS::SIZE, bowNS::SIZE, 1, &bowTexture[type], type);
	//center the bow on the tile
	bow->setPosition(VECTOR2(tileX * tileSize - tileSize/2 - bowNS::SIZE/2, tileY * tileSize - tileSize/2- bowNS::SIZE/2));
	bows.push_back(bow);
}
Beispiel #15
0
void TerrainElement::generateSideEquations()
{
	corners[3] = VECTOR2(this->getCenterX() + cos(this->getRadians())*edge.right - sin(this->getRadians())*edge.top, this->getCenterY() + cos(this->getRadians())*edge.top + sin(this->getRadians())*edge.right);
	corners[2] = VECTOR2(this->getCenterX() + cos(this->getRadians())*edge.right - sin(this->getRadians())*edge.bottom, this->getCenterY() + cos(this->getRadians())*edge.bottom + sin(this->getRadians())*edge.right);
	corners[1] = VECTOR2(this->getCenterX() + cos(this->getRadians())*edge.left - sin(this->getRadians())*edge.bottom, this->getCenterY() + cos(this->getRadians())*edge.bottom + sin(this->getRadians())*edge.left);
	corners[0] = VECTOR2(this->getCenterX() + cos(this->getRadians())*edge.left - sin(this->getRadians())*edge.top, this->getCenterY() + cos(this->getRadians())*edge.top + sin(this->getRadians())*edge.left);
	for(int i(0); i < 4; i++)
	{
		D3DXVECTOR2 tempDist = corners[(3+i)%4]-corners[i];
		sides[i] = myLines::Ray(corners[i], tempDist, (i%2?getHeight():getWidth()));
	}
	
	/*sides[0] = myLines::Ray(corners[0], corners[3]-corners[0],this->getWidth());
	sides[1] = myLines::Ray(corners[1], corners[0]-corners[1],this->getHeight());
	sides[2] = myLines::Ray(corners[2], corners[2]-corners[1],this->getWidth());
	sides[3] = myLines::Ray(corners[3], corners[3]-corners[2],this->getHeight());*/
}
Beispiel #16
0
    //--------------------------------------------------------------------------------
    /// @brief      インデックスを使用して線を連続描画する
    /// @param[in]  vertices    頂点配列
    /// @param[in]  indices     インデックス配列
    /// @param[in]  lineNum     線の数
    /// @param[in]  color       色
    /// @return     なし
    //--------------------------------------------------------------------------------
    void Renderer::DrawLineList( const VECTOR4 verticies[], const unsigned int indicies[], unsigned int lineNum )
    {
        assert( NULL != m_pGraphics );

        MATRIX4x4 mWVP = m_mProjection;

        Multiply( mWVP, m_mView );
        Multiply( mWVP, m_mWorld );

        for( unsigned int lineCnt = 0; lineCnt < lineNum; ++lineCnt )
        {
            VECTOR4 start   = verticies[indicies[lineCnt * 2]];
            VECTOR4 end     = verticies[indicies[lineCnt * 2 + 1]];

            Transform( start, mWVP );
            Transform( end, mWVP );
            m_pGraphics->DrawLine( VECTOR2( start.x / start.w, start.y / start.w ), VECTOR2( end.x / end.w, end.y / end.w ), m_color );
        }
    }
Beispiel #17
0
void BACKGROUND::draw() {
	double oldCamX = camera.pos.x;
	int camX = (int)(oldCamX / parallax) % (int)image->size.x;
	camera.pos.x = camX;

	for (int x=0; x<(SCREENW/image->size.x) + 2; x++) {
		image->draw(VECTOR2(x * image->size.x, yPos));
	}

	camera.pos.x = oldCamX;
}
Beispiel #18
0
void SCORE::draw() {
	int width = font->size.x / 10;
	int height = font->size.y;

	if (score == 0) {
		font->drawRegion(VECTOR2(SCREENW - 12 - width, 12), VECTOR2(0, 0), VECTOR2(width, height));

		return;
	}

	int current_digit = 1;
	int render_score = score;
	while (render_score > 0) {
		int digit = render_score % 10;
		render_score /= 10;

		font->drawRegion(VECTOR2(SCREENW - 12 - current_digit * width * (4/5.0), 12), VECTOR2(width * digit, 0), VECTOR2(width, height));
		current_digit++;
	}
}
Beispiel #19
0
//=============================================================================
// 初期化処理
//=============================================================================
bool CUserNumber::Init( void )
{
	// オブジェクトビルボードの生成
	CBillboard* object_bill = new CBillboard(interface_manager_->graphic_manager()->device_holder());
	object_bill->set_size(VECTOR2(10.0f,10.0f));
	object_bill->Set();

	// オブジェクトリストに追加
	object_key_ = interface_manager_->graphic_manager()->object_manager()->object_3d_manager()->AddList(object_bill);
	return true;
}
//=============================================================================
// update
// typically called once per frame
// frameTime is used to regulate the speed of movement and animation
//=============================================================================
void Vision::update(float frameTime, int& currentRoom)
{
	timeSinceShot += frameTime;
    Entity::update(frameTime);
    //spriteData.angle += frameTime * visionNS::ROTATION_RATE;  // rotate the ship
    spriteData.x += frameTime * velocity.x;         // move ship along X 
    spriteData.y += frameTime * velocity.y;         // move ship along Y

	velocity = VECTOR2(0, 0);

}
Beispiel #21
0
void Player::res() {
    for (int i=0;i<6;i++) {
        b[i] = true;
    }
    bulletCount = 6;
    shotTime = 0;
    velocity = VECTOR2(0,0);
    dead = false;
    splat = false;
    dodgeTime = 0;
    newState(new WalkState());
}
Beispiel #22
0
void Purgatory::roundStart()
{
	 for(int i =0;i<3;i++)
	 {
	 enemy[i].setX(GAME_WIDTH);
	 enemy[i].setY(350);
	 }
	 enemy[0].setVelocity(VECTOR2(0,enemyNS::SPEED1));	
	 enemy[1].setVelocity(VECTOR2(0,enemyNS::SPEED2));
	 enemy[2].setVelocity(VECTOR2(0,enemyNS::SPEED3));	
	 enemy[3].setVelocity(VECTOR2(0,enemyNS::SPEED4));	
	 //
	 background[0].setmoving(false);
	 background[1].setmoving(false);
	 //
	 player1.setX(50);
	 player1.setY(350);
	 player1.setVelocity(VECTOR2(0,BumNS::SPEED));
	 roundOver = false;
	 player1.setjump(false);
	 player1.setonground(true);
}
Beispiel #23
0
//=============================================================================
// Initializes the game
// Throws GameError on error
//=============================================================================
void Spacewar::initialize(HWND hwnd)
{
    Game::initialize(hwnd); // throws GameError

    // nebula texture
    if (!nebulaTexture.initialize(graphics,NEBULA_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula texture"));

    // main game textures
    if (!gameTextures.initialize(graphics,TEXTURES_IMAGE))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing game textures"));

    // nebula image
    if (!nebula.initialize(graphics,0,0,0,&nebulaTexture))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula"));

    // planet
    if (!planet.initialize(this, planetNS::WIDTH, planetNS::HEIGHT, 2, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing planet"));

    // ship
    if (!ship1.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship1"));
    ship1.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
    ship1.setCurrentFrame(shipNS::SHIP1_START_FRAME);
    ship1.setX(GAME_WIDTH/4);
    ship1.setY(GAME_HEIGHT/4);
    ship1.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
    // ship2
    if (!ship2.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship2"));
    ship2.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
    ship2.setCurrentFrame(shipNS::SHIP2_START_FRAME);
    ship2.setX(GAME_WIDTH - GAME_WIDTH/4);
    ship2.setY(GAME_HEIGHT/4);
    ship2.setVelocity(VECTOR2(-shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)

    return;
}
Beispiel #24
0
void CMeshCylinder::Init(void)
{
	IndexNum =		(int)(SUM_INDEX(PanelNum.x,PanelNum.y));
	VertexNum =		(int)((PanelNum.x+1)*(PanelNum.y+1));
	PolygonNum =	(int)(((PanelNum.x*2)*PanelNum.y)+((PanelNum.y-1)*4));

	Vtx = new VECTOR3[VertexNum];
	Tex = new VECTOR2[VertexNum];
	Nor = new VECTOR3[VertexNum];

	float angle = (360.0f/PanelNum.x)*(PI/180.0f);

	for(int LoopZ=0,num=0;LoopZ<PanelNum.y+1;LoopZ++)
	{
		for(int LoopX=0;LoopX<PanelNum.x+1;LoopX++)
		{
			Vtx[num] = VECTOR3(cosf(angle*LoopX)*Radius,PanelHeight*LoopZ,sinf(angle*LoopX)*Radius);
			Tex[num] = VECTOR2((TexDiv.x/PanelNum.x)*LoopX,(TexDiv.x/PanelNum.x)*LoopZ);
			
			Nor[num] = VECTOR3(sinf(angle*LoopX),0.0f,cosf(angle*LoopX));
			Nor[num].Normalize();
			_Color = COLOR(1.0f,1.0f,1.0f,1.0f);
			num++;
		}
	}

	int LoopX=0;
	int VtxNo = 0;
	Index = new int[IndexNum];
	
	for(int LoopZ=0;LoopZ<PanelNum.y;LoopZ++)
	{
		if(LoopZ != 0)
		{
			LoopX = 0;
			Index[VtxNo] = (int)((LoopZ*(PanelNum.x+1))+(((LoopX+1)%2)*(PanelNum.x+1)+(LoopX/2)));
			VtxNo++;
		}
		for(LoopX=0;LoopX<(PanelNum.x+1)*2;LoopX++)
		{
			Index[VtxNo] = (int)((LoopZ*(PanelNum.x+1))+(((LoopX+1)%2)*(PanelNum.x+1)+(LoopX/2)));
			VtxNo++;
		}
		if(LoopZ==PanelNum.y-1)
		{
			break;
		}
		Index[VtxNo] = Index[VtxNo-1];
		VtxNo++;
	}
}
Beispiel #25
0
void Player::collideWith(std::shared_ptr<Bullet> bul) {
    if (!splat) {
        if (bul->time > 8 && bul->live) {
            if (frame < 8 && bul->color != color) {
                newState(new DeadState());
                // game->setRestartTime(60);
                // game->addPoint(1-(color/2));
                sfx.push_back(2);
                game->setShake(10);
                bul->setDead(true);
                splat = true;
            } else if (frame >= 12) {
                bul->live = false;
                if (bul->getPos().x > pos.x) {
                    bul->setVelocity(VECTOR2(0.5,-3));
                    bul->setAngle(180);
                } else {
                    bul->setVelocity(VECTOR2(-0.5,-3));
                    bul->setAngle(0);
                }
                game->setShake(5);
            }
        } else if (bul->step == 2 && bulletCount < 6) {
            bul->setDead(true);
            bulletCount++;
            if(!b[0]) {
                b[0] = true;
            } else {
                for (int i=1;i<6;i++) {
                    if(!b[6-i]) {
                        b[6-i] = true;
                        break;
                    }
                }
            }
        }
    }
}
Beispiel #26
0
void CMeshField::Init(void)
{
	IndexNum =		(int)(SUM_INDEX(PanelNum.x,PanelNum.y));
	VertexNum =		(int)((PanelNum.x+1)*(PanelNum.y+1));
	PolygonNum =	(int)(((PanelNum.x*2)*PanelNum.y)+((PanelNum.y-1)*4));

	Vtx = new VECTOR3[VertexNum];
	Tex = new VECTOR2[VertexNum];
	Nor = new VECTOR3[VertexNum];
	

	float OffsetX = (PanelNum.x*PanelSize.x)/2;
	float OffsetZ = (PanelNum.y*PanelSize.y)/2;

	for(int LoopZ=0,num=0;LoopZ<PanelNum.y+1;LoopZ++)
	{
		for(int LoopX=0;LoopX<PanelNum.x+1;LoopX++)
		{
			Vtx[num] = VECTOR3(OffsetX+(-PanelSize.x*LoopX),0,-OffsetZ+(PanelSize.y*LoopZ));
			Tex[num] = VECTOR2((float)LoopX,(float)LoopZ);
			Nor[num] = VECTOR3(0,1.0f,0);
			_Color = COLOR(1.0f,1.0f,1.0f,1.0f);
			num++;
		}
	}

	int LoopX=0;
	int VtxNo = 0;
	Index = new int[IndexNum];
	for(int LoopZ=0;LoopZ<PanelNum.y;LoopZ++)
	{
		if(LoopZ != 0)
		{
			LoopX = 0;
			Index[VtxNo] = (int)((LoopZ*(PanelNum.x+1))+(((LoopX+1)%2)*(PanelNum.x+1)+(LoopX/2)));
			VtxNo++;
		}
		for(LoopX=0;LoopX<(PanelNum.x+1)*2;LoopX++)
		{
			Index[VtxNo] = (int)((LoopZ*(PanelNum.x+1))+(((LoopX+1)%2)*(PanelNum.x+1)+(LoopX/2)));
			VtxNo++;
		}
		if(LoopZ==PanelNum.y-1)
		{
			break;
		}
		Index[VtxNo] = Index[VtxNo-1];
		VtxNo++;
	}
}
Beispiel #27
0
void Jack::stateChange() {
	// Start of state change
	VECTOR2 v = VECTOR2(gameptr->getPlayer()->getX(), gameptr->getPlayer()->getY());
	float y2 = v.y;
	float x2 = v.x;
	float y1 = getY();
	float x1 = getX();
	float distance = sqrt(pow(y2 - y1, 2) + (pow(x2 - x1, 2)));
	if (distance < getAttackRange()) {
		setAiState(NPC::Attack); // Jump up and down
		setDest(v);
	}
	// End of state change
}
void Enemy::shootMissile(int dir) {
	if (rand() % 5 > 3)
	{

		for (int i = 0; i < EnemyNS::MAX_BULLET_NUMBER; i++)
			if (false == tp[i].getActive() )
			{
				tp[i].setVelocity(VECTOR2(mmp->getDirectionDisX(dir) * 60, -(mmp->getDIrectionDisY(dir) * 60)));
				tp[i].fire(this, -(mmp->getDIrectionDisY(dir) * 60));
				break;
			}
	}
	
}
Beispiel #29
0
bool Player::initialize(Game *gamePtr, int width, int height, int ncols, TextureManager *textureM) {
	gameptr = gamePtr;
	gunTexture = new TextureManager();
	if (!gunTexture->initialize(gamePtr->getGraphics(), TEXTURE_GUNS))
		throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing gun texture"));
	pistol = new Pistol();
	pistol->initialize(gameptr, gunNS::TEXTURE_WIDTH, gunNS::TEXTURE_HEIGHT, gunNS::TEXTURE_COLS, gunTexture);
	pistol->setCurrentFrame(gunNS::PISTOL_FRAME);
	defaultItem = new InventoryItem(pistol);
	inventory->addItem(defaultItem);
	jumpOriginY = getY();
	setVelocity(VECTOR2(0, 0));
	return(Entity::initialize(gamePtr, width, height, ncols, textureM));
}
void IRenderPipeline3D::VertexShader(Vertex& inVertex)
{
	VertexShaderOutput_Vertex outVertex;

	//vertex position
	VECTOR4 pos(inVertex.pos.x, inVertex.pos.y, inVertex.pos.z, 1.0f);
	pos = Matrix_Multiply(mWorldMatrix, pos);
	pos = Matrix_Multiply(mViewMatrix, pos);

	//non-linear operation
	float Z_ViewSpace = pos.z;
	pos = Matrix_Multiply(mProjMatrix, pos);
	if (Z_ViewSpace >= 0)
	{
		pos.x /= (Z_ViewSpace);
		pos.y /= (Z_ViewSpace);
	}

	outVertex.posH = pos;

	//Normal also need transformation,actually it need a World-Inverse-Transpose
	//But I rule out all non-Orthogonal Transformation, so inverse can just use Transpose to substitude
	//thus inverse-transpose yields world matrix itself(without translation)
	MATRIX4x4 WorldMat_NoTrans = mWorldMatrix;
	WorldMat_NoTrans.SetColumn(3, { 0,0,0,1.0f });
	VECTOR4 normW(inVertex.normal.x, inVertex.normal.y, inVertex.normal.z, 1.0f);
	normW = Matrix_Multiply(WorldMat_NoTrans, normW);


	//-----TexCoord
	outVertex.texcoord = VECTOR2(
		inVertex.texcoord.x*mTexCoord_scale + mTexCoord_offsetX, 
		inVertex.texcoord.y*mTexCoord_scale + mTexCoord_offsetY);


	//...Vertex Light or directly use vertex color
	if (mLightEnabled)
	{
		outVertex.color = mFunction_VertexLighting(inVertex.pos, VECTOR3(normW.x,normW.y,normW.z));
	}
	else
	{
		outVertex.color = inVertex.color;
	}

	m_pVB_HomoSpace->push_back(outVertex);
}