File: entity_factory.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 (137 lines) | stat: -rw-r--r-- 3,485 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************************
                          entity_factory.cpp  -  description
                             -------------------
    begin                : Jun 13 2007
    copyright            : (C) 2007 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 "entity_factory.h"
#include "entity_all.h"

#include "level.h"

//APOI: remove *any* reference to Level, maybe through message passing

Entity* Entity_Factory::create_entity(Entity_Type type, Level* level)
{
	//DEBOUT(type<<"\n");
	Entity* entity;
	
	Uint32 x=1;
	Uint32 y = 1;
	//DEBOUT("Creating entity of type:"<<type<<"\n");
	switch(type)
	{
	case UNKNOWN:
		entity = new Entity_Unknown();
		break;
	case PLAYER:
		entity=new Entity_Player(level,x,y);
		//set_entity(m_player);
		DEBOUT("Setting player...\n");
		break;
	case GRASS:
		entity=new Entity_Grass(level,x,y);
		break;
	case STEEL:
		entity=new Entity_Steel(level,x,y);
		break;
	case EMERALD:
		entity=new Entity_Emerald(level,x,y);
		break;
	case BOULDER:
		entity=new Entity_Boulder(level,x,y);
		break;
	case SAPPHIRE:
		entity=new Entity_Sapphire(level,x,y);
		break;
	case EXIT:
		entity=new Entity_Exit(level,x,y,1);
		//set_entity(m_exit);
		DEBOUT("Setting Exit...\n");
		break;
	case DOOR_RED:
		entity=new Entity_Door(level,x,y,1);
		break;
	case DOOR_BLUE:
		entity=new Entity_Door(level,x,y,2);
		break;
	case DOOR_GREEN:
		entity=new Entity_Door(level,x,y,4);
		break;
	case DOOR_YELLOW:
		entity=new Entity_Door(level,x,y,8);
		break;
	case KEY_RED:
		entity=new Entity_Key(level,x,y,1);
		break;
	case KEY_BLUE:
		entity=new Entity_Key(level,x,y,2);
		break;
	case KEY_GREEN:
		entity=new Entity_Key(level,x,y,4);
		break;
	case KEY_YELLOW:
		entity=new Entity_Key(level,x,y,8);
		break;
	case FLINTSTONE:
		entity=new Entity_Flintstone(level,x,y);
		break;
	case PEPERON_UP:
		entity=new Entity_Peperon(level,x,y,UP);
		break;
	case PEPERON_RIGHT:
		entity=new Entity_Peperon(level,x,y,RIGHT);
		break;
	case PEPERON_DOWN:
		entity=new Entity_Peperon(level,x,y,DOWN);
		break;
	case PEPERON_LEFT:
		entity=new Entity_Peperon(level,x,y,LEFT);
		break;
	case BRICK:
		entity=new Entity_Brick(level,x,y);
		break;
	case WOOD:
		entity=new Entity_Wood(level,x,y);
		break;
	case TOMATO_UP:
		entity=new Entity_Tomato(level,x,y,UP);
		break;
	case TOMATO_RIGHT:
		entity=new Entity_Tomato(level,x,y,RIGHT);
		break;
	case TOMATO_DOWN:
		entity=new Entity_Tomato(level,x,y,DOWN);
		break;
	case TOMATO_LEFT:
		entity=new Entity_Tomato(level,x,y,LEFT);
		break;
	case EXPLOSION:
		entity = new Entity_Explosion(level,x,y);
	default:
		//do nothing
		break;
	}
	return entity;
}

Entity_Factory* Entity_Factory::_instance = 0;

Entity_Factory* Entity_Factory::instance()
{
	if(_instance==0)
	{
		_instance=new Entity_Factory();
	}
	return _instance;
}