Game dev – Programming – Rooms, collisions, pause state, textiles and prioritizing work

Intro

Much has been done with the project, I will describe the different parts that I was a part of. Each part is described in detail in each section.

  • I made a RoomManager which holds and handles, you guessed it, rooms.
  • I worked with Malin Lundqvist with collisions between room walls and the avatar, line vs circle collision.
  • I created a pause state which uses Jonas Lundgrens StateManager, which “freezes” the PlayState logic while still drawing it.
  • I added textiles that are objects able to be “picked up” and a TextileManager.
  • We discussed how to prioritize some parts of our work and divided the workload among us.

Rooms

First of all, in our game we have objects called Rooms. There are 28 of these that make up the entire world of the game. Here is our current level design, made by one of my team mates Andreas Calmius:

Image

I made a manager that holds all these rooms, in the Initialize() function they are all created. It can handle rooms, like CreateRoom(), DrawRooms(), CheckCollisions(). This is the layout:

class RoomManager
{
public:
RoomManager(){};

void Initialize(SpriteManager* p_xSpriteManager, std::string p_sRoomFilePath);
void CreateRoom(SpriteManager* p_xSpriteManager, std::string p_sName, sf::Vector2f p_xPos);
void Cleanup();
void DrawRooms(DrawManager* p_xDrawManager);
bool CheckCollisions(CollisionManager* p_xCollisionManager, Collider* p_xCollider);

private:
std::string m_sRoomFilePath;
std::vector m_xRooms;
};

In the future, the plan is to only update rooms close to the avatar and make it so that enemies are part of each room. The idea is that with many enemies, updating them all across the map is not optimal.

Avatar vs wall collision

Me and Malin Lundqvist implemented her collision code to all the rooms, it took a few more hours than we planned in our weekly SCRUM. We had planned for 5 hours and it took about 6-7 hours.

The collision she wrote is a line vs CircleCollider code. Each room reads from a text file with points in vectors. Each vector element corresponds with a part of the room that the player cannot cross. In this example room, one vector element (points that create lines) in this map is the top wall, another is the bottom wall. The text file contains position data with breakpoints between vector elements.

Image

The room is 2560 x 1440.

Here are the current collision points in this room (breakpoint is 9001):

2558 876
2112 806
1744 708
1728 592
1996 342
1948 226
1504 156
882 210
382 510
164 766
2 826
9001
2556 1314
2126 1308
1882 1260
1190 1292
956 1100
1088 854
1352 548
1064 542
800 788
340 1224
50 1356
2 1346

The game took a step closer to being enjoyable to play with the addition of avatar vs wall collision.

Pause state

I added a pause state to the game. Jonas Lundgren built the StateManager and it works very well. It works a bit different from the one we learned about in the lectures. This has levels of states. The later added states can be set as Exclusive, which means that the earlier added ones aren’t updated anymore until the exclusive one is removed. To explain this further, here is a picture to describe it.

Image

The pause state is an exclusive one, so it “freezes” the PlayState below it. It still draws stuff so it look kind of nice. Here is a screenshot from ingame with the pausestate activated and the game logic “frozen”.

Image

Textile Manager

I added textiles (the chests on the picture above) and a manager for them. The textiles are collected when the avatar collides with them. What actually happens when colliding is that the textile is erased from the vector and the AddOneX() function is called, being the type of textile collected. The manager holds the current amount of textiles of each type collected and equipped. This is it’s layout of the manager and it’s functions:

class TextileManager
{
public:
TextileManager();

void Initialize(SpriteManager* p_xSpriteManager);
void CleanUp();

void CreateTextile(SpriteManager* p_xSpriteManager, std::string p_sName, std::string p_sType, sf::Vector2f p_xPos);

int GetWoolCount();
int GetCottonCount();
int GetSilkCount();
int GetLeatherCount();

void AddOneWool();
void AddOneCotton();
void AddOneSilk();
void AddOneLeather();

void UpdateTextiles(float p_fDeltaTime);
void DrawTextiles(DrawManager* p_xDrawManager);
void CheckCollisions(CollisionManager* p_xCollisionManager, Collider* p_xPlayerCollider);

private:
int m_iWoolCount;
int m_iCottonCount;
int m_iSilkCount;
int m_iLeatherCount;

int m_iWoolEquipped;
int m_iCottonEquipped;
int m_iSilkEquipped;
int m_iLeatherEquipped;

std::vector m_xTextiles;
};

It isn’t done, but I will probably finish it tomorrow.

Prioritizing work

We talked about adding pathfinding today after todays lecture on it. The pro’s are that we learn about doing it and it will probably be valuable knowledge since that is a common part of games. The con’s are a higher programmer workload. We discussed the matter and divided the different parts of programming among us. Malin was most eager to do pathfinding, so she starts doing this now. I will make an AI statemanager, based on the one I made for my earlier game “Boberman”. Jonas will keep working on GUI and since we arn’t sure that he will get it working until the alpha, I will program an alternate GUI for buttons in the customization menu.

Here is a list of our priorities right now:

ALPHA
1. Collisions
line vs circle
circle vs circle
2. Rooms (working)
3. AI & Waypoints
3.1 Bugger (early working)
3.2 Mothgomery (early working)
3.3 PATHFINDING (early working)
4. Audio (early)

BETA
1. Textiles & Customization menu
2. Animation
3. AI
3.1 PATHFINDING (final)
3.2 Bugger (final)
3.3 Grubling (final)
3.4 Mothgomery (final)
3.5 Ben bugger, kite fight (final)
3.6 Grubby McGrub, Whack-a-mole (final)
4. Pause map
5. Audio (final)

FINAL
1. Menu’s
1.1 Main menu
1.2 Pause options
2. Rooms (final, quadtree-ish)
3. Polish EVERYTHING