-
Notifications
You must be signed in to change notification settings - Fork 79
Added support for sprite Vector array and Static array in center_camera_on() method #158
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
Conversation
macite
left a comment
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 needs work, and should have been reviewed before submitting here. Reviews should critically check basic things like indentation.
coresdk/src/coresdk/camera.cpp
Outdated
| void center_camera_on(sprite s, double offset_x, double offset_y) | ||
| { | ||
| point_2d center = sprite_position(s); | ||
| // void center_camera_on(sprite s, double offset_x, double offset_y) |
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.
These comments should not remain in the code. Only include comments that add value.
coresdk/src/coresdk/camera.cpp
Outdated
| double sc_x{0}; | ||
| double sc_y{0}; | ||
|
|
||
| for (const auto& ele : s) { |
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.
don't use auto
coresdk/src/coresdk/camera.h
Outdated
| * @param offset_y An additional offset added to the camera, allowing you to | ||
| * position the sprites offset from the center of the screen. | ||
| */ | ||
| void center_camera_on(sprite s[],int size , double offset_x, double offset_y); |
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.
I don't think the translator supports arrays - have you tested rebuilding the language translations. See the tools/scripts/deploy.sh script.
coresdk/src/coresdk/camera.h
Outdated
| * @param offset The amount to offset the camera, allowing you to position | ||
| * the sprites away from the center of the screen. | ||
| */ | ||
| void center_camera_on(sprite s[], int size, const vector_2d &offset); |
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.
As above
coresdk/src/coresdk/camera.h
Outdated
| * @attribute method center_on | ||
| */ | ||
| void center_camera_on(sprite s, const vector_2d &offset); | ||
| /** |
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.
Very sloppy!
Match indentation.
coresdk/src/test/test_camera.cpp
Outdated
|
|
||
| load_bitmap("ufo", "ufo.png"); | ||
| sprite s = create_sprite("ufo"); | ||
| sprite s1 = create_sprite("ufo"); |
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.
Why not just in the vector and then access them there by index when needed.
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.
Then use a loop to run repeated instructions
coresdk/src/test/test_camera.cpp
Outdated
| } | ||
|
|
||
| update_sprite(s); | ||
| update_sprite(s1); |
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.
Loop
coresdk/src/test/test_camera.cpp
Outdated
| draw_triangle(COLOR_AQUA, screen_width() / 2, 0, 0, screen_height(), screen_width(), screen_height()); | ||
|
|
||
| draw_sprite(s); | ||
| draw_sprite(s1); |
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.
Loop
| center_camera_on(s, offset.x, offset.y); | ||
| } | ||
|
|
||
| void center_camera_on(sprite s[],int size , const vector_2d &offset) |
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.
Sloppy!
|
I will make the changes once I got back to my computer 🙌 |
|
strangely enough, I didnt notice the indentation error when I'm working on it. Usually VS code should have warned me about it 🙁 |
|
Update: It seems like the indentation of "camera.h "on my local computer looks fine, I do not know why this happens in github but I will get it fixed real soon and have my senior to get it checked up |

Description
Added in support for vector array and static array for center_camera_on() method for C++ as calculating multiple sprite locations can be tedious.
parameters:
vector<sprite> sdouble offset_xdouble offset_yparameters:
sprite s[]int sizedouble offset_xdouble offset_yBoth supports vector_2d data sets too:
Video demo:
2023-09-07.23-12-04.mp4
Type of change
How Has This Been Tested?
Checklist: