Search found 4373 matches
- January 21st, 2022, 10:12 pm
- Forum: Everything
- Topic: Obstacle Collision Poo game
- Replies: 5
- Views: 3058
Re: Obstacle Collision Poo game
Naïve approach: // Least penetration int px = std::numeric_limits<int>::min(); int py = std::numeric_limits<int>::min(); int dude_left = x; int dude_top = y; int dude_right = x + GetWidth(); int dude_bottom = y + GetHeight(); int wall_left = wall.GetX(); int wall_top = wall.GetY(); int wall_right = ...
- January 20th, 2022, 9:22 pm
- Forum: Everything
- Topic: Obstacle Collision Poo game
- Replies: 5
- Views: 3058
Re: Obstacle Collision Poo game
The easiest way is to detect which side of the box you are colliding with. After you find the side you collide with, you calculate the penetration depth. This gives you the direction and amount you need to reverse the dude so there are no more collisions. To determine which side of the box you colli...
- January 20th, 2022, 9:24 am
- Forum: Everything
- Topic: Fun with templates
- Replies: 7
- Views: 10644
Re: Fun with templates
One of the things I find myself doing is making small simple utility functions or in this case, classes and pseudo functions that I can use to build something more complex. While a lot of those utilities probably aren't useful outside of this domain, it helps making the complex things simpler and ea...
- January 20th, 2022, 8:50 am
- Forum: Everything
- Topic: Fun with templates
- Replies: 7
- Views: 10644
Re: Fun with templates
Here's the companion class and a specialization. template<std::size_t alignment_, typename...Ts> class tuple_like { public: using member_list = list<Ts...>; using element_type = list_to_variant<list<Ts...>>::type; using storage = std::array<element_type, m_member_count>; public: constexpr tuple_like...
- January 20th, 2022, 8:13 am
- Forum: Everything
- Topic: Fun with templates
- Replies: 7
- Views: 10644
Fun with templates
Haven't posted my usual random stuff in some time, but here's what I've been up to. template<typename...Ts> struct list { using type = list<Ts...>; static constexpr auto size = sizeof...( Ts ); using empty = std::conditional_t<size == 0, std::true_type, std::false_type>; static constexpr bool is_emp...
- January 12th, 2022, 8:37 am
- Forum: Everything
- Topic: Stuck with vectors
- Replies: 12
- Views: 6666
Re: Stuck with vectors
Before I made that chart, I had made changes to exclude the circular references. It doesn't include files from the framework nor the standard library, just those pertaining to your game. When you do look at it, the lines go from the file that is included to the file that includes them. In other word...
- January 12th, 2022, 4:30 am
- Forum: Everything
- Topic: Stuck with vectors
- Replies: 12
- Views: 6666
Re: Stuck with vectors
#include "Action.h" #include "Colors.h" #include "Font.h" // -> "Surface.h" -> "Colors.h" // "Location.h" // "Graphics.h" -> "ChiliException.h" // "ChiliWin.h" // "Colors.h" // "Rect.h" // "Surface.h" -> "Colors.h" #include "Graphics.h" // -> "ChiliException.h" // "ChiliWin.h" // "Colors.h" // "Rec...
- January 11th, 2022, 8:51 am
- Forum: Everything
- Topic: Stuck with vectors
- Replies: 12
- Views: 6666
Re: Stuck with vectors
Awesome. Was really trying to think about why you would be using reverse_iterators. The only thing I've come up with is removing elements from a container while looping through them, but there is a different way of doing it that is a little bit less code. // First, remove_if moves elements to the en...
- January 10th, 2022, 11:39 am
- Forum: Everything
- Topic: Stuck with vectors
- Replies: 12
- Views: 6666
Re: Stuck with vectors
Basically, there is a line of code that uses a negative number to access a map when you click on one of the tiles...that's what triggered for me anyway. The forum kicked me out for being idle while writing and when I submitted it all went away and I am too tired to find it again.
- January 10th, 2022, 11:37 am
- Forum: Everything
- Topic: Stuck with vectors
- Replies: 12
- Views: 6666
Re: Stuck with vectors
Make sure to use assert() a lot, especially when you are accessing arrays. I suggest using std::array<T, size> instead of C arrays map[ size ]. They are little safer, usually won't let you access outside the bounds of the array. They also have the added benefit of being able to use them in the STD a...