game-physics

Collision detection of a ball with an arc

我们两清 提交于 2019-12-20 03:52:19
问题 I am making a simple game in which i have a ball and an arc revolving around the center. When user touches the screen the ball moves in the direction of pointer and hits the arc. But i am not able to find any method to detect that collision An image has been attached for better understanding Game image Debug Snapshot.. I have a circle bound around my ball... What i am doing is Detecting the point of intersection of ball center and circle on which arc is >revolving. But i am not able to detect

Javascript ball collision

落爺英雄遲暮 提交于 2019-12-19 11:57:30
问题 I am trying to create a simple javascript game with simple physics. I can determine when 2 balls are colliding but I have having problems with handling the collision. Does anyone know of any useful tutorials on this? I've been searching the internet for a couple days but can't seem to find anything. 回答1: In the UK, this would be A-level maths, so not too advanced. I think the phrase you need is "elastic collision". That page has some of the formulae you need. 回答2: Physics for JavaScript Games

How do I give this spaceship acceleration?

旧时模样 提交于 2019-12-19 10:17:21
问题 Have a very small snippet of an asteroids-like game I'm working on using only the DOM without Canvas. I have the "ship" moving pretty smoothly when arrow keys are pressed but how would I go about making the ship accelerate ( in speed and rotation ) when an arrow key is held down for a longer length of time? window.onkeyup = function( e ) { var kc = e.keyCode; e.preventDefault(); if ( kc === 37 ) Keys.left = false; else if ( kc === 38 ) Keys.up = false; else if ( kc === 39 ) Keys.right = false

Simulating orbits using laws of physics [closed]

Deadly 提交于 2019-12-19 03:18:39
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month . Over the past couple of weeks I've been trying to simulate orbits in a solar system simulation I am making as part of a University module. To cut things short, my simulation is written in C++ using the Ogre3D rendering engine. I have attempted to implement orbits using Newton's law

Smooth Keyboard Movement in Pygame

Deadly 提交于 2019-12-18 12:36:38
问题 I'm using this code to have a player sprite move around a screen when the arrow keys are pressed: import pygame, sys, time from pygame.locals import * pygame.init() FPS=30 fpsClock=pygame.time.Clock() width=400 height=300 DISPLAYSURF=pygame.display.set_mode((width,height),0,32) pygame.display.set_caption('Animation') background=pygame.image.load('bg.png') UP='up' LEFT='left' RIGHT='right' DOWN='down' sprite=pygame.image.load('down.png') spritex=200 spritey=130 direction=DOWN pygame.mixer

Smooth Keyboard Movement in Pygame

心已入冬 提交于 2019-12-18 12:35:59
问题 I'm using this code to have a player sprite move around a screen when the arrow keys are pressed: import pygame, sys, time from pygame.locals import * pygame.init() FPS=30 fpsClock=pygame.time.Clock() width=400 height=300 DISPLAYSURF=pygame.display.set_mode((width,height),0,32) pygame.display.set_caption('Animation') background=pygame.image.load('bg.png') UP='up' LEFT='left' RIGHT='right' DOWN='down' sprite=pygame.image.load('down.png') spritex=200 spritey=130 direction=DOWN pygame.mixer

Simulate water/ make sprite “float” on water in spritekit

浪子不回头ぞ 提交于 2019-12-18 11:36:04
问题 I'm trying to add water to my game. Except for a different background color, there isn't much to it. However, I'd like the player-sprite to float on top of it (or halfway in it). If the player just walks into the water from below, I'd like him to float to the top. If he falls down, I'd like him to slowly change direction and float back up. I tried making the gravity negative when he's in the water, but this gives me some slightly unwanted effects. For example as he (the player) surfaces, the

SpriteKit SKPhysicsBody with Inner Edges

和自甴很熟 提交于 2019-12-14 04:17:52
问题 I have created an SKSpriteNode called let's say Map that has an edge path that I have defined (some simple polygon shape). What I am trying to figure out is how to add several other edge paths that would act as interior edges of the Map . As if the "map" as a whole did in fact have holes . Some sort of inner boundary shapes that could act with Map as a whole: one edge path (as shown below) © I understand that there is a method that allows for creating an SKPhysicsBody with bodies (some

Character fall through ground after playing sometime

南笙酒味 提交于 2019-12-14 03:57:07
问题 I have a character with compound collider setup (the collider that is setup by many primitive collider shapes, one for each body parts), and a simple ground that is setup using a scaled cube. The cube is scaled 1000 in x and 30 in z axis. Things are still in early stage, so there is no expensive graphic, there are just primitive shapes and a low-poly character in scene. Things are going fine at begin, but for some time, after I play for a while, the character start falling through the ground.

How to handle Null Pointer Exception in libGDX's Box2D ContactListener?

你说的曾经没有我的故事 提交于 2019-12-14 03:23:08
问题 What's up everyone, I am heuristically producing a Pong clone in Box2D via libGDX. The Null Pointer Exception is originating in the ContactListener's beginContact() method in which I am trying to implement score logic. The Box2D world uses two separate EdgeShapes as sensors for incrementing a score variable upon collision with the Ball (view attached image). The collision logic between the Ball and the two EdgeShapes works, but collision between the Ball and anything else in the Box2D world