예제 #1
0
void GameDocument::onShipCaptured( Noun * pCapper )
{
	TRACE( "GameDocument::onShipCaptured" );

	setGameState( GS_DEATH );
	m_bShipLost = true;

	// inform our script
	CharString sSelf = ship()->key().string();
	CharString sCapper = pCapper != NULL ? pCapper->key().string() : "";
	context()->scriptCall( CharString().format("onCaptured( '%s''%s' )", sSelf, sCapper ) );
	
	// reset the camera time
	s_fCamera = 0.0f;

	WindowObserve * pWindow = WidgetCast<WindowObserve>( InterfaceContext::findNode( "ObserveWindow" ) );
	if ( pWindow != NULL )
	{
		pWindow->setCameraMode( WindowObserve::CHASE );
		pWindow->setTargetMode( WindowObserve::LOCKED );
		pWindow->setTarget( ship() );
	}

	WindowText * pMessage = WidgetCast<WindowText>( InterfaceContext::findNode( "TextMessage" ) );
	if ( pMessage != NULL )
	{
		if ( pCapper != NULL )
			pMessage->setText( CharString().format("Ship captured by %s...", pCapper->name()) );
		else
			pMessage->setText( "Ship captured..." );
	}
}
예제 #2
0
/* output a vertex */
static void ship_vertex(FILE *fout, char *layer, dpoint_t v, double bulge) {
  ship(fout, 0, "VERTEX");
  ship(fout, 8, "%s", layer);
  ship(fout, 10, "%f", v.x);
  ship(fout, 20, "%f", v.y);
  ship(fout, 42, "%f", bulge);
}
예제 #3
0
파일: backend_pdf.c 프로젝트: OPSF/uClinux
/* Normal output: black on transparent */
static int render0(potrace_path_t *plist) {
  potrace_path_t *p;

  pdf_setcolor(info.color);
  list_forall (p, plist) {
    pdf_path(&p->curve);
    ship("h\n");
    if (p->next == NULL || p->next->sign == '+') {
      ship("f\n");
    }
  }
예제 #4
0
fleet::fleet(bool pOwned)
{
    playerOwned = pOwned;
    if(playerOwned){
        fleetShips.push_back(ship(2,100,550,0));
        fleetShips.push_back(ship(3,200,550,0));
        fleetShips.push_back(ship(3,350,550,0));
        fleetShips.push_back(ship(4,500,550,0));
        fleetShips.push_back(ship(5,700,550,0));
    }
}
예제 #5
0
static void svg_lineto(FILE *fout, dpoint_t p) {
  point_t q;

  q = unit(p);

  if (lastop != 'l') {
    ship(fout, "l%ld %ld", q.x-cur.x, q.y-cur.y);
  } else {
    ship(fout, "%ld %ld", q.x-cur.x, q.y-cur.y);
  }
  cur = q;
  lastop = 'l';
}
예제 #6
0
static void svg_curveto(FILE *fout, dpoint_t p1, dpoint_t p2, dpoint_t p3) {
  point_t q1, q2, q3;

  q1 = unit(p1);
  q2 = unit(p2);
  q3 = unit(p3);

  if (lastop != 'c') {
    ship(fout, "c%ld %ld %ld %ld %ld %ld", q1.x-cur.x, q1.y-cur.y, q2.x-cur.x, q2.y-cur.y, q3.x-cur.x, q3.y-cur.y);
  } else {
    ship(fout, "%ld %ld %ld %ld %ld %ld", q1.x-cur.x, q1.y-cur.y, q2.x-cur.x, q2.y-cur.y, q3.x-cur.x, q3.y-cur.y);
  }
  cur = q3;
  lastop = 'c';
}
예제 #7
0
파일: main.cpp 프로젝트: mantal/4P
int main(void)
{
	std::cout << "Compile date " << __DATE__ << " " << __TIME__ << std::endl; 
	
    sf::RenderWindow window(sf::VideoMode(640, 480), "Huehuehue");
	Display	display(window);
	Input	in(window);
	Loader	loader;//temp
	
	Log::init();

	Ship	ship("kestral");

	while(!in.closed())
    {
		display.updateScreen();
		in.update();
		EntityManager::updateEntity(in);
		EntityManager::displayEntity();
    }

	Log::end();
	window.close();
	
	return EXIT_SUCCESS;
}
예제 #8
0
void GameDocument::onUpdate( float t )
{
	// update the client
	m_pClient->update();
	// validate the cursor target
	setCursorTarget( validateNoun( m_pCursorTarget ) );

	// if we are playing music, check the game state
	if ( m_pJukeBox != NULL )
	{
		m_CheckMusicState += t;
		if ( m_CheckMusicState > CHECK_MUSIC_STATE_TIME )
		{
			m_CheckMusicState = 0.0f;

			bool isCombat = false;

			NounShip * pShip = ship();
			if ( pShip != NULL )
			{
				// check contacts for the ship, if any enemy contacts found, switch to combat music
				for(int i=0;i<pShip->contactCount() && !isCombat;i++)
					if ( pShip->isEnemy( pShip->contact( i ) ) )
						isCombat = true;
			}

			if ( isCombat )
				m_pJukeBox->setPlayList( "COMBAT" );
			else
				m_pJukeBox->setPlayList( "AMBIENT" );
		}
	}
}
///	Funktion erstellt zur aktuellen Mouse-Position einen HTML Tooltip
/// @return	der erstellte Tooltip-Text
CString CShipDesignMenuView::CreateTooltip(void)
{
	if (!m_pShownShip)
		return "";

	CBotEDoc* pDoc = resources::pDoc;
	ASSERT(pDoc);

	if (!pDoc->m_bDataReceived)
		return "";

	// Wo sind wir
	CPoint pt;
	GetCursorPos(&pt);
	ScreenToClient(&pt);
	CalcLogicalPoint(pt);

	if (CRect(388, 90, 388 + 200, 90 + 150).PtInRect(pt))
	{
		// Schiff erzeugen und Spezialforschungen einbeziehen
		CShips ship(pDoc->m_ShipInfoArray[m_pShownShip->GetID() - 10000]);
		pDoc->AddSpecialResearchBoniToShip(&ship, m_pPlayersRace);
		return ship.GetTooltip();
	}

	return "";
}
예제 #10
0
파일: game.c 프로젝트: Sayan-Paul/Project-X
int gamedraw(void){

  /* Calculate Timings for this Frame */
  timeframe();

  /* Set up a Blank Screen To Draw on */
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();

  /* Set the camera focusing on player 10 units away */
  camera(player,10);

  /* Begin Drawing the Level */
  skybox(5000,3000,5000);
  drawmap(&course[loadc]);

  /* Draw the Ship */
	if(tushar==0)
  ship();

  /* Draw The HUD Items */
  drawhud();

  /* Draw it to the screen */
  SDL_GL_SwapBuffers();
  return 1;
}
예제 #11
0
파일: backend_pdf.c 프로젝트: OPSF/uClinux
static void pdf_setcolor(const color_t col) {
  if (col == pdf_color) {
    return;
  }
  pdf_color = col;

  ship("%s\n", pdf_colorstring(col));
}
예제 #12
0
static void svg_rmoveto(FILE *fout, dpoint_t p) {
  point_t q;

  q = unit(p);
  ship(fout, "m%ld %ld", q.x-cur.x, q.y-cur.y);
  cur = q;
  lastop = 'm';
}
예제 #13
0
NounGadget * GameDocument::myGadgetTarget() const
{
	NounGadget * pGadget = gadgetTarget();
	if ( pGadget != NULL && pGadget->parentNoun() == ship() )
		return pGadget;

	return NULL;
}
예제 #14
0
파일: main.cpp 프로젝트: qualab/interfaces
int main()
{
    std::atexit(press_any_key);

    asteroid aster(12345);
    spaceship ship("Alfa-Romeo");
    object obj;
    object obj_aster = asteroid(67890);
    object obj_ship = spaceship("Omega-Juliette");
    asteroid aster_obj = obj_aster;
    spaceship ship_obj = obj_ship;

    auto check_variables = [&]()
    {
        std::cout << std::boolalpha << "\n Test for null:"
            << "\n\t aster.is_null(): " << aster.is_null()
            << "\n\t ship.is_null(): " << ship.is_null()
            << "\n\t obj.is_null(): " << obj.is_null()
            << "\n\t obj_aster.is_null(): " << obj_aster.is_null()
            << "\n\t obj_ship.is_null(): " << obj_ship.is_null()
            << "\n\t aster_obj.is_null(): " << aster_obj.is_null()
            << "\n\t ship_obj.is_null(): " << ship_obj.is_null()
            << std::endl;

        std::cout << "\n Test for data class:"
            << "\n\t aster.data_class(): " << aster.data_class()
            << "\n\t ship.data_class(): " << ship.data_class()
            << "\n\t obj.data_class(): " << obj.data_class()
            << "\n\t obj_aster.data_class(): " << obj_aster.data_class()
            << "\n\t obj_ship.data_class(): " << obj_ship.data_class()
            << "\n\t aster_obj.data_class(): " << aster_obj.data_class()
            << "\n\t ship_obj.data_class(): " << ship_obj.data_class()
            << std::endl;

        std::cout << "\n Test identification:"
            << "\n\t aster.get_identifier(): " << aster.get_identifier()
            << "\n\t ship.get_name(): " << ship.get_name()
            << "\n\t aster_obj.get_identifier(): " << aster_obj.get_identifier()
            << "\n\t ship_obj.get_name(): " << ship_obj.get_name()
            << std::endl;
    };

    std::cout << "\n ======== Check after constructors ========" << std::endl;
    check_variables();

    aster = asteroid(335577);
    ship = spaceship("Ramambahara");
    obj = object();
    obj_aster = asteroid(446688);
    obj_ship = spaceship("Mamburu");
    aster_obj = obj_aster;
    ship_obj = obj_ship;

    std::cout << "\n ======== Check after assignments ========" << std::endl;
    check_variables();

    return 0;
}
예제 #15
0
파일: backend_pdf.c 프로젝트: OPSF/uClinux
static void pdf_curveto(dpoint_t p1, dpoint_t p2, dpoint_t p3) {
  point_t q1, q2, q3;

  q1 = unit(p1);
  q2 = unit(p2);
  q3 = unit(p3);

  ship("%ld %ld %ld %ld %ld %ld c\n", q1.x, q1.y, q2.x, q2.y, q3.x, q3.y);
}
예제 #16
0
void RandomSetShips::setShip(Ship::TubesShip nTubes, Board& board)
{
	Ship ship(nTubes);

	if (checkShip(ship, board))
		insertShip(ship, board);
	else
		setShip(nTubes, board);
}
예제 #17
0
void BotController::checkEnergy() {
    if(!ship()->collidable()) {
        for (std::map<Ship*, float>::iterator it = aggroTable_.begin(); it != aggroTable_.end(); ++it)
            it->second = 0.f;
        target_ = NULL;
    }
    else {
        if (!ship()->docked_ && std::max(100 - ship()->getLife(), 100 - ship()->getFuel()) > 30) {
            slave_->team()->addJob(Job(Job::jHeal, std::max(100 - ship()->getLife(), 100 - ship()->getFuel()), ship()));
            slave_->team()->addJob(Job(Job::jHeal, std::max(100 - ship()->getLife(), 100 - ship()->getFuel()), ship()));
        }

        if (ship()->frozen_ > 0) {
            slave_->team()->addJob(Job(Job::jUnfreeze, 90, ship()));
            slave_->team()->addJob(Job(Job::jUnfreeze, 90, ship()));
            slave_->team()->addJob(Job(Job::jUnfreeze, 90, ship()));
        }
    }
}
예제 #18
0
파일: sprites.cpp 프로젝트: Camelek/qtmoko
/*!
  \internal
  If the ship's shield strength is greater than 0, raise the
  shield (ie show it), and reduce the ship's power level by
  an appropriate amount.

  Note that this function does not set any limits on how long
  shield will stay up. That responsibility belongs to the caller.
 */
bool KShield::raise()
{
    isUp_ = (strength_ > 0);
    if (isUp_) {
	--strength_;
	ship()->reducePowerLevel(SHIELD_ON_COST);
	shield_->show();
    }
    return isUp_;
}
예제 #19
0
void build_escape_pod(region_t &region, const int crash_x, const int crash_y, const int crash_z) {
    xp::rex_sprite ship("rex/spaceship.xp");
    int z=-2+crash_z;
    for (int layer = 0; layer<5; ++layer) {
        for (int Y=0; Y<ship.get_height(); ++Y) {
            for (int X=0; X<ship.get_width(); ++X) {
                const int x = X-5+crash_x;
                const int y = Y-11+crash_y;

                const vchar * output = ship.get_tile(layer,X,Y);
                if (output != nullptr && output->glyph != 32) region.revealed[mapidx(x,y, z)] = true;
				if (output != nullptr && !xp::is_transparent(output)) {
                    if (output->glyph == 219) {
                        add_construction(region, x, y, z, "ship_wall", true, 0);
                    } else if (output->glyph == 177) {
                        add_construction(region, x, y, z, "ship_window", true, 0);
                    } else if (output->glyph == 176) {
                        add_construction(region, x, y, z, "ship_floor", false, 0);
                    } else if (output->glyph == 'X') {
                        add_construction(region, x, y, z, "ship_updown", false, 0);
                    } else if (output->glyph == '<') {
                        add_construction(region, x, y, z, "ship_up", false, 0);
                    } else if (output->glyph == '>') {
                        add_construction(region, x, y, z, "ship_down", false, 0);
                    } else if (output->glyph == 178) {
                        add_construction(region, x, y, z, "solar_panel", false, 0);
                    } else if (output->glyph == 241) {
                        add_construction(region, x, y, z, "battery", false, 0);
                    } else if (output->glyph == 'X') {
                        add_construction(region, x, y, z, "ship_updown", false, 0);
                    } else if (output->glyph == '0') {
                        add_construction(region, x, y, z, "cryo_bed", false, 0);
                    } else if (output->glyph == 'X') {
                        add_construction(region, x, y, z, "ship_updown", false, 0);
                    } else if (output->glyph == 236) {
                        add_construction(region, x, y, z, "storage_locker", false, 0);
                    } else if (output->glyph == 'C') {
                        add_construction(region, x, y, z, "cordex", false, 0);
                    } else if (output->glyph == 251) {
                        add_construction(region, x, y, z, "small_replicator", false, 0);
                    } else if (output->glyph == 232) {
                        add_construction(region, x, y, z, "rtg", false, 0);
                    } else if (output->glyph == 197) {
                        add_construction(region, x, y, z, "ship_door", false, 0);
                    } else {
                        if (output->glyph != 32)
                            std::cout << "Warning: No handler for " << (char)output->glyph << " (" << +output->glyph << ")\n";
                    }
                }
            }
        }
        ++z;
    }
}
예제 #20
0
/* public interface for DXF */
int page_dxf(FILE *fout, potrace_path_t *plist, imginfo_t *imginfo) {
  potrace_path_t *p;
  trans_t t;
  char *layer = "0";

  /* set up the coordinate transform (rotation) */
  t.bb[0] = imginfo->trans.bb[0]+imginfo->lmar+imginfo->rmar;
  t.bb[1] = imginfo->trans.bb[1]+imginfo->tmar+imginfo->bmar;
  t.orig[0] = imginfo->trans.orig[0]+imginfo->lmar;
  t.orig[1] = imginfo->trans.orig[1]+imginfo->bmar;
  t.x[0] = imginfo->trans.x[0];
  t.x[1] = imginfo->trans.x[1];
  t.y[0] = imginfo->trans.y[0];
  t.y[1] = imginfo->trans.y[1];

  ship_comment(fout, "DXF data, created by \"POTRACE\" \"VERSION\", written by Peter Selinger 2001-2015");

  /* header section */
  ship_section(fout, "HEADER");

  /* variables */
  ship(fout, 9, "$ACADVER");
  ship(fout, 1, "AC1006");
  ship(fout, 9, "$EXTMIN");
  ship(fout, 10, "%f", 0.0);
  ship(fout, 20, "%f", 0.0);
  ship(fout, 30, "%f", 0.0);
  ship(fout, 9, "$EXTMAX");
  ship(fout, 10, "%f", t.bb[0]);
  ship(fout, 20, "%f", t.bb[1]);
  ship(fout, 30, "%f", 0.0);

  ship_endsec(fout);

  /* entities section */
  ship_section(fout, "ENTITIES");

  /* write paths */
  list_forall (p, plist) {
    dxf_path(fout, layer, &p->curve, t);
  }
/*---------------------------------------------------------------------------*\
| \fn       AssemblyLineTemplate::process_order
| \brief    AssemblyLineTemplate template method
\*---------------------------------------------------------------------------*/
void AssemblyLineTemplate::process_order()
{
    setup_injection_line();

    std::cout << "\tProcess order." << std::endl;
    pull_mold();
    insert_tags();
    load_additive_bins();
    run_injection_cycle();
    clean_mold();
    ship();
}
예제 #22
0
void BotController::checkCloseEnemies() {
    std::vector<Ship*> const& ships(ships::getShips());
    for (std::vector<Ship*>::const_iterator it=ships.begin(); it!=ships.end(); ++it) {
        if ((*it)->attackable() && (*it)->owner_->team() != slave_->team()) {
            float aggroGain(90.f - (*it)->getLife()*0.9);
            float distance(((*it)->location_-ship()->location_).length()*0.01f);
            aggroGain -= distance;
            if (aggroGain < 0.f) aggroGain = 0.f;
            aggroGain *= settings::C_iDumb*0.01f;
            aggroTable_[*it] += aggroGain;
        }
    }
}
예제 #23
0
/**
 * SLOT
 * Place ships for the oponent in sigle player mode.
 */
void Battleships::randomlyPlaceShips(Board *gameBoard)
{
    gameBoard->removeAll();
    QStringList shipNameList = m_defaultShips.keys();
    for (QString name : shipNameList) {
        bool isPlaced = false;
        do {
            ShipPosition position = getRandomShipPosition(gameBoard->getGameBoardSize());
            int shipLength = m_defaultShips.value(name);
            Ship ship(shipLength, name);
            isPlaced = gameBoard->place(ship, position.x, position.y, position.direction);
        } while(! isPlaced);
    }
}
예제 #24
0
    void test_rockets_should_have_the_same_speed_as_the_launching_object()
    {
        sc::phi::Sector sector;
        test::TestObjectFactory objectFactory( sector );

        sc::phi::ObjectRef ship(
            objectFactory.createShip( sc::phi::ObjectProperties( m_start_coordinate, m_speed_moving, 0.0, 10, 1 ) ) );

        sc::evt::BinaryEvent fire( sc::phi::slot::FIRE );
        ship->dispatchEvent( fire );

        objectFactory.assertRocketCreated_ResetFlag( true );
        objectFactory.assertCreatedRocketSpeedEquals( m_speed_moving );
    }
예제 #25
0
void GameDocument::onShipDestroyed( Noun * pKiller )
{
	TRACE( "GameDocument::onShipDestroyed" );

	setGameState( GS_DEATH );
	m_bShipLost = true;

	// inform our script
	CharString sSelf = ship()->key().string();
	CharString sKiller = "";
	if ( pKiller != NULL )
		sKiller = pKiller->key().string();
	context()->scriptCall( CharString().format("onDeath( '%s','%s' )", sSelf, sKiller) );

	// reset the camera time
	s_fCamera = 0.0f;

	WindowObserve * pWindow = WidgetCast<WindowObserve>( InterfaceContext::findNode( "ObserveWindow" ) );
	if ( pWindow != NULL )
	{
		pWindow->setCameraMode( WindowObserve::CHASE );
		pWindow->setTargetMode( WindowObserve::LOCKED );
		pWindow->setTarget( ship() );
	}

	WindowText * pMessage = WidgetCast<WindowText>( InterfaceContext::findNode( "TextMessage" ) );
	if ( pMessage != NULL )
	{
		if ( pKiller && pKiller != ship() )
			pMessage->setText( CharString().format("Ship destroyed by %s...", pKiller->name()) );
		else if ( pKiller == ship() )
			pMessage->setText( "You have self destructed..." );
		else
			pMessage->setText( "Ship destroyed..." );
	}
}
예제 #26
0
void BotController::checkAggro() {
    if (ship()->collidable()) {
        if(lastFrameLife_ - ship()->getLife() > 0.f && ship()->damageSource()) {
            if(ship()->damageSource() != slave_ && slave_->team() != ship()->damageSource()->team() && ship()->damageSource()->ship()->attackable())
                aggroTable_[ship()->damageSource()->ship()] += (lastFrameLife_ - ship()->getLife()) * 30.f;
        }

        if(lastFrameLife_ != ship()->getLife())
            lastFrameLife_ = ship()->getLife();

        // process aggroTable
        float maxAggro(-1.f);
        for (std::map<Ship*, float>::iterator it = aggroTable_.begin(); it != aggroTable_.end(); ++it) {
            if(it->second > 0.f && !it->first->collidable())
                it->second = 0.f;
            if(it->second > 0.f && it->first != target_)
                it->second -= 5.f;
            if(it->second > maxAggro && it->first->collidable())
                maxAggro = it->second;
        }
        // if there is one enemy with a lot more aggro than the current
        // target, attack this one
        if (maxAggro > 120.f)
            for (std::map<Ship*, float>::iterator it = aggroTable_.begin(); it != aggroTable_.end(); ++it) {
                if(it->second == maxAggro && it->first->attackable()) {
                    it->second = 100.f;
                    target_ = it->first;
                }
                else
                    it->second /= (maxAggro/100.f);
            }

        // normalize aggro to 100 for the target
        if (target_) {
            float targetAggro(aggroTable_[target_]);
            for (std::map<Ship*, float>::iterator it = aggroTable_.begin(); it != aggroTable_.end(); ++it) {
                it->second /= (targetAggro/100.f);
            }
        }
    }
}
예제 #27
0
    void test_launcher_should_lauch_rocket_if_fire_event_arrives_and_has_cooldown()
    {
        sc::phi::Sector sector;
        test::TestObjectFactory objectFactory( sector );

        sc::phi::ObjectRef ship(
            objectFactory.createShip( sc::phi::ObjectProperties( m_start_coordinate, m_speed_still, 0.0, 10, 1 ) ) );

        sc::evt::BinaryEvent fire( sc::phi::slot::FIRE );
        ship->dispatchEvent( fire );

        objectFactory.assertRocketCreated_ResetFlag( true );

        ship->dispatchEvent( fire );
        objectFactory.assertRocketCreated_ResetFlag( false );
    }
예제 #28
0
void BotController::checkSpecial() {
    if (ship()->fragStars_ > 0 && randomizer::random(0, 10) == 1) {
        float radius(ship()->currentSpecial_->radius());
        switch (ship()->currentSpecial_->getType()) {
            case specials::sHeal:
                if (ship()->getLife() < 10)
                    slaveSpecial(100);
                break;

            case specials::sBlast: case specials::sFireWall: case specials::sShocker: {
                int decision(0);
                std::vector<Ship*> const& ships(ships::getShips());
                for (std::vector<Ship*>::const_iterator it=ships.begin(); it!=ships.end(); ++it) {
                    if ((*it)->collidable() && (*it)->frozen_ <= 0 && (*it) != slave_->ship()) {
                        float distance(((*it)->location_-ship()->location_).lengthSquare());
                        if (distance <= radius*radius) {
                            if ((*it)->owner_->team() == slave_->team()) --decision;
                            else                                         ++decision;
                        }
                    }
                }
                if (decision > 0)
                    slaveSpecial(100);
                break;
            }

            default: {
                int decision(0);
                std::vector<Ship*> const& ships(ships::getShips());
                for (std::vector<Ship*>::const_iterator it=ships.begin(); it!=ships.end(); ++it) {
                    if ((*it)->attackable() && (*it) != slave_->ship()) {
                        float distance(((*it)->location_-ship()->location_).lengthSquare());
                        if (distance <= radius*radius) {
                            if ((*it)->owner_->team() == slave_->team()) --decision;
                            else                                         ++decision;
                        }
                    }
                }
                if (decision > 0)
                    slaveSpecial(100);
                break;
            }
        }
    }
}
예제 #29
0
/* output the start of a polyline */
static void ship_polyline(FILE *fout, char *layer, int closed) {
  ship(fout, 0, "POLYLINE");
  ship(fout, 8, "%s", layer);
  ship(fout, 66, "%d", 1);
  ship(fout, 70, "%d", closed ? 1 : 0);
}
예제 #30
0
static void ship_eof(FILE *fout) {
  ship(fout, 0, "EOF");
}