Oddly Posted September 7, 2018 Share Posted September 7, 2018 https://gitlab.com/salemgd/salem2d/blob/feature/game_world/src/system/objects/GameWorld.cpp Got this file, the code is very C Like written in C++. I feel like there's a lot of repetition in it, but don't know how I would split it up, looking for suggestions. Checkout the Update function and the DrawMask and DrawFringe functions. Link to comment Share on other sites More sharing options...
Mighty Professional Posted September 7, 2018 Share Posted September 7, 2018 Why do you have identical shift map code 4 times with just some index's changed? I dont want to read the math there because im lazy but im sure there is a way to do it programatically.  Also if your to lazy like I am, just make a function take a matrix and pass in the index's. Link to comment Share on other sites More sharing options...
Oddly Posted September 7, 2018 Author Share Posted September 7, 2018 7 minutes ago, Mighty Professional said: Why do you have identical shift map code 4 times with just some index's changed? I dont want to read the math there because im lazy but im sure there is a way to do it programatically.  Also if your to lazy like I am, just make a function take a matrix and pass in the index's. That's the point of the post, How can I refactor that? Each function does different operations for the indexes. It's just a matrix, and one if statement shifts the maps in the current block down, so it clears the bottom 3 maps, moves row 1 to row 2 and row 0 to row 1 than loads row 1, while another function does almost the same thing but shifts maps left, so clear the right side, move col 1 to col 2 and col 0 to col 1 than load col 0. The code seems repetitive but each if statement is doing something else. I wanted to see if I could find a way to move the contents of each if statement into a single function, but wasn't sure how. Link to comment Share on other sites More sharing options...
Mighty Professional Posted September 7, 2018 Share Posted September 7, 2018 Where is get_map_left and get_map_right etc declared? Link to comment Share on other sites More sharing options...
Oddly Posted September 7, 2018 Author Share Posted September 7, 2018 7 minutes ago, Mighty Professional said: Where is get_map_left and get_map_right etc declared? It's a function in the Map's header file SALEM_API std::string& get_map_right() { return m_map_right; } m_map_right gets loaded from the map's json file. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now