Collision detection in java 2d game

Przemek

I'm trying to detect in memory, when user invade mouse on some object, like tree. But checking each pixel is too low, and another problem is that my tree.png have size 64x64, but real tree is smaller, and i was trying to get array of pixels, who's real image. My game is in isometric projection. And is there any good way, to detect when user invade mouse on object?

AlexWien

You can assign each object a coordinate. Then you calculate the distance between mouse and object. If the distance is less than the mouse radius, then the objects overlap or touch.

Second possibility: You assign each object a bounding box (rectangle around center of object). Then you check wheter the rectangles intersect. (see Rectangle2D)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Java: Pacman collision detection with wall

From Dev

Java Circle to Circle collision detection

From Dev

Collision detection not working in Unity 2D

From Dev

Collision detection in javascript canvas tanks game

From Dev

Collision detection in 2D game without tiles XNA

From Dev

Unity 2d collision detection not registering

From Dev

Trouble with java 2D collision detection

From Dev

2D Collision detection not working

From Dev

Solving 2d game collision (polygons)

From Dev

Java Game Physics - Determine intersection and collision detection

From Dev

3D java collision detection with Jbullet

From Dev

Unity 2D Collision Detection

From Dev

Java collision detection with 3d obj models

From Dev

Processing color collision detection (java)

From Dev

HTML Canvas game: 2D collision detection

From Dev

Trying to use quadtrees for collision detection in a game

From Dev

Collision Detection with Java, Slick2D and Tiled Map Editor

From Dev

Javascript Canvas Game - Collision Detection

From Dev

Game score via collision detection increment

From Dev

Java Circle to Circle collision detection

From Dev

Collision detection in 2D game without tiles XNA

From Dev

Collision Detection on 2 objects

From Dev

Java Collision detection in 3D with Vertex Coordinates

From Dev

Trying to use quadtrees for collision detection in a game

From Dev

Collision Detection in Java 2D Not Working Properly

From Dev

Java Slick2d rectangle collision detection strange behavior

From Dev

Collision detection in javascript game

From Dev

Collision Detection for fast moving game object in Unity

From Dev

Problem with collision detection is JS canvas game

Related Related

HotTag

Archive