Exemplo n.º 1
0
int main( void ) {
	FILE* f = fopen( "maps/basic.txt", "r" );
	GraphMap map( f );

	Simple_Hero hero( ACTOR_HERO );

	hero.make_graph( &map );

	fclose( f );
	return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
    switch (message)    {
	case WM_CREATE: {
		database->reserve(50);
		initInterface();
		genb = CreateWindowA("BUTTON", loadStringFromFile("tech\\button").c_str(), WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_FLAT, 355, 260, 150, 75, hWnd, HMENU(ID_BUTTON_GEN), NULL, NULL); SendMessage(genb, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(TRUE, 0));
		right = CreateWindowW(L"BUTTON", L"←", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_FLAT, 325, 260, 30, 75, hWnd, HMENU(ID_BUTTON_RIGHT), NULL, NULL); SendMessage(right, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(TRUE, 0));
		left = CreateWindowW(L"BUTTON", L"→", WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_FLAT, 505, 260, 30, 75, hWnd, HMENU(ID_BUTTON_LEFT), NULL, NULL); SendMessage(left, WM_SETFONT, (WPARAM)hFont, (LPARAM)MAKELONG(TRUE, 0));
	}
    case WM_COMMAND: {
			if ((HIWORD(wParam)==0)&&(LOWORD(wParam)==ID_BUTTON_GEN)) {
				database->push_back(hero());
				current_hero = database->size()-1;
				hdc = GetDC(hWnd);
				ResultOnScreen(hdc,hFont);
				ReleaseDC(hWnd, hdc);
			}
			if ((HIWORD(wParam) == 0) && (LOWORD(wParam) == ID_BUTTON_LEFT)) {
				if (current_hero >= 0 && current_hero < database->size()-1) {
					current_hero++;
					hdc = GetDC(hWnd);
					ResultOnScreen(hdc, hFont);
					ReleaseDC(hWnd, hdc);
				}
			}
			if ((HIWORD(wParam) == 0) && (LOWORD(wParam) == ID_BUTTON_RIGHT)) {
				if (current_hero > 0 && current_hero <= database->size()) {
					current_hero--;
					hdc = GetDC(hWnd);
					ResultOnScreen(hdc, hFont);
					ReleaseDC(hWnd, hdc);
				}
			}
			SetFocus(hWnd);
			InvalidateRect(hWnd, NULL, TRUE);
        }
        break;
	case WM_PAINT: {
			hdc = BeginPaint(hWnd, &ps);
			InterfaceOnScreen(hFont, hdc);
			ResultOnScreen(hdc, hFont);
			EndPaint(hWnd, &ps);
		}
        break;
	case WM_KEYDOWN:  if (wParam == VK_ESCAPE) { DestroyWindow(hWnd); } break;
	case WM_DESTROY: PostQuitMessage(0); break;
	default: { return DefWindowProc(hWnd, message, wParam, lParam); }  }
    return 0;
}
Exemplo n.º 3
0
int main(int argc, char const *argv[])
{
	Card card("killer.jpg");
	card.setChars(1, 1, 1);
	std::cout << card.getSkin() << std::endl <<
				 card.costs() << std::endl <<
				 card.hasHealth() << std::endl <<
				 card.hasPower() << std::endl;
	Hero hero("assasin.jpg", 63, &card);
	std::cout << hero.getSkin() << std::endl <<
				 hero.costs() << std::endl <<
				 hero.hasHealth() << std::endl <<
				 hero.hasPower() << std::endl;
	std::cout << hero.power->getSkin() << std::endl <<
				 hero.power->costs() << std::endl <<
				 hero.power->hasHealth() << std::endl <<
				 hero.power->hasPower() << std::endl;	
	return 0;
}
Exemplo n.º 4
0
main()
{
	role hero("剑心", 170, 25);
	cout<<hero;
}
Exemplo n.º 5
0
/* Has all kinds of effects in different circumstances.
   Eventually will be more interesting */
void s_ritual(void)
{
    pob symbol;
    int i,roomno;
    int x,y;

    mprint("You begin your ritual....");
    mprint("You enter a deep trance. Time Passes...");
    setgamestatus(SKIP_PLAYER);
    time_clock(FALSE);
    setgamestatus(SKIP_PLAYER);
    time_clock(FALSE);
    setgamestatus(SKIP_PLAYER);
    time_clock(FALSE);
    setgamestatus(SKIP_PLAYER);
    time_clock(FALSE);
    setgamestatus(SKIP_PLAYER);
    time_clock(FALSE);
    if (RitualHour == hour())
        mprint("Your mental fatigue prevents from completing the ritual!");
    else if (random_range(100) > Player.iq+Player.pow+Player.level)
        mprint("Your concentration was broken -- the ritual fails!");
    else {
        mprint("You charge the ritual with magical energy and focus your will.");
        mprint("Time Passes...");
        setgamestatus(SKIP_PLAYER);
        time_clock(FALSE);
        setgamestatus(SKIP_PLAYER);
        time_clock(FALSE);
        setgamestatus(SKIP_PLAYER);
        time_clock(FALSE);
        setgamestatus(SKIP_PLAYER);
        time_clock(FALSE);
        setgamestatus(SKIP_PLAYER);
        time_clock(FALSE);
        RitualHour = hour();
        /* set of random conditions for different ritual effects */
        if (Current_Environment == E_CITY) {
            mprint("Flowing waves of mystical light congeal all around you.");
            mprint("'Like wow, man! Colors!'");
            mprint("Appreciative citizens throw you spare change.");
            Player.cash +=random_range(50);
        }
        else if ( (roomno=Level->site[Player.x][Player.y].roomnumber) >= ROOMBASE )
        {
            if (RitualRoom == roomno)
                mprint("For some reason the ritual doesn't work this time...");
            else {
                RitualRoom = roomno;
                switch (RitualRoom) {
                case RS_TREASURE: /* ransacked treasure chamber */
                    mprint("Your spell sets off frenetic growth all around you!");
                    for(i=0; i<8; i++) {
                        Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].locchar =
                            HEDGE;
                        Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].p_locf =
                            L_TRIFID;
                        lset(Player.x+Dirs[0][i], Player.y+Dirs[1][i], CHANGED);
                    }
                    break;
                case RS_HAREM: /* harem */
                case RS_BOUDOIR: /* boudoir */
                    mprint("A secret panel opens next to the bed....");
                    if (random_range(2))
                        summon(0,INCUBUS); /* succubus/incubus */
                    else summon(0,SATYR); /* satyr/nymph */
                    break;
                case RS_SHRINE: /*shrine to high magic */
                    mprint("A storm of mana coaelesces around you.");
                    mprint("You are buffeted by bursts of random magic.");
                    p_damage(random_range(Player.pow),UNSTOPPABLE,"high magic");
                    mprint("Continue ritual? Could be dangerous.... [yn] ");
                    if (ynq()=='y') s_wish();
                    else mprint("The mana fades away to nothingness.");
                    x = Player.x;
                    y = Player.y;
                    while (x >= 0 && Level->site[x - 1][y].roomnumber == RS_SHRINE)
                        x--;
                    while (y >= 0 && Level->site[x][y - 1].roomnumber == RS_SHRINE)
                        y--;
                    for (i = 0; Level->site[x][y].roomnumber == RS_SHRINE;) {
                        Level->site[x][y].roomnumber = RS_ZORCH;
                        lset(x, y, CHANGED);
                        x++;
                        i++;
                        if (Level->site[x][y].roomnumber != RS_SHRINE) {
                            x -= i;
                            i = 0;
                            y++;
                        }
                    }
                    break;
                case RS_MAGIC_LAB: /* magician's lab */
                    mprint("Your magical activity sets off a latent spell in the lab!");
                    cast_spell(random_range(NUMSPELLS));
                    break;
                case RS_PENTAGRAM: /* pentagram room */
                    mprint("A smoky form begins to coalesce....");
                    summon(-1,-1);
                    mprint("Fortunately, it seems confined to the pentagram.");
                    m_status_reset(Level->mlist->m,MOBILE);
                    break;
                case RS_OMEGA_DAIS: /* blue omega room */
                    mprint("The Lords of Destiny look upon you....");
                    if (Player.level > 10) {
                        mprint("A curtain of blue flames leaps up from the omega.");
                        morewait();
                        l_adept();
                    }
                    else {
                        if (Player.patron == DESTINY) {
                            mprint("Your patrons take pity on you.");
                            if ((Player.rank[PRIESTHOOD]<SPRIEST) &&
                                    (! find_item(&symbol,OB_SYMBOL_DESTINY,-1))) {
                                symbol = ((pob) checkmalloc(sizeof(objtype)));
                                *symbol = Objects[OB_SYMBOL_DESTINY];
                                symbol->known = 2;
                                symbol->charge = 17;
                                gain_item(symbol);
                                mprint("You feel uplifted.");
                            }
                            else gain_experience(min(1000,Player.xp));
                        }
                        else if (random_range(3)==1) {
                            mprint("You feel Fated.");
                            gain_experience(Player.level*Player.level*10);
                            Player.hp = max(Player.hp, Player.maxhp);
                        }
                        else if (random_range(2)) {
                            mprint("You feel Doomed.");
                            Player.hp = 1;
                            Player.mana = 0;
                            Player.xp = 0;
                        }
                        else mprint("The Lords of Destiny laugh at you!");
                    }
                    break;
                default:
                    mprint("Well, not much effect. Chalk it up to experience.");
                    gain_experience(Player.level*5);
                    break;
                }
            }
        }
        else {
            if (RitualRoom == Level->site[Player.x][Player.y].roomnumber)
                mprint("The ritual fails for some unexplainable reason.");
            else {
                mprint("The ritual seems to be generating some spell effect.");
                RitualRoom = Level->site[Player.x][Player.y].roomnumber;
                switch (RitualRoom) {
                case RS_WALLSPACE:
                    shadowform();
                    break;
                case RS_CORRIDOR:
                    haste(0);
                    break;
                case RS_PONDS:
                    breathe(0);
                    break;
                case RS_ADEPT:
                    hero(1);
                    break;
                default:
                    mprint("The ritual doesn't seem to produce any tangible results...");
                    gain_experience(Player.level*6);
                }
            }
        }
    }
}
Exemplo n.º 6
0
void s_hero(void)
{
    hero(0);
}
Exemplo n.º 7
0
int main(int /*argc*/, char* /*argv*/[])
{
    srand(time(nullptr));

    Logger::get().setLevel(LogLevel::DEBUG);
    CLOG_DEBUG("starting crawler");

    Input input;
    Renderer r;

    auto& simulator = Simulator::get();
    auto& windowManager = WindowManager::get();

    WorldSharedPtr world(new World());
    // Possibility: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096...
    world->generate(128);
    simulator.setWorld(world);

    HeroSharedPtr hero(new Hero());
    hero->setMapHp(100);
    hero->heal();
    hero->setName("Jacob");
    hero->equip(ItemFactory::create(ItemTemplates::PUNCH()));
    simulator.spawn(hero);

    CharacterTemplateSharedPtrs creatureTemplates;
    creatureTemplates.push_back(CharacterTemplates::DEMON());
    creatureTemplates.push_back(CharacterTemplates::VILLAGER());
    creatureTemplates.push_back(CharacterTemplates::KID());
    creatureTemplates.push_back(CharacterTemplates::BAT());

    int worldArea = world->getWidth() * world->getHeight();

    for (int i = 0; i < 10; i++)
    {
        ObjectSharedPtr room = RoomFactory::create(RoomTemplates::INN());
        simulator.spawn(room);
    }

    float creatureDensity = 100 / (float)(64*64);
    int numCreature = (int)(worldArea * creatureDensity);
    for (int i = 0; i < numCreature; i++)
    {
        int idx = Math::ceilRandom(creatureTemplates.size());
        ObjectSharedPtr creature(CharacterFactory::create(creatureTemplates[idx]));
        simulator.spawn(creature);
    }

    float chestDensity = 2 / (float)(64*64);
    int numChest = (int)(worldArea * chestDensity);
    for (int i = 0; i < numChest; i++)
    {
        ObjectSharedPtr chest(ChestFactory::create());
        simulator.spawn(chest);
    }

    Debugger& debugger = Debugger::get();

    Timer timer;
    while (!input.quit())
    {
        debugger.incFrameId();
        float dt = timer.elapsed();
        timer.reset();

        CDEBUG_LOW(debugger.tick(dt));

        simulator.tick(dt);
        windowManager.tick(dt);

        // control camera around hero
        int centerX = hero->getX() - r.getWidth() / 2;
        int centerY = hero->getY() - r.getHeight() / 2;
        /*
          int ox = r.getOriginX();
          int oy = r.getOriginY();
          int errX = (int)fabs((float)centerX - ox) - r.getWidth() / 6;
          int errY = (int)fabs((float)centerY - oy) - r.getHeight() / 6;
          if (errX > 0)
          {
          ox += (centerX > ox) ? errX : -errX;
          }

          if (errY > 0)
          {
          oy += (centerY > oy) ? errY : -errY;
          }

          r.setOrigin(ox, oy);
        */
        r.setOrigin(centerX, centerY, hero->getZ());

        r.clear();
        simulator.draw(&r);
        windowManager.draw(&r);
        CDEBUG_LOW(debugger.draw(&r));
        r.flip();

        int sleepTime = (int)(33333.3f - timer.elapsed() * 1000000.0f);
        if (sleepTime > 0)
        {
            usleep(sleepTime);
        }
    }

    return 0;
}
Exemplo n.º 8
0
void i_hero(pob o)
{
    if (o->known < 1) o->known = 1;
    Objects[o->id].known = 1;
    hero(o->blessing);
}
Exemplo n.º 9
0
GLvoid InitGL(){
	//All the stuff we need to draw
	std::string hero_geo_file = "geo/tank.obj";
	std::string target_geo_file = "geo/target.obj";
	std::string swivel_geo_file = "geo/turret.obj";
	std::string barrel_geo_file = "geo/barrel.obj";
	std::string environment_geo_file = "geo/cube.obj";
	std::string enemy_geo_file = "geo/enemy.obj";
	std::string tile_geo_file = "geo/tile.obj";
	std::string tree_geo_file = "geo/tree.obj";
	std::string rock_geo_file = "geo/rocks.obj";

	std::string hero_tex_file = "tex/tank.ppm";
	std::string target_tex_file = "tex/target.ppm";
	std::string swivel_tex_file = "tex/turret.ppm";
	std::string barrel_tex_file = "tex/barrel.ppm";
	std::string environment_tex_file = "tex/cubemape.ppm";
	std::string enemy_tex_file = "tex/enemy.ppm";
	std::string tile_tex_file = "tex/naked_tile_baked.ppm";
	std::string tree_tex_file = "tex/tree.ppm";
	std::string rock_tex_file = "tex/rocks.ppm";
	std::string tree_tile_tex = "tex/tree_tile.ppm";
	std::string rock_tile_tex = "tex/rocky_tile.ppm";
	std::string blob_tile_tex = "tex/blob_shadow.ppm";

	mesh hero(hero_geo_file);
	mesh target(target_geo_file);
	mesh swivel(swivel_geo_file);
	mesh barrel(barrel_geo_file);
	mesh environment(environment_geo_file);
	mesh enemy(enemy_geo_file);
	mesh tile(tile_geo_file);
	mesh tree(tree_geo_file);
	mesh rock(rock_geo_file);
	HERO_ID = meshes.size();
	meshes.push_back(hero);
	TARGET_ID = meshes.size();
	meshes.push_back(target);
	SWIVEL_ID = meshes.size();
	meshes.push_back(swivel);
	BARREL_ID = meshes.size();
	meshes.push_back(barrel);
	ENVIRONMENT_ID = meshes.size();
	meshes.push_back(environment);
	ENEMY_ID = meshes.size();
	meshes.push_back(enemy);
	TILE_ID = meshes.size();
	meshes.push_back(tile);
	TREE_ID = meshes.size();
	meshes.push_back(tree);
	ROCK_ID = meshes.size();
	meshes.push_back(rock);

	glEnable(GL_TEXTURE_2D);
	glGenTextures(1, &HERO_TEX);
	glGenTextures(1, &TARGET_TEX);
	glGenTextures(1, &SWIVEL_TEX);
	glGenTextures(1, &BARREL_TEX);
	glGenTextures(1, &ENVIRONMENT_TEX);
	glGenTextures(1, &ENEMY_TEX);
	glGenTextures(1, &TILE_TEX);
	glGenTextures(1, &TREE_TEX);
	glGenTextures(1, &ROCK_TEX);
	glGenTextures(1, &TREETILE_TEX);
	glGenTextures(1, &ROCKTILE_TEX);
	glGenTextures(1, &BLOBTILE_TEX);
	loadPPM(hero_tex_file.c_str(), HERO_TEX);
	loadPPM(target_tex_file.c_str(), TARGET_TEX);
	loadPPM(swivel_tex_file.c_str(), SWIVEL_TEX);
	loadPPM(barrel_tex_file.c_str(), BARREL_TEX);
	loadPPM(environment_tex_file.c_str(), ENVIRONMENT_TEX);
	loadPPM(enemy_tex_file.c_str(), ENEMY_TEX);
	loadPPM(tile_tex_file.c_str(), TILE_TEX);
	loadPPM(tree_tex_file.c_str(), TREE_TEX);
	loadPPM(rock_tex_file.c_str(), ROCK_TEX);
	loadPPM(tree_tile_tex.c_str(), TREETILE_TEX);
	loadPPM(rock_tile_tex.c_str(), ROCKTILE_TEX);
	loadPPM(blob_tile_tex.c_str(), BLOBTILE_TEX, true);

	camera = new game_object(-1,-1,-1);

	game_object *hero_character = new game_object(characters.size(), HERO_ID, HERO_TEX);
	characters.push_back(hero_character);
	game_object *target_character = new game_object(characters.size(), TARGET_ID, TARGET_TEX);
	target_character->transform.translate(0.0,0.0,-7.0);
	characters.push_back(target_character);
	game_object *swivel_character = new game_object(characters.size(), SWIVEL_ID, SWIVEL_TEX);
	swivel_character->transform.translate(0.0,0.4,0.0);
	characters.push_back(swivel_character);
	game_object *barrel_character = new game_object(characters.size(), BARREL_ID, BARREL_TEX);
	barrel_character->transform.translate(0.0,0.0,-0.15);
	barrel_character->parent_to(characters[SWIVEL_ID]);
	characters.push_back(barrel_character);
	game_object *environment_character = new game_object(characters.size(), ENVIRONMENT_ID, ENVIRONMENT_TEX);
	environment_character->transform.scale(TILES_DIMENSION,TILES_DIMENSION,TILES_DIMENSION);
	environment_character->parent_to(camera);
	characters.push_back(environment_character);
	
	// game_object *enemy_character = new game_object(characters.size(), ENEMY_ID, ENEMY_TEX);
	// enemy_character->transform.translate(0.0, 0.0, -7.0);
	// enemy_character->parent_to(camera);
	// characters.push_back(enemy_character);
	// bad_guys.push_back(ENEMY_ID);

	srand(time(NULL));

	int spread = TILES_DIMENSION;
	for(int i=1; i<BAD_GUY_COUNT; i++)
	{
		game_object *enemyX = new game_object(characters.size(), ENEMY_ID, ENEMY_TEX);
		enemyX->transform.translate(rand()%spread-spread/2, 0.0, rand()%spread-spread/2);
		enemyX->transform.rotateY(rand()%180);
		enemyX->parent_to(camera);
		bad_guys.push_back(characters.size());
		colliders.push_back(characters.size());
		characters.push_back(enemyX);
	}

	double tile_width = meshes[TILE_ID].xmax - meshes[TILE_ID].xmin;
	double tile_length = meshes[TILE_ID].zmax - meshes[TILE_ID].zmin;
	for(int i=0; i<TILES_DIMENSION; i++)
	{
		int xmult = i - TILES_DIMENSION/2;
		for(int j=0; j<TILES_DIMENSION; j++)
		{
			int zmult = j - TILES_DIMENSION/2;
			double rot = rand() % 4 * 90.0;
			// std::cout << rot << std::endl;
			game_object *tileX = new game_object(characters.size(), TILE_ID, TILE_TEX);
			tileX->transform.rotateY(rot);
			tileX->transform.translate(tile_width*xmult, 0.0, tile_length*zmult);
			tileX->parent_to(camera);
			characters.push_back(tileX);
			int tile_type = rand() % 100;
			if(tile_type >= 96 && tile_type < 98)
			{
				tileX->tex = TREETILE_TEX;
				game_object *treeX = new game_object(characters.size(), TREE_ID, TREE_TEX);
				treeX->transform = tileX->transform;
				treeX->parent_to(camera);
				bad_guys.push_back(characters.size());
				colliders.push_back(characters.size());
				characters.push_back(treeX);
			}
			else if(tile_type >= 98)
			{
				tileX->tex = ROCKTILE_TEX;
				game_object *rockX = new game_object(characters.size(), ROCK_ID, ROCK_TEX);
				rockX->transform = tileX->transform;
				rockX->parent_to(camera);
				bad_guys.push_back(characters.size());
				colliders.push_back(characters.size());
				characters.push_back(rockX);
			}
			
		}
	}
	game_object *blob_character = new game_object(characters.size(), TILE_ID, BLOBTILE_TEX);
	blob_character->transform.translate(0.0,0.001,0.0);
	blob_character->transform.scale(2.0, 1.0, 3.0);
	characters.push_back(blob_character);

	last_update = (double)clock() / ((double)CLOCKS_PER_SEC);

	//GL boilerplate initialization
	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading
	glClearColor(0.5f, 0.5f, 0.5f, 0.5f);				// grey Background
	glClearDepth(1.0f);									// Depth Buffer Setup
	glEnable(GL_DEPTH_TEST);							// Enables Depth Testing				

	glEnable(GL_CULL_FACE);
	glShadeModel(GL_SMOOTH);
	glDepthFunc(GL_LEQUAL);								// The Type Of Depth Testing To Do
	glEnable(GL_COLOR_MATERIAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} 
Exemplo n.º 10
0
#include "global.hpp"
#include "hero.hpp"
#include "gettext.hpp"

hero hero_invalid = hero(HEROS_INVALID_NUMBER);

hero_map::iterator hero_map_iter_invalid = hero_map::iterator(HEROS_INVALID_NUMBER, NULL);
hero_map::const_iterator hero_map_const_iter_invalid = hero_map::const_iterator(HEROS_INVALID_NUMBER, NULL);

std::string hero::image_file_root_ = "";
std::string hero::gender_str_[HEROS_MAX_GENDER] = {};
std::string hero::arms_str_[HEROS_MAX_ARMS] = {};
std::string hero::skill_str_[HEROS_MAX_SKILL] = {};
std::string hero::feature_str_[HEROS_MAX_FEATURE] = {};
std::string hero::feature_desc_str_[HEROS_MAX_FEATURE] = {};
std::string hero::stratum_str_[HEROS_STRATUMS] = {};
std::string hero::status_str_[HEROS_STATUSES] = {};
std::string hero::official_str_[HEROS_OFFICIALS] = {};
std::map<int, std::string> hero::treasure_str_;
std::map<int, std::string> hero::character_str_;
std::vector<int> hero::valid_features_;

int hero::number_market = 272;
int hero::number_wall = 273;
int hero::number_keep = 274;
int hero::number_tower = 275;

static std::string null_str = "";
std::vector<hero*> empty_vector_hero_ptr = std::vector<hero*>();
std::vector<size_t> empty_vector_size_t = std::vector<size_t>();