小编Gur*_*jit的帖子

检测矩形与圆的碰撞

实际上我试图在下面的代码中检测到矩形与圆形的碰撞: -

function checkCollision() {
     //checking of the Collision
     if (ry + rh > cy - radius && rx + rw > cx - radius && rx + rw < cx + radius ) {
          dy = -dy;
     }
}
Run Code Online (Sandbox Code Playgroud)

这也是我的代码的一部分: -

var rx = 50; //distance from the x-axis of the Rect. 
var ry = 50; //distance from the y-axis of the Rect.
var rw = 80; //width of the Rect
var rh = 30; //Height of the Rect. …
Run Code Online (Sandbox Code Playgroud)

javascript canvas collision-detection

9
推荐指数
2
解决办法
2万
查看次数

给定代码中的异常(java)

我有这个测试程序,我看到一个NullPointer异常.我需要帮助找出如何解决它,并想知道根本原因.

public class test {

    private static void practice(String[] words) {

        int vowelPosition = 0;
        int consonantPosition = 0;
        char[] vowel = (char[]) null;
        char[] consonant = (char[]) null;

        for (int i = 0; i < words.length; i++) {
            int currentWordLength = words[i].length();
            for (int j = 0; j < currentWordLength; j++) {
                if (words[i].charAt(j) == 'a' || words[i].charAt(j) == 'e'
                        || words[i].charAt(j) == 'i'
                        || words[i].charAt(j) == 'o'
                        || words[i].charAt(j) == 'u') {
                    consonant[j] = 'n';
                    vowel[j] = words[i].charAt(j); …
Run Code Online (Sandbox Code Playgroud)

java nullpointerexception

-2
推荐指数
1
解决办法
82
查看次数