void GameScene::initMoveableLayerGroup()
{
	moveableGroup = MoveableLayerGroup::create();
	moveableGroup->ignoreAnchorPointForPosition(false);
	moveableGroup->setAnchorPoint(Point(0, 0));
	this->addChild(moveableGroup);
	setMapSize(1.2f);
	focusPoint(false, 450, 450);
}
int GameScene::processBasicController()
{
	ButtonLayer* b = controllerGroup->getButtonLayer();

	if (b->isNeedResponse(BIG_MAP))
	{
		b->responsed(BIG_MAP);
		setMapSize(2.4f);
		focusPoint(false, lead->getPositionIndex());
	}
	if (b->isNeedResponse(SMALL_MAP))
	{
		b->responsed(SMALL_MAP);
		setMapSize(1);
		focusPoint(false, 0);
	}
	return NOEVENT;
}
GameOfLifeMain::GameOfLifeMain(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::GameOfLifeMain),
    map(new ColonyMap(this))

{
    ui->setupUi(this);

    // place colony widget on window
    QPalette Pal(palette());
    Pal.setColor(QPalette::Background, Qt::white);
    map->setAutoFillBackground(true);
    map->setPalette(Pal);
    ui->mapLayout->addWidget(map);

    // setting connections

    // connect control buttons to main slots of map
    connect(ui->startButton, SIGNAL(clicked(bool)),
            map, SLOT(gameStart()));
    connect(ui->stopButton, SIGNAL(clicked(bool)),
            map, SLOT(gameStop()));
    connect(ui->stepButton, SIGNAL(clicked(bool)),
            map, SLOT(nextGen()));
    connect(ui->resetButton, SIGNAL(clicked(bool)),
            map, SLOT(gameReset()));
    connect(ui->cleanColonyButton, SIGNAL(clicked(bool)),
            map, SLOT(cleanMap()));

    // saving and loading
    connect(ui->saveButton, SIGNAL(clicked(bool)),
            map, SLOT(saveMap()));
    connect(ui->loadButton, SIGNAL(clicked(bool)),
            map, SLOT(loadMap()));
    // cell color control
    connect(ui->cellColorButton, SIGNAL(clicked(bool)),
            map, SLOT(chooseCellColor()));

    // let size slider set map size
    connect(ui->colonySizeSlider, SIGNAL(valueChanged(int)),
            map, SLOT(setMapSize(int)));
    // while slider pressed, pause the game
    connect(ui->colonySizeSlider, SIGNAL(sliderPressed()),
            map, SLOT(gamePause()));
    // resume, when slider released
    connect(ui->colonySizeSlider, SIGNAL(sliderReleased()),
            map, SLOT(gameResume()));

    // let generation time slider change time interval
    connect(ui->generationTimeSlider, SIGNAL(valueChanged(int)),
            map, SLOT(setInterval(int)));

    connect(ui->colonySizeSpinBox, SIGNAL(editingFinished()),
            this, SLOT(setMapSize()));
    connect(ui->generationTimeSpinBox, SIGNAL(editingFinished()),
            this, SLOT(setInterval()));

    // Buttons must react to game running state
    connect(map, SIGNAL(gameRunning(bool)),
            ui->stepButton, SLOT(setDisabled(bool)));
    connect(map, SIGNAL(gameRunning(bool)),
            ui->startButton, SLOT(setDisabled(bool)));
    connect(map, SIGNAL(gameRunning(bool)),
            ui->stopButton, SLOT(setEnabled(bool)));

    // inform sliders, when size and tine interval changed
    connect(map, SIGNAL(sizeChanged(int)),
            ui->colonySizeSlider, SLOT(setValue(int)));
    connect(map, SIGNAL(intervalChanged(int)),
            ui->generationTimeSlider, SLOT(setValue(int)));

    connect(map, SIGNAL(generationLived(int)),
            ui->generationCountLabel, SLOT(setNum(int)));
}
Exemple #4
0
/*!
 * \brief the create button is pressed in the new city form
 */
static void
cnCreateButtonPressed(void)
{
	char *pGameName;
	FormPtr form;
	UInt8 level = 0;
	UInt8 width;
	UInt8 height;
	FieldPtr fp;
	MemHandle mh;
	MemPtr mp;

	InitGameStruct();

	form = FrmGetActiveForm();
	if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Easy)))
		level = 0;
	if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Medium)))
		level = 1;
	if (FrmGetControlValue(form, FrmGetObjectIndex(form, buttonID_Hard)))
		level = 2;
	setDifficultyLevel(level);

	if (FrmGetControlValue(form, FrmGetObjectIndex(form,
	    buttonID_dis_off)))
		level = 0;
	if (FrmGetControlValue(form, FrmGetObjectIndex(form,
	    buttonID_dis_one)))
		level = 1;
	if (FrmGetControlValue(form, FrmGetObjectIndex(form,
	    buttonID_dis_two)))
		level = 2;
	if (FrmGetControlValue(form, FrmGetObjectIndex(form,
	    buttonID_dis_three)))
		level = 3;
	setDisasterLevel(level);

	fp = (FieldPtr)GetObjectPtr(form, fieldID_width);
	mh = FldGetTextHandle(fp);
	mp = MemHandleLock(mh);
	width = (UInt8)StrAToI(mp);
	MemHandleUnlock(mh);
	fp = (FieldPtr)GetObjectPtr(form, fieldID_height);
	mh = FldGetTextHandle(fp);
	mp = MemHandleLock(mh);
	height = (UInt8)StrAToI(mp);
	MemHandleUnlock(mh);
	setMapSize(width, height);
	ConfigureNewGame();

	pGameName = FldGetTextPtr((FieldPtr)GetObjectPtr(form,
	    fieldID_newGameName));
	if (pGameName != NULL) {
		MemSet(game.cityname, CITYNAMELEN, '\0');
		StrNCopy((char *)game.cityname, pGameName, CITYNAMELEN);
		while (GameExists((char *)game.cityname)) {
			UInt16 slen = StrLen((char *)game.cityname);
			if (slen < CITYNAMELEN-1) {
				game.cityname[slen-1] = '0' - 1;
				game.cityname[slen] = '\0';
				slen++;
			}
			game.cityname[slen - 1]++;
		}
		SaveGameByName((char *)game.cityname);
		CleanSaveGameList();
		if (LoadGameByName((char *)game.cityname) != -1) {
			FrmEraseForm(form);
			form = FrmGetFormPtr(formID_files);
			if (form != NULL) {
				FrmEraseForm(form);
				FrmDeleteForm(form);
			}
			FrmGotoForm(formID_pocketCity);
		} else {
			UpdateSaveGameList();
		}
	} else {
		game.cityname[0] = '\0';
		WriteLog("No name specified\n");
	}
}
EntityManager::EntityManager():
	mMaxPlayerLife(5),
	mPlayerLife(mMaxPlayerLife),
	mZeroPlayerLife(0),
	mMapTop(360),
	mMapLeft(512),
	shadeAll(false),
	mCameraLastPos(0, 0),
	mCameraFakePos(0,0),
	mCameraSpeed(3),
	mBackgroundPos(-1024, -1024),
	mParalax(false),
	mMovingCamera(true),
	mCantMoveCharacters(false),
	mCameraDist(0,0),
	mFadeCount(0)
{		
		emote[0] = 0;
		emote[1] = 0;
		emote[2] = 0;
		emote[3] = 0;
		frame[0] = Animation("frame.png", 60, 1, 84, 84);
		frame[1] = Animation("frame.png", 60, 1, 84, 84);
		frame[2] = Animation("frame.png", 60, 1, 84, 84);
		frame[3] = Animation("frame.png", 60, 1, 84, 84);
		mPortraitSprite[0] = Animation("Kiba portraites spritesheet.png",	60, 1, 64, 64);
		mPortraitSprite[1] = Animation("charlotteportrait.png",				60, 1, 64, 64);
		mPortraitSprite[2] = Animation("Fenrir Face sprite 1_1.png",		60, 1, 64, 64);
		mPortraitSprite[3] = Animation("Sheeka Face sprite 1_1.png",		60, 1, 64, 64);
		
		shadow.loadFromFile("greyscale.frag", sf::Shader::Fragment);
		shadow.setParameter("texture", sf::Shader::CurrentTexture);
		
		mLifeTexture.loadFromImage(*ImageManager::getImage("heart.png"));
		mLifeSprite.setTexture(mLifeTexture);
		//mLifeFrameTexture.loadFromImage(*ImageManager::getImage("LifeFrame.png"));
		//mLifeFrameSprite.setTexture(mLifeFrameTexture);
		mDeathTexture.loadFromImage(*ImageManager::getImage("DieScreen.png"));
		mDeathSprite.setTexture(mDeathTexture);
		mDeathSprite.setColor(sf::Color(mDeathSprite.getColor().r, mDeathSprite.getColor().r, mDeathSprite.getColor().r, 0));
		mMaskTexture.loadFromImage(*ImageManager::getImage("mask.png"));
		mMaskSprite.setTexture(mMaskTexture);
		mBackgroundTexture.loadFromImage(*ImageManager::getImage("background.png"));
		createBackground();
		setMapSize(61, 28);


		//mLightSystem = MyLightSystem::getLightSystem();
		//
		//mLight = new ltbl::Light_Point(); 
		//mLight->m_intensity = 100.0f; 
		//mLight->m_radius = 400.0f; 
		//mLight->m_size = 700.0f; 
		//mLight->m_spreadAngle = ltbl::pifTimes2; 
		//mLight->m_softSpreadAngle = 0.0f;
		//mLight->CalculateAABB();
		//mLight->m_color.r = 0.5f; 
		//mLight->m_color.g = 0.5f; 
		//mLight->m_color.b = 0.5f;
		//mLight->m_bleed = 1.0f; 
		//mLight->m_linearizeFactor = 2.0f; 

		//mLightSystem->AddLight(mLight); 
		//mLight->SetAlwaysUpdate(true); 

}