FAQ Database Discussion Community


Foreach statement does not contain public definition for getEnumerator

c#,collision,monogame,enumerator
I am trying to implement collision between two paddles and I am getting the GetEnumerator error. This is where I am getting the error: foreach (Player item in paddle1) { item.Update(gameTime); if (paddle2.CollisionSprite(item)) { paddle2.Velocity = -paddle2.Velocity; } } And my Collision methods from Player: public virtual Circle CollisionCircle {...

Box2D not detecting collision

java,libgdx,box2d,collision
I'm working on a game using the Box2D extension of the LibGdx library and everything is working like it should except for the collision detection. This is what it currently looks like: Image The idea is the player (little circle) can jump in his bounds (gravity is set towards the...

Limiting List Iterations in a For Loop (Closest To Player)

c#,optimization,xna,collision
I have a List<Collider> colliders which is for a tile map. One approach that I thought of is to check the full list for all colliders' positions, compare to player's position, then add closest colliders to a temporary list for faster iteration. Only doing this once every 100ms would decrease...

Why are sprites in contact with each other although they do not collide ?

swift,collision,contact,skaction
I am trying to make a simple SpriteKit game. There are two sprites on the screen. One of them is shooting laser gun. When the laser goes through the screen it should be missed. The bullet and the sprite are not in contact with each other but contact detection func...

Object Collision Issues

java,exception,collision
I'm making a basic game, and it's almost done. I was trying to do object collision and started getting IndexOutOfBounds exceptions. I think this means that my arrayLists that I am storing object under are pointing to nothing, but I don't know why this is happening nor how to fix...

how to create a linked-list in a hash-table with the specific index?

java,linked-list,hashtable,collision
public boolean isCollide(String key, String value){ int index = key.hashCode(); if (this.key_array[index]==null) return false; else return true; } public void addValue(String key, String value){ Hashtable hashtable = new Hashtable(key,value); int index = key.hashCode(); if (isCollide(key,value)) { hashtable.key_array[index]=key; hashtable.value_array[index]=value; } else{ LinkedList<String> linkedList = new LinkedList<>(); linkedList.add(value); //how to create a...

Jquery collision of 2 elements

javascript,jquery,collision
First of all I'm very happy to be apart of the Stackoverflow community! Been reading for almost a year now and I've always found very useful bits here and there. I've been trying to code a very simple collision function in jquery but can't seem to find the issue with...

HTML5 Canvas Collision Detection

html5,canvas,collision,detection
So I have been looking around and trying tutorials but I can't seem to get any collision detection systems to work. If someone would be able to explain what I am doing wrong or any syntax errors that would be great. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Bouncing Ball</title> <style>...

Collision - recognizing when object has stopped colliding

java,collision
What I mean is that when I collide with the side of an entity and want to jump, I cannot move right/left as I have a flag which prevents this when I collide with the entity on the right/left side, like so: This is code code I use to detect...

Physics with bouncing balls

java,swing,collision-detection,collision,game-physics
Is this the right site to ask this question, since I've been referred to another site two times by now. I'm trying to create bouncing balls with realistic physics. At the moment, when the balls hit each other, they bounce back in the same direction they were coming from, now,...

How to remove Sprite when collision is detected? Libgdx

java,libgdx,collision,rectangles
Every random time (between 1,2 and 3 seconds) a rectangle and a sprite is created,1 rectangle for each sprite that spawns. new enemy method is called at random time: public void newEnemy(){ Sprite enemy= Pools.obtain(Sprite.class); enemy.set(enemySpr); enemy.setPosition(200,150); enemies.add(enemy);} the same thing happens to rectangles: public void newRect(){ Rectangle rect=Pools.obtain(Rectangle.class); rect.set(enemyRect);...

Why should I be failing this simple python algorithm?

python,python-2.7,encryption,collision-detection,collision
I have an algorithm that I want to write in python and analyze it. I think I wrote it well, but my output doesn't match what the given output should be. given algorithm; Input{inStr: a binary string of bytes} Output{outHash: 32-bit hashcode for the inStr in a series of hex...

SpriteKit physics: How to make a player sprite follow the (sloped) ground

ios,swift,sprite-kit,collision,skphysicsbody
I am creating a tilemap platform game in SpriteKit. I assigned collision paths to the physics body of all ground tiles and made them non-dynamic. To the player I assigned two collision polygons: a circle on the bottom and a rectangle on the top. The player sprite has a fixed...

How to expel a rect from inside another rect - Javascript

javascript,function,collision,rect
I am trying to make rect1 move out from inside rect2. I have tried to look around for an awsner but i am unable to find a satisfactory awnser. I can detect the rectangles intersecting, but i cannot expel rect1 so it goes outside rect2. Can you provide some code...

Players appear to be colliding with air?

java,opengl,collision-detection,lwjgl,collision
(Will be putting a bounty on this - Also, I'm not 100% sure what tags are relevant for this) I'm incredibly confused here. I am attempting to use this (simplified) model for my archers to collide with: However, as you can see, my archers appear to be colliding in mid-air!...

Emit Particle onCollision in Unity 3D

c#,animation,unity3d,collision,particle-system
I have a character that is going to collide with a coin. When the character collides with the coin, a particle "animation" should occur. Here's my code so far. Some basic assistance would help a lot. This code is attached to the player character. void OnTriggerEnter(Collider _hit) { if (_hit.tag...

List removal error in Pygame 1.9.2a0 after collision detection

python,list,vector,collision-detection,collision
I am trying to make a breakout clone in Python 3.2.5 using Pygame 1.9.2a0. The code is way more complex than what is really needed, but this was my first program in python/pygame and I am used to having stuff split up in their own classes/objects. Anyways - the problem...

SDL Tile and Sprite Rendering Terrain

c++,opengl,sdl,collision,tiles
Hello recently i started to mess around with SDL. Since i was interested in some 2D/2.5D games.So i started messing around with SDL in C++, I was looking to recreate something similar to Original Zelda. So as far as i understand those game work with some kind of isometric prespective,...

How do I make the code Wait for a few milliseconds in C#?

c#,xna,collision,game-physics
I have made some collision if statements, but they didn't work. birdbox3.X += 5; birdbox3.Y -= 5; if (birdbox3.Intersects(Banner1)) { birdbox3.Y += 10; } else if (birdbox3.Intersects(Banner2)) { birdbox3.Y = -birdbox3.Y; } So if we take the first statement, the box is initially on the left down corner. According to...

Cannot assign a value of type “Game Scene” to a value of type “SKPhysicsContactDelegate”

swift,collision-detection,physics,collision,contact
I am trying to build flappy bird on my own. Everything works fine but now I have added the CategoryBitMasks and all that stuff and every time I try adding this piece of code: self.physicsworld.contactDelegate = self I get the error message : Cannot assign a value of type 'GameScene'...

Flash actionscript 3, collision detection upon keypress

actionscript-3,flash,collision,detection
I am trying to get my character to collide with the walls I have created but I am having difficulties doing so, I have tried using solutions in other threads but none have worked. help please. Essentially I got collision detection working, however it only activates upon clicking, with a...

Error in checking for if mouse is in tolerance

if-statement,processing,collision
I have a rect, which I want to disappear when it's getting clicked. I use the following method to control if the mouseX and height*0.9 is in the area of the rectangle when clicked: //balken is a ArrayList of the object holding the variables for the rectangle boolean mouseInTolerance() {...

How can java detect collision of shapes that are stored in an array Java

java,arraylist,collision-detection,collision,shape
So what am trying to do is to enable the user to draw rectangles and detect collisions between rectangles. The rectangles are added into an Array_List shapes: ArrayList<Shape> shapes = new ArrayList<Shape>(); and for the collisions java must go through the ArrayList to detect collisions of shapes. (Any other ways...

Collision Detection and isGrounded checks

c#,unity3d,collision
I'm currently working on a project in Unity and as I'm fairly new to C# and programming in general I'm having a few issues. The first issue is with the collision detection for my player - I have a modelled Rigidbody with gravity and a mesh collider on (non convex)...

Rectangle Wall collision in Java

java,collision,rectangles,pacman
I really could use some help in order to find a working solution for my game. My game is almost done, but the walls in my game are still not working as they should. I have tried to find a solution on the internet for this problem, but i still...

Why does a certain if statement only trigger once in a while loop?

python,while-loop,pygame,collision,pong
I'm trying to get into game programming but I'm having difficulty with the first game I'm making. I want to make a pong game, but I can't get the collision detection to work twice. It works once either way the ball goes, but the second time doesn't work. Here's my...

how do you make a Rectangle change it's position or move?

java,libgdx,collision,movement,rectangles
I'm using rectangles for collision detection and a rectangle is created every 3 seconds, I wan't the rectangle to move upward just like my sprite but .translateY() method can't be used on rectangle. this is what I did to my sprites stored on ArrayList: for(Sprite sprite:mySprite){ sprite.translateY(deltaTime*movementSpeed); } and this...

Java 3D LWJGL collision

java,lwjgl,models,collision,detection
I am making a 3D Java game with the LWJGL library, and I was wondering how to add collision detection, so that the player does not go through models. I am using OBJ models. Here is the OBJLoader class, which loads the models: package renderEngine; import java.io.BufferedReader; import java.io.File; import...

XNA : 2D Foreach Collision detection issues with a reference of “t” not exiting in current context.

c#,foreach,xna,collision
My problem is that; when doing collision detection using bounding boxes my second player's arrows are not detecting the fact that they are hitting the "pots" on screen. My first player can hit them just fine, when trying to duplicate the player 1's foreach statement for detecting collisions I have...

Unity 2D collisions - how to setup objects that collides among themselves

unity3d,2d,collision
I am starting with Unity 5 and I am straggling a bit with its 2D collisions. Looking a bit into it I found that there are three types of objects that can be defined: - Static: Just a 2D collider (2D collision box component for example). - Dynamic: 2D collider...

How do I detect the collision of two sprites using pygame?

python,pygame,sprite,collision
This is my code so far, I can move and it places out a blip to pick up, I just need to know how to register that and move the blip to a new random spot! I am very new to pygame and not 100% fluent in python either, but...

How are hash collisions handled?

swift,dictionary,hash,collision
I've recently learned a little bit about hash values, and therefore also heard of about the problem of hash collisions. I therefore wondered: How does one deal with those? E.g. Swift's Dictonary uses hash values with its keys. I assume that it looks up its values via the hash. So...

How would I test if a particular object is entirely within another object?

actionscript-3,flash,collision
I don't want to just test if an object has collided with another object but rather test if the entire object (which is rectangular like) is completely located within another object (which is circular).

Swift collision not working. I think something is wrong with my code in didBeginContact

swift,collision,bitmask
I've been working on a game that has to perform a test every time my test node contacts with my check node. As these two nodes are the only nodes that will be checking for collision in the game, I decided to use this method to initiate my test. The...

How to check collision if only bottom half of the sprite matters (think of a cherry with a stem)

swift,sprite,collision,rect
I am trying to put together a game using SpriteKit, in Swift. I have a moving sprite which is a rectangle of width (sprite.frame.size.width) and height 2*(sprite.frame.size.width) I only want to check collision of the bottom half which is a square of width (sprite.frame.size.width) and height (sprite.frame.size.width) I set sprite.anchorPoint...

Unity3D Play sound from particle

audio,unity3d,collision,particles
I am trying to play a sound when a particle collides with a wall. Right now, it just plays the sound from the parent object, which is the player. However, I want the sound to play from the particle. Which means when a particle is far to the left, you...

How does an iBeacon/sender/receiver handle collisions?

protocols,collision,ibeacon
What is the theoretical/practical limit to the number of ibeacons you can have within their broadcasting range; there must be one. And what do they do, if anything to compensate should their signal constantly collide with another, unsure if they even know ? Anybody? Imagine you have 30 beacons within...

simple 2d collision in monogame (using xna pipeline)

c#,collision,detection,monogame
I am just starting to learn monogame and I am using the XNA pipeline (search RBWhitiker) to create a 2d platformer, however I have become stuck when trying to get my player to jump on a platform. My player can run past the platform and jump, which is desired. The...

Rectangle collision - Unwanted overlapping. (Processing IDE)

java,processing,collision-detection,collision
So I have this simple processing sketch where blocks follow the mouse. It has a basic collision function which detects an intersection between two rectangles then sets rectangle A's position equal to rectangle B's position minus rectangle A's width (assuming rect B is in front of A). Unfortunately this method...

Pygame image collision

python,pygame,collision
I have a pygame program where there's a face in the center. What I want the program to do is have a bunch of objects on the screen, all irregular. Some would be circles, others would be cut-out pictures of objects like surf boards, chairs, bananas, etc. The user would...

Pygame Screen Collision Troubles, Player Moves Off Screen

python,pygame,screen,collision
I've looked around alot for code to implement screen collision but I can't find any that I know how to adapt to my own code, so I just need some help figuring out how to make my player not go through the screen. import pygame import random pygame.init() display_width =...

pygame rect collision smaller than image

python,image,pygame,collision,rect
How can I define a rect collision detection smaller than image in pygame? I'd like to have a collision patter like the second image , but I'm having a cut image when a try to set the width and height in the method rect. When I try to set using...

SpriteKit tilemaps collision with curved or sloped floor tiles

swift,sprite-kit,collision,tile,tiled
I am planning a platforming game for iOS using SpriteKit and Swift. I did some research on how to handle collisions of the player sprite and stumbled upon this article. http://www.learn-cocos2d.com/2013/08/physics-engine-platformer-terrible-idea/ That article advices you not to use the build-in physics engine of SpriteKit but to implement things like moving,...

multiple DIV collision detection in Javascript/JQuery

javascript,jquery,html,collision
Working on a little "zombies" or "tag you're it" or "ew! you got cooties"-styled game where each AI object (a person, basically) runs around randomly. There is an initial object that is "it" or "infected" and as it moves about the screen and touches/overlaps/collides with another object it should change...