CPlayGameGalaxy.cpp 2.7 KB
Newer Older
gerstrong's avatar
gerstrong committed
1 2 3 4 5 6 7 8
/*
 * CPlayGame.cpp
 *
 *  Created on: 31.01.2010
 *      Author: gerstrong
 */

#include "CPlayGameGalaxy.h"
gerstrong's avatar
gerstrong committed
9 10
#include "CMapLoaderGalaxy.h"

11
#include "../../sdl/CVideoDriver.h"
12
#include "../../sdl/CInput.h"
13
#include "../../graphics/CGfxEngine.h"
Gerhard Stein's avatar
Gerhard Stein committed
14
#include "../../StringUtils.h"
15

gerstrong's avatar
gerstrong committed
16 17 18
namespace galaxy
{

gerstrong's avatar
gerstrong committed
19
CPlayGameGalaxy::CPlayGameGalaxy(CExeFile &ExeFile, char level,
gerstrong's avatar
gerstrong committed
20
		 char numplayers, char difficulty, stOption *p_option) :
21 22 23
CPlayGame(ExeFile, level, numplayers, difficulty, p_option),
m_posx(0),
m_posy(0)
gerstrong's avatar
gerstrong committed
24 25 26 27 28
{}

bool CPlayGameGalaxy::loadGameState()
{return false;}

29 30
// Setup for the ingame
bool CPlayGameGalaxy::init()
31 32 33 34 35 36 37
{
	loadLevel();

	return false;
}

void CPlayGameGalaxy::loadLevel()
gerstrong's avatar
gerstrong committed
38
{
39 40 41
	// Load the Level map. We have two modes. Inlevel and game map

	// TODO: Lets load the main map for now and create process for this
gerstrong's avatar
gerstrong committed
42 43
	CMapLoaderGalaxy MapLoader(m_ExeFile);

44
	m_Map.setScrollSurface(g_pVideoDriver->getScrollSurface());
45
	MapLoader.loadMap(m_Map, m_Level); // Map Level?
gerstrong's avatar
gerstrong committed
46

47
	m_Map.drawAll();
gerstrong's avatar
gerstrong committed
48 49
}

50 51 52 53
// The main ingame process cycle when keen galaxy is up and running
void CPlayGameGalaxy::process()
{
	// TODO: Process code for the main map
54 55
	// Blit the background

56 57
	processInput();

58 59 60
	// process World Map if active. At the start it's enabled
	//if(m_WorldMap.isActive())
		//m_WorldMap.process();
61

62 63 64 65 66 67 68
	// process World Map if active. At the start it's enabled
	//if(m_LevelPlay.isActive())
		//m_LevelPlay.process();

	// process Page if one is open. Could be one of the finale
	//if(m_Page.isActive())
		//m_Page.process();
69

70 71 72 73 74
	processRendering();
}

void CPlayGameGalaxy::processInput()
{
75 76 77
	// TODO: wrap this into the camera class they way it can be used in the vorticons engine
	// Also make it more efficient.

78 79 80
	if(g_pInput->getPressedCommand(IC_QUIT))
		m_endgame = true;

81
	if(g_pInput->getHoldedCommand(IC_LEFT))
82
	{
83
		m_Map.scrollLeft();
84 85
		m_Map.scrollLeft();
	}
86
	else if(g_pInput->getHoldedCommand(IC_RIGHT))
87
	{
88
		m_Map.scrollRight();
89 90
		m_Map.scrollRight();
	}
91
	if(g_pInput->getHoldedCommand(IC_UP))
92
	{
93
		m_Map.scrollUp();
94 95
		m_Map.scrollUp();
	}
96
	else if(g_pInput->getHoldedCommand(IC_DOWN))
97 98
	{
		m_Map.scrollDown();
99
		m_Map.scrollDown();
100
	}
101 102 103 104 105 106 107 108 109

	if(g_pInput->getPressedCommand(IC_STATUS))
	{
		if(m_Level < 20)
			m_Level++;
		else
			m_Level = 0;
		loadLevel();
	}
110 111 112 113
}

void CPlayGameGalaxy::processRendering()
{
114
	// Animate the tiles of the map
115
	m_Map.animateAllTiles();
116 117 118

	// Blit the background
	g_pVideoDriver->blitScrollSurface();
119

Gerhard Stein's avatar
Gerhard Stein committed
120
	g_pGfxEngine->getFont(0).drawFont(g_pVideoDriver->BlitSurface, "Press the arrows to scroll, ESC to quit", 10, 10);
121
	g_pGfxEngine->getFont(0).drawFont(g_pVideoDriver->BlitSurface, "Enter to switch Level", 10, 20);
122
}
gerstrong's avatar
gerstrong committed
123

124

gerstrong's avatar
gerstrong committed
125 126 127
void CPlayGameGalaxy::cleanup()
{}

gerstrong's avatar
gerstrong committed
128 129 130 131 132 133
CPlayGameGalaxy::~CPlayGameGalaxy()
{
	// TODO Auto-generated destructor stub
}

}