Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / GetBullet Collision Problem

Author
Message
Behdadsoft
14
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Apr 2015 16:27
Hi.

I create a Spaceship that can shoot to enemies and wrote a code for get collide between bullet and enemies. but Problem is when enemy[x] = destroy that bullet[1] collide with enemy[1] and .... .

Another problem is, I delete bullet[x] after collide with enemies and this make decrease bullet.

Please Guide Me.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Apr 2015 20:20
You need to loop through every bullet for every enemy, currently you are testing for a collision between enemy X and bullet X but not any other bullet or enemy.

I don't understand your second problem. Can I recommend google translate?

Using AppGameKit V2 Tier 1
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 9th Apr 2015 22:18
Hi

As baxslash says you are not checking each bullet and each ememy.

As for your second problem, if I understand you, when you delete your bullet sprite you have never decreased your BulletNumber variable.
ie BulletNumber=BulletNumber-1

Scotty
Behdadsoft
14
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Apr 2015 13:09
I use this loop for check every bullet with all enemies, but this code only work with enemy[10].

Please guide Me to fix it.

Thanks.

IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 10th Apr 2015 14:29
This works.

Behdadsoft
14
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Apr 2015 14:56
Thanks IronManhood for fix my mistake.

Login to post a reply

Server time is: 2024-03-28 19:47:57
Your offset time is: 2024-03-28 19:47:57