File: levelmap.cpp

package info (click to toggle)
epiphany 0.7.0+0-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 7,532 kB
  • sloc: cpp: 6,404; ansic: 141; makefile: 78; sh: 7
file content (109 lines) | stat: -rw-r--r-- 2,504 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/***************************************************************************
                          levelmap.cpp  -  description
                             -------------------
    begin                : Thu Aug 8 2002
    copyright            : (C) 2002 by Giuseppe D'Aqui'
    email                : kumber@tiscalinet.it
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License, Version 2, as published by  *
 *   the Free Software Foundation.                                   *
 *                                                                         *
 ***************************************************************************/

#include "dephine.h"
#include "levelmap.h"
#include "myparser.h"
#include "epimap.h"
#include "entity_type.h"
#include <vector>
#include <string>
#include <fstream>

Levelmap::Levelmap()
{

}

Levelmap::Levelmap(const char* map_path)
{

	load_map(map_path);
}

void Levelmap::load_map(const char* map_path)
{
	std::ifstream scriptfile(map_path);

	myparser parsy;
	parsy<<scriptfile;
	DEBOUT("Map parsed.\n");
	Epimap epimap = parsy.get_epimap();
	DEBOUT("Map acquired.\n");
	m_min_score=epimap.get_min_score();
	m_max_time=epimap.get_max_time();
	m_name=epimap.get_name().c_str();
	m_author=epimap.get_author().c_str();
	m_size_x=epimap.get_size_x();
	m_size_y=epimap.get_size_y();
	DEBOUT("Getting Map... ");
	DEBOUT("\n\tMap Name: "<<m_name);
	DEBOUT("\n\tMap Author: "<<m_author);
	DEBOUT("\n\tMinimum score: "<<m_min_score);
	DEBOUT("\n\tMaximum time: "<<m_max_time);

	m_map=epimap.get_map();
	DEBOUT("\nGot.\n");
    m_version=epimap.get_map_version();


}


Uint32 Levelmap::get_min_score()
{
	return m_min_score;
}

Uint32 Levelmap::get_max_time()
{
	return m_max_time;
}

const char* Levelmap::get_name()
{
	return m_name;
}

const char* Levelmap::get_author()
{
	return m_author;
}

Uint32 Levelmap::get_size_x()
{
	return m_size_x;
}

Uint32 Levelmap::get_size_y()
{
	return m_size_y;
}


std::vector< std::vector<Entity_Type> >& Levelmap::get_map()
{
	return m_map;
}

Entity_Type Levelmap::get_map_element(Uint32 x, Uint32 y)
{
	if((x>m_size_x)||(y>m_size_y))
		DEBOUT("Alert: map element outside map size\n");
	
	return m_map[x][y];
}