Skip to content

Integrate map into chiventure gui split screen - #1121

Open
perenewang wants to merge 59 commits into
devfrom
gui/split_screen_update
Open

perenewang wants to merge 59 commits into
devfrom
gui/split_screen_update

Conversation

@perenewang

Copy link
Copy Markdown
Contributor

We implemented the map into gui.c to be in the top left corner of the split screen. It shows the rooms surrounding the current room (if there are any) and if a player moves rooms, the map updates so that that new room now becomes the center room.

@eao10000 eao10000 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me!

@MaxineK36 MaxineK36 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of style things to fix, and it looks like this branch may have some files that you didn't intend to merge. Please make sure that you're only merging in code that is completed and ready to be in dev.

Comment thread include/ui/draw_images.h Outdated
*
* No value is returned
*/
void draw_room_gui(int width, int height, int pos_x, int pos_y, room_t *curr_room);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a line break after line 19

Comment thread src/ui/examples/gui_sample_game.c
Comment thread src/ui/src/draw_images.c Outdated
{
// BeginDrawing();

char filename[MAX_FILENAME_LEN] = "/home/grkapoor/cs220/chiventure/tests/wdl/examples/wdl/";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be a hardcoded value, especially not one that references someone's home directory. It should be generalized before merging to dev.

Comment thread src/ui/src/draw_images.c Outdated

strcat(filename, ".png");

// snprintf(filename, MAX_FILENAME_LEN, "/home/grkapoor/cs220/chiventure/tests/wdl/examples/wdl/%s.png", room_id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all extra commented out code should be removed before merging

Comment thread src/ui/src/draw_images.c
Comment thread src/ui/src/draw_images.c Outdated
colors[6] = ORANGE;
colors[7] = DARKGREEN;

// map background

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a block comment /* Map background */ as should all other comments that take up a whole line

Comment thread src/ui/src/draw_images.c
Comment thread src/ui/src/draw_images.c Outdated

}

/* See draw_images.h for documentation */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be removed or completed before merging

Comment thread src/ui/src/gui.c
ball_rad = map_room_width / 10;
room_t *curr_room = ctx->game->curr_room;

Color colors[8];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code seems to be repeated; you should be calling your draw map function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to call draw_map now!

@perenewang

Copy link
Copy Markdown
Contributor Author

This PR is only for the draw_images module and updates to gui.c which now includes the map in the top left corner (it does not include changing room image based on the player moving).

@perenewang
perenewang requested a review from MaxineK36 June 2, 2021 21:05

@MaxineK36 MaxineK36 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small fixes!

Comment thread include/ui/draw_images.h Outdated
#include "game-state/room.h"

/* draw_room_gui
* Draws a room based on its room number for the split screen in chiventure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it now draws based on room id; please update this header accordingly

Comment thread include/ui/draw_images.h Outdated
* - height: integer that defines the height of the split screen
* - pos_x: integer that defines the x-coordinate of the center of the image
* - pos_y: integer that defines the x-coordinate of the center of the image
* - filepath: string that contains the filepath of the images

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify that it's the filepath to the directory; images filenames are of the form filepath/[room-id].png

Comment thread src/ui/src/draw_images.c
/* See draw_images.h for documentation */
void draw_room_gui(int width, int height, int pos_x, int pos_y, char *filepath, room_t *curr_room)
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're using strcat, you should start by callocing a new string of sufficient length, and the strcat'ing onto that.
You can also do this via sprintf: if your new string is called image_filename and has been calloced, you should be able to do sprintf(image_filename, "%s%s.%s", filepath, curr_room, ".png")

Comment thread src/ui/src/draw_images.c Outdated
UnloadImage(room);

DrawTexture(texture, pos_x, pos_y, WHITE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete extra lines here

Comment thread src/ui/src/draw_images.c

int posX = map_topX + map_width / 2 - map_room_width / 2;
int posY = map_topY + map_height / 2 - map_room_height / 2;
/* draw current room */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a blank line between lines 59 and 60

Comment thread src/ui/src/gui.c
ball_rad = map_room_width / 10;
room_t *curr_room = ctx->game->curr_room;

Color colors[8];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to call draw_map now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants