Skip to content

Commit fe93770

Browse files
committed
this is for the good of the item economy
1 parent f9c6afc commit fe93770

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

src/control/input_manager.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ InputManager::get_controller(int player_id)
5353
return *m_controllers[player_id];
5454
}
5555

56-
bool InputManager::can_add_user() const
56+
bool
57+
InputManager::can_add_user() const
5758
{
58-
return get_num_users() >= MAX_PLAYERS;
59+
return get_num_users() < MAX_PLAYERS;
5960
}
6061

6162
void

src/supertux/game_session.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ GameSession::update(float dt_sec, const Controller& controller)
648648
}
649649

650650
m_currentsector->update(dt_sec);
651+
651652
} else {
652653
bool are_all_stopped = true;
653654

src/supertux/player_status.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ static const int MAX_COINS = 9999;
3434

3535
PlayerStatus::PlayerStatus(int num_players) :
3636
m_num_players(num_players),
37+
m_item_pockets(num_players),
3738
coins(START_COINS),
3839
bonus(num_players),
39-
m_item_pockets(num_players),
4040
max_fire_bullets(num_players),
4141
max_ice_bullets(num_players),
4242
max_air_time(num_players),
@@ -64,7 +64,8 @@ PlayerStatus::take_checkpoint_coins()
6464
coins = 0;
6565
}
6666

67-
void PlayerStatus::reset(int num_players)
67+
void
68+
PlayerStatus::reset(int num_players)
6869
{
6970
coins = START_COINS;
7071

@@ -265,15 +266,19 @@ void
265266
PlayerStatus::give_item_from_pocket(Player* player)
266267
{
267268
BonusType bonustype = m_item_pockets[player->get_id()];
269+
if (bonustype == NO_BONUS)
270+
return;
271+
268272
m_item_pockets[player->get_id()] = NO_BONUS;
269273

270274
Vector pos;
271275
auto& powerup = Sector::get().add<PowerUp>(pos, PowerUp::get_type_from_bonustype(bonustype));
272276
pos.x = player->get_bbox().get_left();
273-
pos.y = player->get_bbox().get_top() - powerup.get_bbox().get_height() - 5;
277+
pos.y = player->get_bbox().get_top() + player->get_collision_object()->get_movement().y - powerup.get_bbox().get_height() - 15;
274278

275279
powerup.physic.set_velocity_y(-200);
276280
powerup.physic.set_gravity_modifier(0.4f);
281+
powerup.get_collision_object()->m_group = COLGROUP_TOUCHABLE;
277282
powerup.set_pos(pos);
278283
}
279284

src/supertux/player_status_hud.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "video/surface.hpp"
2525
#include "editor/editor.hpp"
2626

27+
#include <iostream>
28+
2729
static const int DISPLAYED_COINS_UNSET = -1;
2830

2931
PlayerStatusHUD::PlayerStatusHUD(PlayerStatus& player_status) :
@@ -151,15 +153,18 @@ PlayerStatusHUD::draw(DrawingContext& context)
151153
PlayerStatusHUD::text_color);
152154
}
153155

156+
std::cout << m_player_status.m_num_players << std::endl;
157+
for (int i = 0; i < m_player_status.m_num_players; i++) {
158+
float ypos = static_cast<float>(m_item_pocket_border->get_height() * i);
159+
Vector pos(BORDER_X, BORDER_Y + ypos);
160+
context.color().draw_surface(m_item_pocket_border, pos, LAYER_HUD);
154161

155-
Vector pos(BORDER_X, BORDER_Y);
156-
context.color().draw_surface(m_item_pocket_border, pos, LAYER_HUD);
157-
158-
Sprite* sprite = m_bonus_sprites[m_player_status.m_item_pockets.front()].get();
159-
if (m_player_status.m_item_pockets.size() > 0 && sprite)
160-
{
161-
pos += 20;
162-
sprite->draw(context.color(), pos, LAYER_HUD);
162+
if (m_bonus_sprites.find(m_player_status.m_item_pockets[i]) != m_bonus_sprites.end())
163+
{
164+
pos += 20;
165+
Sprite* sprite = m_bonus_sprites[m_player_status.m_item_pockets.front()].get();
166+
sprite->draw(context.color(), pos, LAYER_HUD);
167+
}
163168
}
164169

165170
context.pop_transform();

0 commit comments

Comments
 (0)