Integrate map into chiventure gui split screen#1121
Conversation
…date' into gui/split_screen_update
MaxineK36
left a comment
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
nit: add a line break after line 19
src/ui/src/draw_images.c
Outdated
| { | ||
| // BeginDrawing(); | ||
|
|
||
| char filename[MAX_FILENAME_LEN] = "/home/grkapoor/cs220/chiventure/tests/wdl/examples/wdl/"; |
There was a problem hiding this comment.
This can't be a hardcoded value, especially not one that references someone's home directory. It should be generalized before merging to dev.
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); |
There was a problem hiding this comment.
all extra commented out code should be removed before merging
src/ui/src/draw_images.c
Outdated
| colors[6] = ORANGE; | ||
| colors[7] = DARKGREEN; | ||
|
|
||
| // map background |
There was a problem hiding this comment.
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
Outdated
|
|
||
| } | ||
|
|
||
| /* See draw_images.h for documentation */ |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
This code seems to be repeated; you should be calling your draw map function
There was a problem hiding this comment.
You should be able to call draw_map now!
|
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). |
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 |
There was a problem hiding this comment.
Looks like it now draws based on room id; please update this header accordingly
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 |
There was a problem hiding this comment.
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) | ||
| { | ||
|
|
There was a problem hiding this comment.
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")
src/ui/src/draw_images.c
Outdated
| UnloadImage(room); | ||
|
|
||
| DrawTexture(texture, pos_x, pos_y, WHITE); | ||
|
|
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
You should be able to call draw_map now!
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.