collision

Pygame collision detection not working how I want it to

非 Y 不嫁゛ 提交于 2019-12-31 04:24:27
问题 Collisions are not working the way I want them to. I want it so that whenever you hit a boat, you are sent back to MENUSTATE, and whenever you hit a fish, the image disappears and the game keeps running. From what I've tried, the game will go back to MENUSTATE after a boat collision for as long as the two objects are still colliding, but will go back to GAMESTATE when it's done. How can I have it so it permanently stays in the MENUSTATE after a collision with the boat, and how would I go

How to know which SKSpriteNode is affected by collision detection in Swift?

余生长醉 提交于 2019-12-30 06:49:54
问题 Situation: I have two or more ships on my iOS screen. Both have different attributes like name, size, hitpoints and score points. They are displayed as SKSpriteNodes and each one has added a physicsBody . At the moment those extra attributes are variables of an extended SKSpriteNode class. import SpriteKit class ship: SKSpriteNode { var hitpoints: Int = nil? var score: Int = nil? func createPhysicsBody(){ self.physicsBody = SKPhysicsBody(circleOfRadius: self.size.width / 2) self.physicsBody?

How to resolve Rails model namespace collision

风流意气都作罢 提交于 2019-12-29 04:22:23
问题 The story so far: I have a rails app with a model named "Term". All is well until trying to install Cucumber. Upon running rake cucumber I get Term is not a class (TypeError) This happens because Cucumber includes another gem, 'term-ansicolor' (to do the nifty colored text output in the console), and term-ansicolor defines a module named "Term". Cucumber includes term-ansicolor before including the Rails models, thus "Term" is already defined as a module when loading the "Term" model. Top

Detecting collisions in sprite kit

旧城冷巷雨未停 提交于 2019-12-27 12:21:34
问题 I'm trying to make a simple game with sprite kit. The basic idea is that there is one player who can jump to avoid blocks. But i have a problem I don't know how to make it that when the player hits the block the player disappears and the blood animation starts. First of all i don't understand what this code does that I found on apples website. static const uint32_t blockCategory = 0x1 <<0; static const uint32_t playerCategory = 0x1 <<1; Than i am calling the didBeginContact function and put a

How do I add a timer in libgdx java?

佐手、 提交于 2019-12-25 16:53:37
问题 I am trying to add a timer for power ups in my game. What I am trying to do is change a parameter (like jump height for example) after the player has collided with the power up box but it should only apply for 4 seconds. I have already written the collision coding and have added a random element to choose which power up is activated. I have also added a power up that will not use the timer (adding 1 to the score). Searching google I found code using various methods like Gdx.graphics

JQuery Collision Detection

折月煮酒 提交于 2019-12-25 08:48:37
问题 Not sure if I'm on the right track here, but I figured this should work: function collides(a, b) { return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y; } function handleCollisions() { $('#player').forEach(function(player) { $('#powerUp').forEach(function(powerup) { if(collides(player, powerup)) { $('#player').hide(); } }); }); } handleCollisions(); } Basically I have my player running around the game and the object at a fix position. When the

Collision of a line and object ( Corona SDK )

ぃ、小莉子 提交于 2019-12-25 05:24:27
问题 I am developing a game when there is a line and physics object The line code is: And the interesting thing is that when i code print ("collision is here") (for ex) they some how don't even collide! Both line and obj bodies are static How can make this collision happed? thanks in advance! 回答1: Static bodies can't collide with each other, but this question has a solution. 回答2: IF both lines are static make a function where you detect the x and y of both object and make equation accordingly, for

PyGame Collision detection for pong and keeping the paddles on screen

我怕爱的太早我们不能终老 提交于 2019-12-25 02:57:07
问题 So my problem here is that I don't want to use classes because I don't fully understand them yet nor do I want to use sprites. I have uploaded two images to the program I am able to move the paddles and get the ball to move and bounce off the top and bottom. However I cannot get the ball to bounce off the paddles. Also I cannot keep the paddles from going down off the screen or above off the screen. Any help would be appreciated thank you. import sys import pygame pygame.init() size = width,

Unity collider going through other colliders at times?

三世轮回 提交于 2019-12-24 17:18:13
问题 I'm trying to create a Pong clone for practice. I setup my project in 2D. The paddle has the following components: -Rigidbody2D (set to kinematic ) -BoxCollider2D (is a trigger ) The ball has the following components: -Rigidbody2D (set to kinematic ) -CircleCollider2D (is a trigger ) The paddle is controlled via dragging (user dragging finger on screen left/right). I used the EasyTouch plugin for this. Then I move the ball with this script: void Update () { transform.position += new Vector3

Three on node.js with JSONLoader

坚强是说给别人听的谎言 提交于 2019-12-24 16:09:46
问题 I need to use three.js on my node.js server to control positions and collisions on players (I try to make a video game). To use three on nodejs, I have install with "npm install three", and it's works. But when I want call JSONLoader, I can't. I my class, I add : var THREE =require('three'); //or require('three/three.js'); var JSON=require('three/src/loaders/JSONLoader.js'); or require('three'); //or require('three/three.js'); var JSON=require('three/src/loaders/JSONLoader.js'); It the same,