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

Plans to continue? #5

Open
jmarcher opened this issue Jan 29, 2020 · 5 comments
Open

Plans to continue? #5

jmarcher opened this issue Jan 29, 2020 · 5 comments

Comments

@jmarcher
Copy link

Hi @carlbirch do you have any plans to continue with the series? I learned a lot from your videos and the game is looking sharp.
If you are not planning to continue with the development, do you have any guidelines that you suggest on how to follow with the Game?

@drew-wilson
Copy link

Would love to help grow this engine. @carlbirch has taught me a lot about C++ and coding from the ground up. I found a way to change the for loop in the map.cpp to accept more than 99 tiles. If you're creating a large landscape that has more than 99 unique tiles, the engine currently cannot process that. I can do a pull request later and share how I did it.

Also, any idea on how to switch maps? Was thinking of doing this in the game.cpp's update function. Can we do this based on 'playerPos' which is the Vector2D we created? We're using it for collision, just don't know how to check it and switch the map based on the player's x,y. Something like:
if (playerPos = {900, 775}) { map->LoadMap("assets/env_2.map", 16, 16); }

@jmarcher
Copy link
Author

Would love to help grow this engine. @carlbirch has taught me a lot about C++ and coding from the ground up. I found a way to change the for loop in the map.cpp to accept more than 99 tiles. If you're creating a large landscape that has more than 99 unique tiles, the engine currently cannot process that. I can do a pull request later and share how I did it.

Also, any idea on how to switch maps? Was thinking of doing this in the game.cpp's update function. Can we do this based on 'playerPos' which is the Vector2D we created? We're using it for collision, just don't know how to check it and switch the map based on the player's x,y. Something like:
if (playerPos = {900, 775}) { map->LoadMap("assets/env_2.map", 16, 16); }

Yeah there is a simple yet efficient way of doing that in just 2 lines of code in the TextureManager:

void TextureManager::draw(SDL_Texture* texture, SDL_Rect source, SDL_Rect destination, SDL_RendererFlip flip)
{
    // Now we check if we need to render the texture or not.
    if(destination.x < (Engine::camera.w + destination.w) && destination.x >= ((-1) * destination.w))
        if(destination.y < (Engine::camera.h + destination.h) && destination.y >= ((-1) * destination.h))
            SDL_RenderCopyEx(Engine::renderer, texture, &source, &destination, 0, NULL, flip);
}

That way we render only the Sprites or tiles that are visible.

@drew-wilson
Copy link

Ah, I do see how this works. It's useful if I have one very large map. that spans an area larger than the window size. I was thinking more along the lines of loading new maps from external files. Similar to how I said above, 'if player is at the edge of the screen, then load the second map'.

@jmarcher
Copy link
Author

Yes, you could do something like that but you could have unnecessary disk reads. You can surely load a huge map and just render the visible part easily.

You could change the map using your method as well just remember if you load a new map you should deactivate the old tiles.

@GlockPL
Copy link

GlockPL commented Jul 22, 2022

Maybe forking this and merging patches would be a good idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants