collision

SFML tilemap collision

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:57:50
问题 I'm making a 2D game in SFML and I'm trying to figure out how to collide with tiles in a tilemap. I've written some code but the problem is that I get stuck in the tile I'm colliding with as you can see in the picture below. I cannot move in any direction and around 5 pixels of the player is in the wall. This is my collision / movement code void Player::update(float delta, std::vector<Tile>& tiles) { canMove = true; for (int i = 0; i < tiles.size(); i++) { if (Collision::PixelPerfectTest

Do swift hashable protocol hash functions need to return unique values?

帅比萌擦擦* 提交于 2019-12-11 02:12:55
问题 I am working through an iOS swift Tetris tutorial* and have it completed and working. But I am puzzled about one particular aspect - the Hashable protocol. The function: class Block: Hashable, Printable { [...] var hashValue: Int { return self.column ^ self.row } Rows go 0..9, and Columns 0..20. The notes says of this function "We return the exclusive-or of our row and column properties to generate a unique integer for each Block.". But my understanding is that 0^1 would be the same as 1^0,

Zend framework 2 : Add different authentication adapter for two different modules

送分小仙女□ 提交于 2019-12-11 01:16:02
问题 I have two different modules. Now I need to add different authentication mechanism for both modules. So I added event code first module's Module.php's onBootstrap method $listener = $serviceManager->get('First\Service\AuthListener'); $listener->setAdapter($serviceManager->get('First\Service\BasicAuthAdapter')); $eventManager->attach(MvcEvent::EVENT_ROUTE, $listener, 0); and in second module's Module.php's onBootstrap method $listener = $serviceManager->get('Second\Service\AuthListener');

How to “round” a 2D Vector to nearest 15 degrees

六眼飞鱼酱① 提交于 2019-12-11 00:08:30
问题 I'm working on a simple game and I'm trying to simplify part of the 2D collision reaction in the game. When certain objects hit walls, I'm calculating a collision normal ( collisionPoint - objectCenter ) and reflecting based on that normal. I'm interested in rounding that normal vector to its nearest 15° but I'm not sure of a good way to go about that. My current thought is doing something like this float angle = atan2(normal.Y, normal.X) * Rad2Deg; float newAngle = ((int)(angle + 7.5f) / 15)

Perfect circle to perfect circle and Perfect circle to straight line collision HANDLING in Java

帅比萌擦擦* 提交于 2019-12-10 19:54:18
问题 I am a newbie at Java, but decided to make a application that has a bunch of balls bouncing around. Please keep in mind that I know almost nothing about normals, which I have seen mentioned a lot in this kind of thread. I have also only take Algebra 1, and know a little bit of trig (sin, cosin and tangent). Anyways... I have collision detection covered, using if (java.awt.geom.Point2D.distance(X1, Y1, X2, Y2) < ball1.radius + ball2.radius) {return true;} else {return false;} and if (ball.x +

Collision c++ 2d game, preventing player from entering tile

瘦欲@ 提交于 2019-12-10 17:49:30
问题 I've tried for several days and spent hours searching the web to no avail. I'm having trouble with collision, i can detect the collision but my problem is preventing the player from entering the tile. I've tried all i can think of. I'm detecting the collision of my tilemap using 1 for solid and 0 for passive for(int i = 0; i < tiles.size(); i++) { if(colMap[tiles[i].y][tiles[i].x] == 1) { myrect.setFillColor(sf::Color::Red); collide = true; break; } else { collide = false; break; } } This

How to determine point/time of intersection for ray hitting a moving triangle?

筅森魡賤 提交于 2019-12-10 11:35:19
问题 I have a deforming triangle, whose vertices all move between t0 and t1. I am shooting a ray toward the triangle. The ray doesn't hit the triangle at t0 or t1, but somewhere within that interval of time. How do I calculate the exact point of intersection for the ray, and at what time (between t0 and t1) that the ray hits the triangle? Here's an image that hopefully helps illustrate the question better: 来源: https://stackoverflow.com/questions/43771759/how-to-determine-point-time-of-intersection

Collision detection in a 2D maze with thick walls

岁酱吖の 提交于 2019-12-10 07:27:40
问题 I have to make a game with Windows Forms for school. My game consists of a user having to get through a maze. I'm trying to prevent my user from going straight through the walls using collision detection, but am getting stuck because of the varying shape of the rectangles being used to represent walls. Here's an image of the game. This question may be similar to this one, however with my movement I believe that it is quite different, as I don't have a grid system or graphical map laid out. As

Tag multiple branches in git?

天涯浪子 提交于 2019-12-10 04:03:12
问题 I have a git repository with two branches; one for code that's used for manufacturing/test and one that's the actual production firmware (they're nearly identical). It's now time to cut a release to send to the manufacturer, so I naturally want to put down some appropriate tags on both branches. But, it seems that git won't let me put the same tag name on both branches. If I try to tag the branches individually it tells me the tag already exists when I go to tag the seconds branch. I tried

libGDX- Exact collision detection - Polygon creation?

試著忘記壹切 提交于 2019-12-09 19:04:50
问题 I've got a question about libGDX collision detection. Because it's a rather specific question I have not found any good solution on the internet yet. So, I already created "humans" that consist of different body parts, each with rectangle-shaped collision detection. Now I want to implement weapons and skills, which for example look like this: Skill example image Problem Working with rectangles in collision detections would be really frustrating for players when there are skills like this: