Tag Info

New answers tagged

1

By using SDL_RenderCopy you can do all the zoom in/out or scaling stuff, by using non null values for the srcrect and dstrect parameters. Here is the prototype of the function : int SDL_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect) ...


0

The modifier keys can be combined with OR-bits. You need to use AND-bits to test for the modifier flags since it could contain all of CTRL+ALT+SHIFT (Left AND Right) and even some other modifier keys. For example, if NumLock or CapsLock is ON, the value will never be == to LeftShift. See the documentation for the ModifierKeys. It is also not necessary to ...


1

You could re-order your std::vector<Object> by creating a function that sort it by Y position of your objects void SortObjects() { std::sort(Object.begin(), Object.end(), CompareYAxis); } bool CompareYAxis(const Object first, const Object second) { //Do the comparison here } I think this would work.


0

To expand @Alexandre Vaillancourt answer, I would even consider using a collection that keeps your data sorted, instead of re-sorting it every frame. struct Drawable_compare { bool operator() (const IDrawable& d1, const IDrawable& d2) const{ return d1.y < d2.y; } }; class Renderer { private: std::multiset<IDrawable*, ...


1

I would forget right away the option to create the sprites in order based on their y coordinate as it will create a hell for you because it's not a flexible design. You look like you need a common way to handle the drawing process. You can achieve this using polymorphism. I would probably create a IDrawable interface, which requires children to have ...


1

If you have to handle a large set of keys have a look at: SDL_GetKeyState which gives you a snapshot of the state of the whole keyboard.



Top 50 recent answers are included