Skip to content
This repository has been archived by the owner on Jun 7, 2018. It is now read-only.

Commit

Permalink
Starting the map submenu
Browse files Browse the repository at this point in the history
git-svn-id: svn://solarus-engine.org/solarus@528 08e91b48-8f19-0410-8fc9-9db6b7bce602
  • Loading branch information
christopho committed Oct 5, 2008
1 parent 2fb2d6c commit d91c506
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 9 deletions.
Binary file added data/images/menus/link_head.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/menus/outside_world_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions data/sprites/menus/link_head.zsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tunic0 menus/link_head.png 1 300 0
0 0 16 13 0 0 2 2

tunic1 menus/link_head.png 1 300 0
0 13 16 13 0 0 2 2

tunic2 menus/link_head.png 1 300 0
0 26 16 13 0 0 2 2

2 changes: 2 additions & 0 deletions include/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Game: public Screen {
Transition *transition; /**< the transition currently shown, or NULL if no transition is playing */

Dungeon *dungeon; /**< the dungeon of the current map, of NULL if we are not in a dungeon */
static const SDL_Rect outside_world_size; /**< size of the outside world in pixels */

// graphics
HUD *hud; /**< the game HUD (displaying hearts, rupees, key icons, etc.) */
Expand Down Expand Up @@ -80,6 +81,7 @@ class Game: public Screen {
void set_current_map(MapId map_id, string entrance_name, Transition::Style transition_style);
bool is_in_dungeon(void);
Dungeon *get_current_dungeon(void);
const SDL_Rect *get_outside_world_size(void);

// music
void play_music(MusicId new_music_id);
Expand Down
3 changes: 2 additions & 1 deletion include/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ class Map {
Tileset *get_tileset(void);
int get_world_number(void);
bool is_in_dungeon(void);
bool is_in_outside_world(void);
int get_floor(void);
bool has_floor(void);
SDL_Rect *get_location(void);
const SDL_Rect *get_location(void);
int get_small_keys_variable(void);
bool has_small_keys(void);

Expand Down
14 changes: 14 additions & 0 deletions include/menus/PauseSubmenuMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
*/
class PauseSubmenuMap: public PauseSubmenu {

private:

static const SDL_Rect outside_world_minimap_size;

// data
Dungeon *dungeon; /**< the dungeon whose map is displayed, or NULL if we are not in a dungeon */
SDL_Rect link_position; /**< position of Link on the minimap */

// graphics
SDL_Surface *world_map_img;
Sprite *link_head_sprite;

public:

PauseSubmenuMap(PauseMenu *pause_menu, Game *game);
Expand All @@ -17,6 +29,8 @@ class PauseSubmenuMap: public PauseSubmenu {
void key_pressed(const SDL_keysym &keysym);
void update(void);
void display(SDL_Surface *destination);
void display_world_map(SDL_Surface *destination);
void display_dungeon_map(SDL_Surface *destination);
};

#endif
13 changes: 12 additions & 1 deletion src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "entities/EntityDetector.h"
#include "movements/Movement8ByPlayer.h"

const SDL_Rect Game::outside_world_size = {0, 0, 1024, 2048}; // TODO

/**
* Creates a game.
* @param savegame the saved data of this game
Expand Down Expand Up @@ -374,15 +376,24 @@ void Game::set_current_map(MapId map_id, string entrance_name, Transition::Style
bool Game::is_in_dungeon(void) {
return current_map->is_in_dungeon();
}

/**
* Returns the dungeon where the current map is, or NULL
* if we are not in a dungeon.
* @return the current dungeon
*/
Dungeon *Game::get_current_dungeon(void) {
Dungeon * Game::get_current_dungeon(void) {
return dungeon;
}

/**
* Returns the size of the oustide world in pixels.
* @return the size of the oustide world
*/
const SDL_Rect * Game::get_outside_world_size(void) {
return &outside_world_size;
}

/**
* Plays a music. If the music is different from the current one,
* the current one is stopped.
Expand Down
10 changes: 9 additions & 1 deletion src/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ bool Map::is_in_dungeon(void) {
return get_world_number() > 0;
}

/**
* Returns whether this map belongs to the outside world.
* @return true if this map is in the oustide world
*/
bool Map::is_in_outside_world(void) {
return get_world_number() == 0;
}

/**
* Returns the floor where this map is.
* The value returned can be:
Expand Down Expand Up @@ -93,7 +101,7 @@ bool Map::has_floor(void) {
* - in a dungeon: location of the map's top-left corner relative to the whole floor
* The width and height fields correspond to the map size.
*/
SDL_Rect * Map::get_location(void) {
const SDL_Rect * Map::get_location(void) {
return &location;
}

Expand Down
1 change: 1 addition & 0 deletions src/menus/PauseSubmenuInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ void PauseSubmenuInventory::update(void) {

/**
* Displays this submenu.
* @param destination the destination surface
*/
void PauseSubmenuInventory::display(SDL_Surface *destination) {

Expand Down
78 changes: 76 additions & 2 deletions src/menus/PauseSubmenuMap.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,63 @@
#include "menus/PauseSubmenuMap.h"
#include "menus/PauseMenu.h"
#include "Game.h"
#include "Dungeon.h"
#include "ResourceManager.h"
#include "Sprite.h"
#include "Map.h"
#include "Equipment.h"
#include "entities/Link.h"

const SDL_Rect PauseSubmenuMap::outside_world_minimap_size = {0, 0, 225, 500};

/**
* Constructor.
* @param pause_menu the pause menu object
* @param game the game
*/
PauseSubmenuMap::PauseSubmenuMap(PauseMenu *pause_menu, Game *game):
PauseSubmenu(pause_menu, game) {
PauseSubmenu(pause_menu, game), dungeon(game->get_current_dungeon()) {

Map *map = game->get_current_map();
link_position = *map->get_location();

if (dungeon == NULL) {
world_map_img = ResourceManager::load_image("menus/outside_world_map.png");
set_caption_text("Carte du monde");

const SDL_Rect *real_size = game->get_outside_world_size();

if (map->is_in_outside_world()) {
link_position.x += game->get_link()->get_x();
link_position.y += game->get_link()->get_y();
}

link_position.x = link_position.x * outside_world_minimap_size.w / real_size->w;
link_position.y = link_position.y * outside_world_minimap_size.h / real_size->h;
}
else {
// TODO
}

link_position.x += 48 - 8;
link_position.y += 59 - 7;

link_head_sprite = new Sprite("menus/link_head");
ostringstream oss;
oss << "tunic" << equipment->get_tunic();
link_head_sprite->set_current_animation(oss.str());
}

/**
* Destructor.
*/
PauseSubmenuMap::~PauseSubmenuMap(void) {

if (dungeon == NULL) {
SDL_FreeSurface(world_map_img);
}

delete link_head_sprite;
}

/**
Expand Down Expand Up @@ -44,12 +85,45 @@ void PauseSubmenuMap::key_pressed(const SDL_keysym &keysym) {
* Updates this submenu.
*/
void PauseSubmenuMap::update(void) {

link_head_sprite->update_current_frame();
}

/**
* Displays this submenu.
* @param destination the destination surface
*/
void PauseSubmenuMap::display(SDL_Surface *destination) {

PauseSubmenu::display(destination);

if (dungeon == NULL) {
display_world_map(destination);
}
else {
display_dungeon_map(destination);
}
}

/**
* Displays the world map.
* @param destination the destination surface
*/
void PauseSubmenuMap::display_world_map(SDL_Surface *destination) {

// display the map
SDL_Rect src_position = {0, 0, 225, 133};
static SDL_Rect dst_position = {48, 59, 0, 0};

SDL_BlitSurface(world_map_img, &src_position, destination, &dst_position);

// display Link's position
link_head_sprite->display(destination, link_position.x, link_position.y);
}

/**
* Displays the dungeon map.
* @param destination the destination surface
*/
void PauseSubmenuMap::display_dungeon_map(SDL_Surface *destination) {

}
1 change: 1 addition & 0 deletions src/menus/PauseSubmenuOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void PauseSubmenuOptions::update(void) {

/**
* Displays this submenu.
* @param destination the destination surface
*/
void PauseSubmenuOptions::display(SDL_Surface *destination) {
PauseSubmenu::display(destination);
Expand Down
1 change: 1 addition & 0 deletions src/menus/PauseSubmenuQuestStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void PauseSubmenuQuestStatus::update(void) {

/**
* Displays this submenu.
* @param destination the destination surface
*/
void PauseSubmenuQuestStatus::display(SDL_Surface *destination) {
PauseSubmenu::display(destination);
Expand Down
4 changes: 0 additions & 4 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
- Voir les boss de Pyro
- Afficher le nom du donjon dans le hud
- Classe donjon dans l'éditeur: interface pour éditer les étages des donjons
- Animation tire + pierres trop lourdes

- Bugs :
- quand on met pause et qu'on revient, les touches relâchées entre temps ne sont pas détectées (sauf concernant le mouvement de link)

- Prochaines grandes étapes :
- collision au pixel près
Expand Down

0 comments on commit d91c506

Please sign in to comment.