-
Notifications
You must be signed in to change notification settings - Fork 1
/
World.h
62 lines (43 loc) · 1.39 KB
/
World.h
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
//
// Created by Alejandro on 19/08/16.
//
#ifndef TEST_SERVER_WORLD_H
#define TEST_SERVER_WORLD_H
#include <SFML/Graphics.hpp>
#include "Entity.h"
#include "Area.h"
#include "Player.h"
class World
{
public:
int16_t selectedMap = 0;
std::vector<const char *> maps = {"maps/level1.txt","maps/level2.txt"};
World();
void init(const char * mapName, std::vector<Player*>* players);
void update(sf::Time elapsedTime);
void processEvents();
std::vector<int16_t> areasForEntity(const Entity &entity);
std::vector<Player*>* players;
sf::FloatRect bounds;
//Every position in the first vector represents an area (area 0, 1, ..., n)
//Every vector in each position has references to every object in the area
std::vector<std::vector<Entity*>> static_entities;
void randomSpawn(Player *p);
private:
std::vector<Area*> areas;
float area_size;
int noAreasX;
int noAreasY;
std::vector<std::vector<Entity*>> moving_entities;
std::vector<Entity*> world_entities;
std::vector<Pickup*> pickups;
std::vector<sf::Vector2f> spawn_locations;
void indexStaticEntities();
void createAreas();
void reset();
void indexMovingEntities();
void checkWallCollisions(Player &player);
void checkProjectileCollisions(int16_t currentPlayerEntityId, Projectile &proj);
void readMap2(const char* map);
};
#endif //TEST_SERVER_WORLD_H