about summary refs log tree commit diff stats
path: root/data/maps/daedalus/rooms/Pyramid Entry.txtpb
blob: 2c9e8415b1597af1591d8a2ae8ee86f217c4b080 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
name: "Pyramid Entry"
panel_display_name: "Pyramid"
panels {
  name: "TREE"
  path: "Panels/Pyramid/pyramid_1"
  clue: "tree"
  answer: "pine"
  symbols: EXAMPLE
}
panels {
  name: "SHAPE"
  path: "Panels/Pyramid/pyramid_2"
  clue: "shape"
  answer: "triangle"
  symbols: EXAMPLE
}
' href='/therapy/blame/src/components.h?id=b53826079429939cdfbda073608cb85be8ba0738'>^
b538260 ^


1a392a7 ^
b538260 ^

7f0e8c7 ^
b538260 ^
7f0e8c7 ^

0e03897 ^
b538260 ^

7f0e8c7 ^

b538260 ^




1a392a7 ^
b538260 ^



0e03897 ^
7f0e8c7 ^
b538260 ^

7f0e8c7 ^
b538260 ^

7f0e8c7 ^
b538260 ^
0e03897 ^
7f0e8c7 ^
b538260 ^

0e03897 ^
7f0e8c7 ^


0e03897 ^
7f0e8c7 ^



0e03897 ^
7f0e8c7 ^
0e03897 ^
ea0a959 ^
b538260 ^
0e03897 ^



1a392a7 ^
b538260 ^


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






                    
                 


                                                
                                                                





                              
                                               
         
                                                                 


                                                                                                               
              

                                       



                                                
                                                             
                                                                 

          
                                        


                            
                       

  
                                                 
         

                                          
                                                                 

          

                                       




                              
                        



                                             
                                       
                                                             

          
                                            

  
                                                
         
                                          
                                                                                                               

          
                          


                           
                      



                
      
    
                                                                               
                                                                                            
    



                                          
                   


      
#ifndef COMPONENTS_H
#define COMPONENTS_H

#include "entity.h"
#include <utility>
#include <list>
#include "map.h"
#include <memory>

class UserMovementComponent : public Component {
  public:
    void input(Game& game, Entity& entity, int key, int action);
      
  private:
    bool holdingLeft = false;
    bool holdingRight = false;
};

class PhysicsBodyComponent : public Component {
  public:
    void receive(Game& game, Entity& entity, const Message& msg);
    void tick(Game& game, Entity& entity);
    void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair<double, double> old_position);
    
  private:    
    std::pair<double, double> velocity;
    std::pair<double, double> accel;
};

class PlayerSpriteComponent : public Component {
  public:
    void render(Game& game, Entity& entity, Texture& buffer);
    void receive(Game& game, Entity& entity, const Message& msg);
    
  private:
    Texture sprite{"../res/Starla.png"};
    int animFrame = 0;
    bool facingLeft = false;
    bool isMoving = false;
    bool dying = false;
};

class PlayerPhysicsComponent : public Component {
  public:
    PlayerPhysicsComponent();
    void tick(Game& game, Entity& entity);
    void receive(Game& game, Entity& entity, const Message& msg);
    
  private:
    std::pair<double, double> velocity;
    std::pair<double, double> accel;
    double jump_velocity;
    double jump_gravity;
    double jump_gravity_short;
    int direction = 0;
    bool canDrop = false;
    bool frozen = false;
};

class MapRenderComponent : public Component {
  public:
    MapRenderComponent(const Map& map);
    void render(Game& game, Entity& entity, Texture& buffer);
    
  private:
    Texture screen{GAME_WIDTH, GAME_HEIGHT};
};

class MapCollisionComponent : public Component {
  public:
    MapCollisionComponent(const Map& map);
    void detectCollision(Game& game, Entity& entity, Entity& collider, std::pair<double, double> old_position);
    
  private:
    enum class Direction {
      up, left, down, right
    };

    struct Collision {
      int axis;
      int lower;
      int upper;
      int type;
    };
    
    void addCollision(int axis, int lower, int upper, Direction dir, int type);
    bool processCollision(Game& game, Entity& collider, Collision collision, Direction dir);
    
    std::list<Collision> left_collisions;
    std::list<Collision> right_collisions;
    std::list<Collision> up_collisions;
    std::list<Collision> down_collisions;
    const Map& map;
};

#endif