-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: dev
Are you sure you want to change the base?
Conversation
…date' into gui/split_screen_update
There was a problem hiding this 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!
There was a problem hiding this 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.
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.
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/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.
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.
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.
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
Outdated
colors[6] = ORANGE; | ||
colors[7] = DARKGREEN; | ||
|
||
// map background |
There was a problem hiding this comment.
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
Outdated
|
||
} | ||
|
||
/* See draw_images.h for documentation */ |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
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). |
There was a problem hiding this 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/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.
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
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.
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) | ||
{ | ||
|
There was a problem hiding this comment.
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 calloc
ing 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 calloc
ed, 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.
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 */ |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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!
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.