//************************************************************************
// Initializes the screen 
//************************************************************************
bool CNotificationScreen::Initialize()
{
	if(!CScreen::Initialize())
		return false;

	m_EventText.Initialize();
	m_MessageText.Initialize();
	m_TitleText.Initialize();
	m_Scrollbar.Initialize();
	m_Timestamp.Initialize();

	m_Timestamp.SetAlignment(DT_RIGHT);

	m_TitleText.SetText(_T("Trillian"));
	m_TitleText.SetAlignment(DT_LEFT);
	
	m_EventText.SetAlignment(DT_CENTER);
	m_EventText.SetWordWrap(TRUE);

	m_MessageText.SetScrollbar(&m_Scrollbar);

	UpdateObjects();

	AddObject(&m_Scrollbar);
	AddObject(&m_EventText);
	AddObject(&m_MessageText);
	AddObject(&m_TitleText);
	AddObject(&m_Timestamp);

	SetButtonBitmap(0,IDB_UP);
	SetButtonBitmap(1,IDB_DOWN);

	return true;
}
Example #2
0
//************************************************************************
// Initializes the screen 
//************************************************************************
bool CChatScreen::Initialize()
{
	if(!CScreen::Initialize())
		return false;

	m_InfoText.Initialize();
	m_UserName.Initialize();
	m_UserStatus.Initialize();
	m_UserProto.Initialize();
	m_Input.Initialize();
	m_TextLog.Initialize();
	m_Scrollbar.Initialize();
	
	UpdateObjects();
	// other attributes
		m_InfoText.SetAlignment(DT_CENTER);
		m_InfoText.SetWordWrap(TRUE);
		m_InfoText.SetText(_T(""));
		m_InfoText.Show(0);

		m_UserName.SetAlignment(DT_CENTER);
		m_UserName.SetWordWrap(TRUE);
		m_UserName.SetText(_T("Proto"));


		m_UserStatus.SetAlignment(DT_LEFT);
		m_UserStatus.SetWordWrap(TRUE);
		m_UserStatus.SetText(_T("Status"));
	
		
		m_UserProto.SetAlignment(DT_RIGHT);
		m_UserProto.SetWordWrap(TRUE);
		m_UserProto.SetText(_T("User"));

		m_Input.Show(0);
	
		
		
		m_TextLog.Show(1);
		
	
	
		m_TextLog.SetScrollbar(&m_Scrollbar);

		AddObject(&m_Scrollbar);
		AddObject(&m_TextLog);
		AddObject(&m_Input);
		AddObject(&m_InfoText);
		AddObject(&m_UserName);
		AddObject(&m_UserStatus);
		AddObject(&m_UserProto);


	SetButtonBitmap(0,IDB_UP);
	SetButtonBitmap(1,IDB_DOWN);
	SetButtonBitmap(2,IDB_HISTORY);
	SetButtonBitmap(3,IDB_REPLY);

	return true;
}
Example #3
0
//************************************************************************
// maximizes the content object
//************************************************************************
void CChatScreen::Maximize(DWORD dwTimer)
{
	m_bMaximizedTimer = true;
	m_dwMaximizedTimer = GetTickCount();
	m_dwMaximizedDuration = dwTimer;
	UpdateObjects();
}
Example #4
0
//************************************************************************
// Called when the applet's configuration has changed
//************************************************************************
void CChatScreen::OnConfigChanged()
{
	CScreen::OnConfigChanged();

	UpdateObjects();

	m_TextLog.ClearLog();
	LoadHistory();
}
Example #5
0
void GameEngine::Update(MasterControl* Control){
    Timer::Update();
    HandleEvents(Control);
    UpdateObjects();
    if (CollisionTimer.IsTime()){
        CollisionDetection();
    }
    if (RenderTimer.IsTime()){
        Draw();
    }
}
Example #6
0
void ClearObjects()
{
	for (int i = 0; i < NUM_OBJECTS; ++i)
	{
		// This can't just set all the attributes to 0, because an object
		// with attr0 == 0 is actually visible.
		SetObject(i, ATTR0_HIDE, 0, 0);
	}

	UpdateObjects();
}
Example #7
0
void Pause_Draw()
{
	//Pause draw routines go here
	// Write "PAUSED" on BG0.
	SetTile(27, 10, 10, 96);
	SetTile(27, 12, 10, 97);
	SetTile(27, 14, 10, 98);
	SetTile(27, 16, 10, 99);
	SetTile(27, 18, 10, 100);
	SetTile(27, 20, 10, 101);
	
	// Update Objects
	UpdateObjects();
}
Example #8
0
//  Take a 'turn' (throw three darts)
void Player::TakeTurn(int cursoractual[], int cursorpos[], int BGPos[], bool playertothrow) {
	int throws = 3;
	int wait = 0;
	p_turnthrows = 0;
	p_turnstartpoints = p_points;
	SetTile(27, 23+5*playertothrow, 1, 5);
	SetTile(27, 23+5*playertothrow-1, 1, 5);
	SetTile(27, 23+5*playertothrow-2, 1, 5);
	
	while ((throws > 0 && p_points > 0) || wait < 40) {
		UpdateObjects();
		
		if (throws > 0 && p_points > 0) {	
			WaitVSync();
			UpdateObjects();
			TakeAShot(cursoractual, cursorpos, BGPos);
			DrawPoints(20+5*playertothrow, 4 + p_throws);
			
			SetTile(27, 23+5*playertothrow-p_turnthrows, 1, 4);
			
			p_throws++;
			p_turnthrows++;
			throws--;
		} else {
			wait++;
		}
		
		for (int i = 0; i < p_turnthrows; i++) {
			darts[i].UpdateDart(BGPos);			
		}
	}
	SetTile(27, 23+5*playertothrow, 1, 4);
	SetTile(27, 23+5*playertothrow-1, 1, 4);
	SetTile(27, 23+5*playertothrow-2, 1, 4);
	ClearObjects();
}
bool EDetailManager::Initialize()
{
	if (m_SnapObjects.empty()){
    	ELog.DlgMsg(mtError,"Snap list empty!");
    	return false;
    }
	if (!m_Base.Valid()){
    	ELog.DlgMsg(mtError,"Base texture empty!");
    	return false;
    }				
    if (!UpdateHeader())                return false;
    m_Base.CreateRMFromObjects			(m_BBox,m_SnapObjects);
    if (!UpdateSlots()) 		   		return false;
    if (!objects.empty()&&!UpdateObjects(false,false))	return false;
	return true;
}
Example #10
0
nuiObjectInspector::nuiObjectInspector()
: mSink(this)
{
  SetObjectClass(_T("nuiObjectInspector"));
  
  // decoration
  nuiDecoration* pDeco = nuiDecoration::Get(INTROSPECTOR_DECO_CLIENT_BKG);
  mpImage = NULL;
  mpAttributeGrid = NULL;
  
  if (pDeco)
  {
    SetDecoration(pDeco, eDecorationBorder);
  }
  
  UpdateObjects();
  //mSink.Connect(nuiObject::ObjectsChanged, &nuiObjectInspector::OnObjectsChanged);
}
Example #11
0
void NWApp::CalcActor()
{
	Camera cam = GetCame();
	cam.fCamX = m_player.m_fX;
	cam.fCamY = m_player.m_fY;
	cam.fCamZ = m_player.m_fZ;
	cam.fCamAng = m_player.m_fAngle;
	SetCam(cam);

	if (m_player.GetMoveStatus() & MoveUp)
	{
		m_player.MoveUp();
	}
	else if (m_player.GetMoveStatus() & MoveDown)
	{
		m_player.MoveDown();
	}

	if (m_player.GetMoveStatus() & MoveTurnLeft)
	{
		m_player.TurnLeft();
	}
	else if (m_player.GetMoveStatus() & MoveTurnRight)
	{
		m_player.TrunRight();
	}

	if (m_player.GetMoveStatus())
	{
		m_plink->SendPlayerPos(m_player.m_fX, m_player.m_fY, m_player.m_fZ, m_player.m_fAngle);
	}

	auto list = m_plink->GetObjectList();
	if (list.size() > 0)
	{
		UpdateObjects(list);
	}

	auto listRemove = m_plink->GetRemoveList();
	if (listRemove.size() > 0)
	{
		RemoveObjects(listRemove);
	}
}
Example #12
0
// Play a single leg, resetting all necessary numbers before doing so.
void Leg::Play(Player players[], int BGPos[], int cursorpos[], int cursoractual[]) {
	
	players[0].ResetForNextLeg();
	players[1].ResetForNextLeg();
	ClearScreenBlocks(25,31);
	DrawDartboard();
	DrawWindow(19, 0, 11, 20);
	players[0].DrawName(20,2);
	players[1].DrawName(25,2);
	players[0].DrawPoints(20,3);
	players[1].DrawPoints(25,3);

	bool running = true;
	int pointsdisplay = 1;		//  remember number of lines of points displayed so far

	//  Game loop
	//  flip-flop between players 1 and 2, after each turn check for a winner
	while (running)
	{
		UpdateObjects();
		
		playertothrow = !playertothrow;
		players[playertothrow].TakeTurn(cursoractual, cursorpos, BGPos, playertothrow);
		
		if (playertothrow == 1) {	
			pointsdisplay++;
		}
		if (players[playertothrow].GetPoints() == 0) {
			running = false;
		}
	}
	
	//  Once someone wins clear screen and display winner
	ClearScreenBlocks(25,31);
	DrawWindow(0, 0, 30, 20);
	players[playertothrow].DrawName(13, 8);
	players[playertothrow].p_legwins[setnumber]++;
	DrawText(13, 10, "Wins the Leg!", 25);	
	for (int i = 0; i < DELAY; i++) {
		WaitVSync();
	}	
	
}
Example #13
0
int main()
{
	// Set display options.
	// DCNT_MODE0 sets mode 0, which provides four tiled backgrounds.
	// DCNT_OBJ enables objects.
	// DCNT_OBJ_1D make object tiles mapped in 1D (which makes life easier).
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ;
	
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32 | BG_PRIO(0);
	
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32 | BG_PRIO(1);
	
	REG_BG2CNT = BG_CBB(0) | BG_SBB(25) | BG_8BPP | BG_REG_64x64 | BG_PRIO(2);
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	
	ClearObjects();
	
	SetPaletteBG(1, RGB(31, 31, 31)); // white
	
	//Load each tile in font_bold into it's corresponding position in charblock 0
	for (int i = 0; i < 128; i++)
	{
		LoadTile8(0, i, font_bold[i]);
	}
	
	DrawText(5, (SCREEN_HEIGHT / 16) - 2, "DECEPTIVE DIMENSIONS");
	DrawText(5, (SCREEN_HEIGHT / 16), "Press start to begin");
	
	Buttons buttons;
	int framecounter = 0;
	
	//Title screen (under construction)
	while (true)
	{
		buttons.Update();
		
		if (buttons.StartJustPressed())
		{
			break;
		}
		
		WaitVSync();	
	}
	
	while (true)
	{
		//Load Custom spritesheet
		LoadPaletteObjData(0, spritesheet4Pal, sizeof spritesheet4Pal);
		LoadPaletteBGData(0, backgroundnewnewPal, sizeof backgroundnewnewPal);
		LoadTileData(4, 0, spritesheet4Tiles, sizeof spritesheet4Tiles);
		LoadTileData(0, 0, backgroundnewnewTiles, sizeof backgroundnewnewTiles);
		
		int levelnumber = 1;
		
		Level level(levelnumber);
		
		for (int screenblock = 21; screenblock < 31; screenblock++)
		{
			level.FillScreenblock(screenblock, 0);
		}
		
		level.DrawBackground(level.curdimension);
		
		bool gamerunning = true;
		
		//Main game loop
		while (gamerunning)
		{
			buttons.Update();
			
			gamerunning = level.CheckIfLevelComplete();
			level.TakeInput(buttons);
			level.MoveObjects();
			level.Draw();
			level.UpdateLevelObjects(framecounter);

			framecounter++;
			
			WaitVSync();
			FlipBuffers();
		}
		
		//Reload each tile in font_bold into it's corresponding position in charblock 0
		for (int i = 0; i < 128; i++)
		{
			LoadTile8(0, i, font_bold[i]);
		}
		
		SetPaletteBG(0, RGB(0, 0, 0)); // black
		SetPaletteBG(1, RGB(31, 31, 31)); // white		
		
		for (int screenblock = 25; screenblock < 31; screenblock++)
		{
			for (int y = 0; y < 32; y++)
			{
				for (int x = 0; x < 32; x++)
				{
					SetTile(screenblock, x, y, 0);
				}
			}
		}
		
		level.player.drawx = SCREEN_WIDTH;
		
		SetObject(level.player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_HIDE,
		  ATTR1_SIZE(2) | ATTR1_X(level.player.drawx),
		  ATTR2_ID8(0) | ATTR2_PRIO(2));
		
		UpdateObjects();
		
		DrawText(6, (SCREEN_HEIGHT / 16) - 2, "That's all folks!!");
		DrawText(3, (SCREEN_HEIGHT / 16), "Press start to try again");
		
		while (true)
		{
			buttons.Update();
			
			if (buttons.StartJustPressed())
			{
				break;
			}
			
			WaitVSync();
		}
	}
}
Example #14
0
void enterMenu(int menu){
	LoadPaletteBGData(0, menuBGPal, menuBGPalLen);
	
	bool active = true;
	int option = 0;
	int keyPressCoolDown = 30;
	if(menu == 0)ClearObjects();
	
	//MENU LOOP
	while(active){
		keyPressCoolDown--;
		if(keyPressCoolDown <= 0)keyPressCoolDown = 0;
		clearText();
		switch(menu){
			case 0://Main menu
			if((REG_KEYINPUT & KEY_UP) == 0){
				option = 0;
			}
			if((REG_KEYINPUT & KEY_DOWN) == 0){
				option = 1;
			}
			if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){
				if(option == 0){
					active = false;
					gameInit();
				}else{
					menu = 1;
					keyPressCoolDown = 30;
				}
			}
			drawText(60,20,"Super Crate Box");
			drawText(105,65,"PLAY");
			drawText(93,90,"CREDITS");
			
			if(option == 0)drawText(90, 65, ">      <");
			if(option == 1)drawText(78, 90, ">         <");
			break;
			
			case 1://Credits
			if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){
				menu = 0;
				keyPressCoolDown = 30;
			}
			if((REG_KEYINPUT & KEY_B) == 0 && keyPressCoolDown == 0){
				menu = 0;
				keyPressCoolDown = 30;
			}
			
			drawText(30, 20, "GBA - Super Crate Box");
			drawText(30,60, "Created by Peter Black");
			drawText(70,80, "for CGA 2014");
			drawText(8, 135, "Assets & Gameplay C Vlambeer");
			break;
			
			case 2://Game Over
			if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){
				active = false;
				gameInit();
			}
			if((REG_KEYINPUT & KEY_B) == 0 && keyPressCoolDown == 0){
				menu = 0;
				ClearObjects();
				keyPressCoolDown = 30;
			}
		
			drawText(82,60,"GAME OVER");
			drawText(85,80,"Score:");
			drawText(133,80,toString(score));
			drawText(77, 125,"A = Retry");
			drawText(65, 135,"B = Main Menu");
			
			
			break;
		}
		
		
		WaitVSync();
		UpdateObjects();
	}
	
	LoadPaletteBGData(0, backgroundPal, backgroundPalLen);
}
void GraphicsManager::Draw(EntityManager* entity_manager)
{
	// Check for new renderable entities TODO

	// Get all renderable components
	vector<IComponent*> renderable_components = entity_manager->GetAllComponentsOfType(COMP_RENDER);

	int i = 0;
	// Iterate through the object components
	for (vector<IComponent*>::iterator it = renderable_components.begin(); it != renderable_components.end(); ++it)
	{
		RenderComponent* renderableComponent = (RenderComponent*)(*it);
		SpriteDefinition spriteDef = GetSpriteDefinition(renderableComponent->_id);

		int x = renderableComponent->_position.x;
		int y = renderableComponent->_position.y;

		if (x < 0)
			x = 511 + x;
		if (y < 0)
			y = 255 + y;

			
		
		SetObject(i, (spriteDef.shape << 14) | ATTR0_Y(y) | ATTR0_8BPP | ATTR0_AFF,
			ATTR1_SIZE(spriteDef.size) | ATTR1_X(x) | ATTR1_AFF(0),
			ATTR2_PALBANK(0) | ATTR2_ID4(spriteDef.char_bb_identifier));
		
		ObjAffine* renderAffine = &( (ObjAffine*) ObjBuffer)[0];
	
	
		//float theta = (float)(++player.angleDegrees % 360) * (M_PI/180);
		float angle = (float)(renderableComponent->_angleDegrees % 360) * (M_PI / 180);
		renderAffine->pa = float2fx( cos(angle) );
		renderAffine->pb = float2fx( -sin(angle) );	
		renderAffine->pc = float2fx( sin(angle) );
		renderAffine->pd = float2fx( cos(angle) );
		
		++i;
	}
	UpdateObjects();

	// Get all background components
	vector<IComponent*> background_components = entity_manager->GetAllComponentsOfType(COMP_BACKGROUND);

	// Iterate through the background components
	for (vector<IComponent*>::iterator it = background_components.begin(); it != background_components.end(); ++it)
	{
		BackgroundComponent* backgroundComponent = (BackgroundComponent*)(*it);

		
		// Scroll background
		if (backgroundComponent->_background_id == BG_PIPES)
		{
			REG_BG1HOFS = backgroundComponent->_integer_position.x;
		}
		
		// Update tiles
		if (backgroundComponent->_background_id == BG_PIPES || backgroundComponent->_background_id == BG_SCORE)
		{
			
			for (int x = 0; x < 32; x++)
			{
				for (int y = 0; y < 32; y++)
				{
					DisplayTile(x, y, backgroundComponent->_tiles[x][y], backgroundComponent->_screen_bb);
				}
			}
		}
		
		if (backgroundComponent->_update_screen)
		{
			for (int x = 0; x < 32; x++)
			{
				for (int y = 0; y < 32; y++)
				{
					DisplayTile(x, y, backgroundComponent->_tiles[x][y], backgroundComponent->_screen_bb);
				}
			}
			backgroundComponent->_update_screen = false;
		}
	}

}
Example #16
0
//  Throw a single dart, handles both AI and Player controlled, if a player than enable cursor and wait for input
//  if computer then call target select functions and decide what to do with results by passing to DartLocationDecide()
void Player::TakeAShot(int cursoractual[], int cursorpos[],int BGPos[]){
	bool wait = true;
	oldkey[A_KEY] = true;

	if (p_ishuman == true) {		
		while (wait) {
			WaitVSync();
			UpdateObjects();
			HandleCursorMovement(cursoractual, cursorpos, BGPos);
			
			for (int i = 0; i < p_turnthrows; i++) {
				darts[i].UpdateDart(BGPos);			
			}
			
			if ((REG_P1 & KEY_A) == 0 && oldkey[A_KEY] == false) {
				GetPointsValue(cursoractual, BGPos);
				wait = false;
				oldkey[A_KEY] = true;
			}
			if ((REG_P1 & KEY_A) != 0) {
				oldkey[A_KEY] = false;
			}
		}
		if (p_colinmode) {
			Inaccuracy();
			DartLocationDecide();
			darts[p_turnthrows] = Dart(p_darthitloc[0], p_darthitloc[1], p_turnthrows+1);					
		} else {	
			darts[p_turnthrows] = Dart(cursoractual[0]+BGPos[0], cursoractual[1]+BGPos[1], p_turnthrows+1);	
		}
	} else {
		for (int animate = 0; animate < 10; animate++) {
			WaitVSync();
			UpdateObjects();
			for (int i = 0; i < p_turnthrows; i++) {
				darts[i].UpdateDart(BGPos);			
			}					
		}
		for (int i  = DELAY; i > 0; i--) {
			WaitVSync();
		}		
		TargetSelect(0);
		Inaccuracy();
		DartLocationDecide();
		BGPos[0] = p_darthitloc[0]-80;
		BGPos[1] = p_darthitloc[1]-80;
		
		REG_BG3HOFS = BGPos[0];
		REG_BG3VOFS = BGPos[1];	
		darts[p_turnthrows] = Dart(p_darthitloc[0], p_darthitloc[1], p_turnthrows+1);
	}
	if (CheckLegality(p_hit)) {
		p_points -= p_hit;	
		DrawText(20, 17, "          ", 25);
		if (p_targettype == 0) {
			DrawText(20, 17, "Single", 25);
			DrawNumber(27, 17, (p_hit), 25);
		} else if (p_targettype == 1) {
			DrawText(24, 17, "Bull", 25);
		} else if (p_targettype == 2) {
			DrawText(20, 17, "Double", 25);
			DrawNumber(27, 17, (p_hit/2), 25);
		} else if (p_targettype == 3) {
			DrawText(20, 17, "Treble", 25);
			DrawNumber(27, 17, (p_hit/3), 25);
		} else if (p_targettype == 4) {
			DrawText(21, 17, "BullsEye", 25);
		} else {
			DrawText(24, 17, "Miss", 25);
		}				
	} else {
		DrawText(20, 17, "  Illegal   ", 25);
	}

}
Example #17
0
void nuiObjectInspector::OnObjectsChanged(const nuiEvent& rEvent)
{
  UpdateObjects();
}
Example #18
0
int main()
{
    LoadAssets();
    ClearObjects();
    InitialiseStage();

    uint16_t oldKeys = REG_P1;

    Cursor cursor = Cursor(0);

    bool pieceSelected = false;
    int currentPiece = 0;
    int* moves = new int[28];
    int* takingMoves = new int[16];

    int currentTurnColor = WHITE;
    for(int i = 0; i < 2; i++)
        for(int j = 0; j < 16; j++)
            _lostPieces[i][j] = -1;


    while (true)
    {
        if(!(REG_P1 & KEY_RIGHT) && (oldKeys & KEY_RIGHT))
            cursor.Move(1,  0);
        if(!(REG_P1 & KEY_LEFT) && (oldKeys & KEY_LEFT))
            cursor.Move(-1, 0);
        if(!(REG_P1 & KEY_DOWN) && (oldKeys & KEY_DOWN))
            cursor.Move(0,  1);
        if(!(REG_P1 & KEY_UP) && (oldKeys & KEY_UP))
            cursor.Move(0, -1);

        if(!(REG_P1 & KEY_A) && (oldKeys & KEY_A))
        {
            if(PieceAt(cursor.X(), cursor.Y()))
            {
                pieceSelected = true;
                for(int i = 0; i < 16 && takingMoves[i] >= 0; i++)
                    if(takingMoves[i] % 8 == cursor.X() && takingMoves[i] / 8 == cursor.Y())
                    {
                        TakePiece(currentPiece % 8, currentPiece / 8, cursor.X(), cursor.Y());
                        currentTurnColor = (currentTurnColor == WHITE ? BLACK : WHITE);
                        pieceSelected = false;
                        ClearHighlights();
                        takingMoves[0] = -1;
                        break;
                    }

                if(pieceSelected && PieceColor(cursor.X(), cursor.Y()) == currentTurnColor)
                {
                    ClearHighlights();

                    AvailableMoves(cursor.X(), cursor.Y(), moves, takingMoves);

                    currentPiece = cursor.Y() * 8 + cursor.X();

                    for(int i = 0; i < 28 && moves[i] >= 0; i++)
                        Highlight(moves[i] % 8, moves[i] / 8, GREEN);

                    for(int i = 0; i < 16 && takingMoves[i] >= 0; i++)
                        Highlight(takingMoves[i] % 8, takingMoves[i] / 8, RED);
                }
            }
            else if(pieceSelected)
            {
                ClearHighlights();

                if(!PieceAt(cursor.X(), cursor.Y()))
                {
                    for(int i = 0; i < 28 && moves[i] >= 0; i++)
                        if(moves[i] % 8 == cursor.X() && moves[i] / 8 == cursor.Y())
                        {
                            MovePiece(currentPiece % 8, currentPiece / 8, cursor.X(), cursor.Y());
                            currentTurnColor = (currentTurnColor == WHITE ? BLACK : WHITE);
                            pieceSelected = false;
                            break;
                        }
                }
            }
        }

        oldKeys = REG_P1;

        if(currentTurnColor == WHITE)
            DrawString(20, 1, "WHITE", 5);
        else
            DrawString(20, 1, "BLACK", 5);

        WaitVSync();
        UpdateObjects();
    }

    return 0;
}
Example #19
0
//************************************************************************
// Called when the configuration has changed
//************************************************************************
void CNotificationScreen::OnConfigChanged()
{
	CScreen::OnConfigChanged();

	UpdateObjects();
}
Example #20
0
int main()
{
	init();
	
	enterMenu(0);

	int cloudScroll = 0;
	int loopSlower = 0;
	bool shootCoolDown = true;
	int reloadTimer = 0;
	
	//GAME LOOP
	while (true)
	{	
		//INPUT
		if((REG_KEYINPUT & KEY_RIGHT) == 0){
			tryMove(2,0,player.getWidth()-2,player.getHeight()/2,player);
			player.setRunning(true);
			player.setDir(true);
		}
		if((REG_KEYINPUT & KEY_LEFT) == 0){
			tryMove(-2,0,0,player.getHeight()/2,player);
			player.setRunning(true);
			player.setDir(false);
		}
		if((REG_KEYINPUT & KEY_UP) == 0 || (REG_KEYINPUT & KEY_B) == 0){
			if(player.getLanded()){
				player.jump();
				player.updateFrame();
			}
			player.setJumpHeight(player.getJumpHeight()+4);
		}
		if((REG_KEYINPUT & KEY_A) == 0){
			if(shootCoolDown){
				if(weapon == 8){
					if(player.getDir())tryMove(-2,0,0,player.getHeight()/2,player);
					else tryMove(2,0,player.getWidth()-2,player.getHeight()/2,player);
				}else if(weapon == 1){
					if(player.getDir())tryMove(-1,0,0,player.getHeight()/2,player);
					else tryMove(1,0,player.getWidth()-2,player.getHeight()/2,player);
				}
				shoot();
				shootCoolDown = false;
				reloadTimer = 0;
			}
		}
		
		//Player movement
		if(player.getJumping()){
			if(!tryMove(0,-3,player.getWidth()/2,0,player)){
				player.setJumping(false);
			}
		}else{
			if(!tryMove(0,2,player.getWidth()/2,player.getHeight(),player)){
				tryMove(0,1,player.getWidth()/2,player.getHeight(),player);
				player.setLanded(true);
				player.setJumping(false);
			}else{
				player.setLanded(false);
			}
		}

		//Monster Movement
		for(int i = 0; i < enemies.size(); i++){
			if(!enemies.at(i).isDead()){
				if(enemies.at(i).getDir()){
					if(!tryMove(1,0,enemies.at(i).getWidth(),(enemies.at(i).getHeight()/2)+1,enemies.at(i))){
						enemies.at(i).setDir(false);
					}
				}else{
					if(!tryMove(-1,0,0,(enemies.at(i).getHeight()/2)+1,enemies.at(i))){
						enemies.at(i).setDir(true);
					}
				}
				tryMove(0,2,enemies.at(i).getWidth()/2,enemies.at(i).getHeight(),enemies.at(i));
				ObjBuffer[i+3].attr0 &= ~(ATTR0_HIDE);
			}else{
				ObjBuffer[i+3].attr0 |= ATTR0_HIDE;
			}
		}
		
		//Bullet movement
		for(int i = 0; i < bullets.size(); i++){
			if(!bullets.at(i).isDead()){
			
				int yMove = 0;
				if(rand() % 3 == 0)yMove = bullets.at(i).getLift(); 
				
				if(bullets.at(i).getType() == 4){
				
					tryMove(0,1,bullets.at(i).getWidth(),bullets.at(i).getHeight()+4,bullets.at(i));
					
				}else if(bullets.at(i).getType() == 6){
					if(player.getDir()){
						ObjBuffer[i+24].attr1 &= ~(ATTR1_HFLIP);
						bullets.at(i).move(player.getX()+8, player.getY());
					}else{
						ObjBuffer[i+24].attr1 |= ATTR1_HFLIP;
						bullets.at(i).move(player.getX()-8, player.getY());
					}	
					if(bullets.at(i).charge()){
						bullets.at(i).setDead(true);
						int number = 0;
						if(player.getDir())number = (SCREEN_WIDTH - player.getX())/8;
						else number = (0 + player.getX())/8;
	
						for(int i = 0; i < number; i++){
							spawnBullet(7);
						}
					}
				}else if(bullets.at(i).getType() == 7){
					if(bullets.at(i).charge())bullets.at(i).setDead(true);
				}else{
					if(bullets.at(i).getDir()){
						if(!tryMove(2,yMove,bullets.at(i).getWidth(), bullets.at(i).getHeight(), bullets.at(i))){	
							if(bullets.at(i).getType() == 3 && !bullets.at(i).getBounce()){
								bullets.at(i).setBounce(true);
								bullets.at(i).setDir(false);
							}else{
								bullets.at(i).setDead(true);
								if(bullets.at(i).getType() == 0
								|| bullets.at(i).getType() == 4){
									explode(bullets.at(i).getX(), bullets.at(i).getY());
								}
							}
						}
					}else{ 
						if(!tryMove(-2,yMove,bullets.at(i).getWidth(), bullets.at(i).getHeight(), bullets.at(i))){
							if(bullets.at(i).getType() == 3 && !bullets.at(i).getBounce()){
								bullets.at(i).setBounce(true);
								bullets.at(i).setDir(true);
							}else{
								bullets.at(i).setDead(true);
								if(bullets.at(i).getType() == 0
								|| bullets.at(i).getType() == 4){
									explode(bullets.at(i).getX(), bullets.at(i).getY());
								}
							}
						}
					}
				}
				ObjBuffer[i+24].attr0 &= ~(ATTR0_HIDE);
			}else{
				ObjBuffer[i+24].attr0 |= ATTR0_HIDE;
			}
		}
		
		for(int i = 0; i < enemies.size(); i++){
			if(!enemies.at(i).isDead()){
				if(checkEntityCollision(player, enemies.at(i))){
					player.setDead(true);
				}
				
				for(int k = 0; k < bullets.size(); k++){
					if(!bullets.at(k).isDead()){
						if(checkEntityCollision(bullets.at(k), enemies.at(i))){
							enemies.at(i).hurt(bullets.at(k).getDamage());
							if(bullets.at(k).getType() != 3
							&& bullets.at(k).getType() != 6
							&& bullets.at(k).getType() != 7){
								bullets.at(k).setDead(true);
								if(bullets.at(k).getType() == 0
								|| bullets.at(k).getType() == 4){
									explode(bullets.at(k).getX(), bullets.at(k).getY());
								}
							}
							break;
						}
					}
				}
			}
		}
		
		if(checkEntityCollision(player, crate)){
			crate.setDead(true);
			weapon = crate.getWeapon();
			score++;
		}
		
		if(crate.isDead()){
			switch(rand() % 7){
				case 0:crate.move(80,32);
				break;
				case 1:crate.move(150,32);
				break;
				case 2:crate.move(30,64);
				break;
				case 3:crate.move(200,64);
				break;
				case 4:crate.move(115,104);
				break;
				case 5:crate.move(80,144);
				break;
				case 6:crate.move(150,144);
				break;
			}
			int newWep = 0;
			do newWep = rand() % 9;
			while(newWep == weapon || newWep == 6);
			crate.setWeapon(newWep);
			crate.setDead(false);
		}
		
		//General Slow things
		if(loopSlower % 7 == 0){
			cloudScroll++;
			REG_BG3HOFS = cloudScroll;
		
			SetTile(30, 14, 19, 16+rand()%5);
			SetTile(30, 15, 19, 16+rand()%5);
			
			player.updateFrame();
			
			for(int i = 0; i < enemies.size(); i++){
				if(!enemies.at(i).isDead()){
					enemies.at(i).updateFrame();
				}
			}
			ObjBuffer[2].attr2 = ATTR2_ID8(player.getFrame());
			for(int i = 0; i < enemies.size(); i++){
				ObjBuffer[i+3].attr2 = ATTR2_ID8(enemies.at(i).getFrame());
			}
			
		}
		
		reloadTimer++;
		if(weapon == 0 || weapon == 5 || weapon == 6 || weapon == 7){
			if(reloadTimer >= 60){
				shootCoolDown = true;
			}
		}else if(weapon == 2 || weapon == 4){
			if(reloadTimer >= 45){
				shootCoolDown = true;
			}
		}else if (weapon == 3){
			if(reloadTimer >= 20){
				shootCoolDown = true;
			}
		}else if(weapon ==  1){
			if(reloadTimer >= 10){
				shootCoolDown = true;
			}
		}else{
			if(reloadTimer >= 5){
				shootCoolDown = true;
			}
		}
		if(reloadTimer > 1000)reloadTimer = 60;
		
		//Monster spawner
		if(rand()%100 == 0){
			spawnMonster();	
		}
		
		//Player state updates
		if(player.getJumping())player.setState(2);
		else if(player.getRunning())player.setState(1);
		else player.setState(0);
		
		if(!player.getDir()){
			ObjBuffer[0].attr1 |= ATTR1_HFLIP;
			ObjBuffer[2].attr1 |= ATTR1_HFLIP;
		}else{
			ObjBuffer[0].attr1 &= ~(ATTR1_HFLIP);
			ObjBuffer[2].attr1 &= ~(ATTR1_HFLIP);
		}
		
		if(weapon == 8)ObjBuffer[0].attr0 |= ATTR0_SHAPE(1);
		else ObjBuffer[0].attr0 &= ~(ATTR0_SHAPE(1));
		
		ObjBuffer[0].attr2 = ATTR2_ID8(22+weapon);
			
		for(int i = 0; i < enemies.size(); i++){
			if(!enemies.at(i).isDead()){
				if(!enemies.at(i).getDir())ObjBuffer[i+3].attr1 |= ATTR1_HFLIP;
				else ObjBuffer[i+3].attr1 &= ~(ATTR1_HFLIP);
			}
		}
		
		player.update();
		
		if(player.isDead())enterMenu(2);
	
		//Render
		if(!player.getDir()){
			if(weapon != 8)SetObjectX(0, player.getX()-4);
			else{
				if(player.getX()-12 <= 0) SetObjectX(0, 0);
				else SetObjectX(0, player.getX()-12);
			}	
		}else{
			SetObjectX(0, player.getX()+4);
		}
		SetObjectY(0, player.getY()+1);
		
		SetObjectX(1, crate.getX());
		SetObjectY(1, crate.getY());
		
		SetObjectX(2, player.getX());
		SetObjectY(2, player.getY());
		
		for(int i = 0; i < enemies.size(); i++){
			if(!enemies.at(i).isDead()){
				SetObjectX(i+3, enemies.at(i).getX());
				SetObjectY(i+3, enemies.at(i).getY());
			}
		}
		
		for(int i = 0; i < bullets.size(); i++){
			if(!bullets.at(i).isDead()){
				SetObjectX(i+24, bullets.at(i).getX());
				SetObjectY(i+24, bullets.at(i).getY());
			}
		}

		drawText(112,10,toString(score));
		
		WaitVSync();
		UpdateObjects();
		clearText();
		loopSlower++;
	}

	return 0;

}
Example #21
0
//************************************************************************
// minimizes the content object
//************************************************************************
void CChatScreen::Minimize()
{
	m_bMaximizedTimer = false;
	m_dwMaximizedTimer = 0;
	UpdateObjects();
}
Example #22
0
//************************************************************************
// Called when the screen size has changed
//************************************************************************
void CChatScreen::OnSizeChanged()
{
	CScreen::OnSizeChanged();
	UpdateObjects();
}
Example #23
0
//************************************************************************
// Called when the screen size has changed
//************************************************************************
void CNotificationScreen::OnSizeChanged()
{
	CScreen::OnSizeChanged();

	UpdateObjects();
}
/**
Updates all gba objects in Level
*/
void Level::UpdateLevelObjects(int framecounter)
{
	DetermineBackgroundOffsets();
	ApplyEntityOffsets();
	
	REG_BG2HOFS = backgroundoffsetx;
	REG_BG2VOFS = backgroundoffsety;
	
	uint16_t facing = 0;
	
	if (player.direction == player.LEFT)
	{
		facing = ATTR1_HFLIP;
	}
	
	int playertileoffset = 0;
	if (player.IsMoving())
	{
		if ((framecounter % 15 == 0) && ((!paused) || (!indimensionsmenu)))
		{
			player.animationframe = !player.animationframe;
		}
		
		if (player.animationframe == true)
		{
			playertileoffset = 2;
		}
		else
		{
			playertileoffset = 4;
		}
	}
	
	if (player.isholding)
	{
		//Allows for height change when carrying cubes on the head
		SetObject(player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_REG
		    | ATTR0_Y(player.drawy + cube[player.cubeheld].GetHeight()),	
		  ATTR1_SIZE(2) | ATTR1_X(player.drawx) | facing,
		  ATTR2_ID8(playertileoffset) | ATTR2_PRIO(2));
	}
	else
	{
		SetObject(player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(player.drawy),
		  ATTR1_SIZE(2) | ATTR1_X(player.drawx) | facing,
		  ATTR2_ID8(playertileoffset) | ATTR2_PRIO(2));
	}
	
	int cubetile = 6 + DimensionTileOffset(curdimension);
	
	//Draw cubes
	for (int i = 0; i < numofcubes; i++)
	{
		SetObject(cube[i].GetObjNum(),
		  ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(cube[i].drawy),
		  ATTR1_SIZE(1) | ATTR1_X(cube[i].drawx),
		  ATTR2_ID8(cubetile) | ATTR2_PRIO(2));
	}
	
	UpdateObjects();
}
Example #25
0
	bool MainScene::Update()
	{
		switch (updateState)
		{
		case isGameOver:
			Input::KeyInput();
			if (Y == Input::GetLastKey())
			{
				StageManager::GetInstance()->ReSetStage();
				Sleep(2000);
				renderState = isLevelUpdate;
				updateState = isLevelUpdate;
			}
			if (N == Input::GetLastKey())
				BreakBlockGame::setScene(new EndScene());

			break;
		case isLevelUpdate:
			Sleep(2000);
			renderState = isPrimeDraw;
			updateState = isGameing;
			break;
		case isMissionClear:
			StageManager::GetInstance()->SetNextStage();
			Sleep(2000);
			renderState = isLevelUpdate;
			updateState = isLevelUpdate;
			break;
		case isGameing:
			CollisionCheck();
			UpdateObjects();
			renderState = isGameing;
			if (StageManager::GetInstance()->CheckLifeZero() ||
				StageManager::GetInstance()->CheckTimeEnd())
			{
				renderState = isGameOver;
				updateState = isGameOver;
			}
			if (StageManager::GetInstance()->CheckMissionClear())
			{
				renderState = isMissionClear;
				updateState = isMissionClear;
			}
		case isUiDraw:
			if (GetTickCount() >= UiDrawTime)
			{
				StageManager::GetInstance()->AddPlayTime();
				UiDrawTime = GetTickCount() + 1000;
				renderState = isUiDraw;
			}
		case isPrimeDraw:
			if (GetTickCount() >= primeDrawTime)
			{
				primeDrawTime = GetTickCount() + 1000;
				renderState = isPrimeDraw;
			}
			break;
		default:
			break;
		}
		return true;
	}