Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate map into chiventure gui split screen #1121

Open
wants to merge 59 commits into
base: dev
Choose a base branch
from

Conversation

perenewang
Copy link
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.

Copy link

@eao10000 eao10000 left a comment

Choose a reason for hiding this comment

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

Looks great to me!

Copy link
Contributor

@MaxineK36 MaxineK36 left a comment

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.

*
* No value is returned
*/
void draw_room_gui(int width, int height, int pos_x, int pos_y, room_t *curr_room);
Copy link
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

src/ui/examples/gui_sample_game.c Show resolved Hide resolved
{
// BeginDrawing();

char filename[MAX_FILENAME_LEN] = "/home/grkapoor/cs220/chiventure/tests/wdl/examples/wdl/";
Copy link
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.


strcat(filename, ".png");

// snprintf(filename, MAX_FILENAME_LEN, "/home/grkapoor/cs220/chiventure/tests/wdl/examples/wdl/%s.png", room_id);
Copy link
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

src/ui/src/draw_images.c Show resolved Hide resolved
colors[6] = ORANGE;
colors[7] = DARKGREEN;

// map background
Copy link
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

src/ui/src/draw_images.c Show resolved Hide resolved

}

/* See draw_images.h for documentation */
Copy link
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

ball_rad = map_room_width / 10;
room_t *curr_room = ctx->game->curr_room;

Color colors[8];
Copy link
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
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
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
Copy link
Contributor

@MaxineK36 MaxineK36 left a comment

Choose a reason for hiding this comment

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

A few small fixes!

#include "game-state/room.h"

/* draw_room_gui
* Draws a room based on its room number for the split screen in chiventure
Copy link
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

* - 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
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

/* 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
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")

UnloadImage(room);

DrawTexture(texture, pos_x, pos_y, WHITE);

Copy link
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


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
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

ball_rad = map_room_width / 10;
room_t *curr_room = ctx->game->curr_room;

Color colors[8];
Copy link
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.

5 participants