null;

Members
  • Content count

    60
  • Joined

  • Last visited

Community Reputation

239 Neutral

About null;

  • Rank
    Member
  1. Tile Transition Logic

    That does seem to be the correct search term, thank you.
  2. Tile Transition Logic

    I apologize for my lack of clarity. Here's a diagram of what I'm trying to accomplish. https://gyazo.com/41dcae854315a28a67cb30390c365771 Notice how when the tiles are grouped, not all sides of each individual one are rendered, only the exposed ones.
  3. Tile Transition Logic

    I think I've thought of a better way of explaining my question, or what I want to accomplish. How would I incorporate tile smoothing, so the edges aren't always jagged and pointed. Basically, just corner smoothing.
  4. Tile Transition Logic

    How would I go about implementing tile smoothing? Let's say there's a 3x3 set of grass tiles. I want the outside grass tiles to have some kind of outline, while the middle one blends in with the rest. I don't really see a point in sharing any code, as I'm just asking for the implementation process. Thank you to whoever replies!
  5. SFML Odd Collision

    It gets called before the keyboard logic function is called, in the main class. leftCollisionRectangle.intersects(otherRect) is false after the keyboard is released and the odd player movement occurs, but it's true while the player is actively moving into the rectangle.   The logic is as simple as the pseudocode demonstrates.
  6. SFML Odd Collision

    I have 4 rectangles attached to my player for collision detection. When the player collides with anything, it's moved back the opposite direction.   Here's some pseudo code to demonstrate how it works. if(leftCollisionRectangle.intersects(otherRect)) { player.move(1, 0); //player's position is set to its x, plus one 1, and the y isn't affected as it isn't checking for top or bottom collision in this example } So I'm moving the player in the opposite direction at its speed when it intersects with another rectangle.   This is the result: (I'm drawing the player's collision rectangles to demonstrate the intersection) https://gyazo.com/33b257b8ec5063b021a927d844a655ec   It works, but it's buggy. The player is getting pushed back more once the key is released. Is there anything wrong with the logic I'm using to keep the player from being able to move through the rectangle, or could it be some kind of other issue?
  7. SDL 2 Zooming In and Out

    Yeah, it really helped with the first part. I'm mad at myself for not thinking of that!   The problem is, this kind of only works with the background image, since the way the player is rendered differs to the way the background is rendered. I'm having a hard time explaining it at the moment, I'll post another reply when I can.
  8. SDL 2 Zooming In and Out

    Wow... I mean, I really appreciate the detailed reply and code examples; I just... don't really understand a lot of it.   I mean, here's the way I'm currently doing it (pseudocode):  SDL_Rect camerRect = { 0, 0, 640, 480 }; in game loop: camerRect.x = player1.positionRect.x - 290;        camerRect.y = player1.positionRect.y - 170;         player1.Draw(renderTarget, camerRect);         SDL_RenderPresent(renderTarget);         SDL_RenderClear(renderTarget);         SDL_RenderCopy(renderTarget, mapTexture, &camerRect, NULL);   player draw method in player class:           void Player::Draw(SDL_Renderer *renderTarget, SDL_Rect camerRect) {                 SDL_Rect drawingRect = { positionRect.x - camerRect.x, positionRect.y - camerRect.y, positionRect.w * 2, positionRect.h * 2};                 SDL_RenderCopy(renderTarget, texture, &cropRect, &drawingRect);         }   I don't think the kind of stuff you're talking about applies to how I'm doing it - if it did, I don't really understand it...   Again, I really appreciate the detailed reply. I apologize for my noobness at this, lol.
  9. SDL 2 Zooming In and Out

    I recently got into SDL 2 in C++. I've implemented a camera into the game, and was wondering how I would go about zooming. I've tried doing many things, but I won't go into detail because I don't think I'm on the right track at all.   If any of you have implemented zooming in/out into your game, can you specify how you actually did it?   Thanks to everyone who replies.
  10. GameObject class structure

    Sort of. Pointers, references, or some other advanced programming techniques under the bucket of "type erasure" (that under the hood use pointers or references somewhere) can all provide dynamic polymorphism, like Java. Value objects - which Java doesn't support for user-written classes - cannot be _dynamically_ polymorphic, but can be _statically_ polymorphic (a concept that mostly doesn't exist in Java). For instance, C++ functions and classes can be generated with templates, so you can write a single function that takes any type of value and operates on it. Functions that operate on objects polymorphically can work on any kind of object in C++. e.g. you can get a reference or pointer to any object, no matter how it was created. The function doesn't and shouldn't care where the object came from. That said, dynamic polymorphism is a bit rarer in C++ than Java, typically because polymorphism and class inheritance and such are _bad solutions_ for a number of problems. Java programmers tend not to notice how bad those solutions are because Java _forces_ people to use polymorphic objects for everything; C++ gives you a lot more options for when dynamic polymorphism is a suboptimal tool for the job. Some examples:   // references should be preferred over pointers in most cases void foo(base_type& ref) { ref.method(); // dynamically polymorphic } // higher level abstractions can also be polymorphic and are sometimes very preferable over base classes and inheritance void foo(function<void(int)> func) { func(42); // "polymorphic" because func can be bound to a free function, member function, lambda, etc. } // templates are a form of static (compile-time) polymorphism template <typename T> void foo(T val) { val.method(); // tries to invoke T::method() on val, no matter what T is } In general, remember two things: - you should _very rarely_ ever have a raw pointer in C++. If you're passing around ownership of an object, use std::unique_ptr or std::shared_ptr, and if you're just observing an object, use a reference or std::weak_ptr (and __strongly__ prefer unique_ptr and references as shared_ptr/weak_ptr can cause more problems than they solve if you're not careful!). - don't use inheritance to solve every problem. that's Java-esque thinking that should be stamped out when moving to another language. :) inheritance solves a small few particular types of problem very well but leads to either inflexible code, overly-coupled code, or poorly-performining code when it's overused.   Wow, thanks! Yeah, I figured making everything I wanted to incorporate polymorphism with (which would be a lot of things in a game) a raw pointer would just get tiring after a while.    Yeah, I was worried about writing Java++ code. Thanks for the clarification!
  11. Hey all. I recently started doing some game development in C++ - I've been trying out both C++ and SFML.   Anyways, I've recently encountered this issue that I'm not sure how I'll overcome when the time comes. Well, it's not really an issue per se, but I'd like some clarification in any case.   In a language like Java, polymorphism is just a matter of changing a function in a derived class. I assume this is because pretty much everything is a pointer in Java.   However, in C++, I found out that an object has to be a pointer for me to properly implement polymorphism.   Is this actually the case, or is there some other method everybody uses that I'm unaware of?  
  12. I recently formatted my PC and upgraded to windows 10, as it was starting to get really slow and had a few driver issues.    After getting everything set up, I went to install visual studio, but I had to cancel because I forgot to add a feature. After doing that, the installer displayed a message saying that it installed 5 components out of 309 or something like that.   I really don't want to screw things up with my new setup. Did the act of cancelling the installation do anything that could have harmed my PC? If so, is there any relatively simple, non-hacky fix?   Thanks to anyone who replies.
  13. C++ SFML Stuttering

    The problem seems to have come back. 
  14. C++ SFML Stuttering

    Yeah, the issue got fixed somehow. Thanks anyways!   Just to answer your question, I load my assets at load time.
  15. C++ SFML Stuttering

    Yeah, that makes sense. When I framelocked it to 60 fps, it would drop down to ~19.   The stutters are pretty clear in-game. It would be a lag spike that lasts for about half a second, and it happens at half a second intervals.   This has affected every SFML project I've had as far as I can tell.   I'll just do a bit more research. Thanks anyways!   EDIT: The issue got fixed, but I'm not entirely sure how.