|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
My problem with multiple collision detection (Java)
Hello,
i don't know how to explain my problem so i've called it: "my problem with multiple collision detection". The idea: you are a guy/girl and need kill all evil aliens. But the problem is how i know when that guy / girl shoots an alien. so with other words how do i know when there is a collision between a bullet and an alien.Let's say that there are 50 aliens and you have unlimited bullets. When you make a game like pong it's easy because you only have 3 objects. Do i need to write this like 70000000000 times? Code:
bullet[0].intersects(evilAlienNR1); I hope not Help me java-game-programmers you guys are my only hope William |
|
#2
|
||||
|
||||
|
This is why we use lists of all objects in games.
![]()
__________________
The day I get my hands on the cookbook it's all over. -nicky |
|
#3
|
|||
|
|||
|
Can I ask you how i'm supposed to do that
ArrayList? Code:
ArrayList alList1 = new ArrayList(); or some kind of ingenious class. Code:
class bullet{}
Code:
class alien{}
someone help me *puppy face* William ![]() |
|
#4
|
||||
|
||||
|
should I move this to Java forum?
__________________
Miscellaneous Software Viper_SB Developershed E-Support Anyone else play chess? Challenge me |
|
#5
|
|||
|
|||
|
sure no problem
|
|
#6
|
||||
|
||||
|
Ok. Your aliens. Do you have 50 different instances of alien or do you have them in an array or a list? If they're in a list (or array) then you can loop through them for each bullet using a nested loop.
Collections |
|
#7
|
|||
|
|||
|
k thanks going to tryout the collections idea
William |
|
#9
|
|||
|
|||
|
thanks man
William ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Game Development > My problem with multiple collision detection (Java) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|