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.

AppGameKit Classic Chat / Problem with multiple enemies in array

Author
Message
x3meblue
15
Years of Service
User Offline
Joined: 11th Dec 2008
Location: Nuremberg, Germany
Posted: 4th May 2015 20:24
Hello!

I try to re-create an arcade game like galaga,
where in the top enemy spaceships attack the player
in a formation. I put the enemies in an array and if
the player shoots i check the collision in a for loop.
The problem is that always one enemy gets deleted, also
if he is not hit by a bullet and i don't understand why.

What is the correct way to cycle through an array and delete
sprites, without getting the IDs get f..... up?

AGK2 Tier 1 / GameGuru / DB PRo / ProMotion 6.5
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 4th May 2015 23:11
show me the source code

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 4th May 2015 23:19
use 'Types', then you can delete sprites without messing up the array id's (I assume that's what you meant)

x3meblue
15
Years of Service
User Offline
Joined: 11th Dec 2008
Location: Nuremberg, Germany
Posted: 4th May 2015 23:32 Edited at: 4th May 2015 23:34
Ok, here is the source code (a bit long)
I use types already..

The problem is probably in EnemyHit() and/or UpdateEnemies() functions.




AGK2 Tier 1 / GameGuru / DB PRO / ProMotion 6.5
x3meblue
15
Years of Service
User Offline
Joined: 11th Dec 2008
Location: Nuremberg, Germany
Posted: 4th May 2015 23:40
Here is the complete game with graphics & code, i think it's more easy to read in an editor with syntax highlighting.

AGK2 Tier 1 / GameGuru / DB PRO / ProMotion 6.5

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th May 2015 03:54
i touch a row and the problem disappear and me wonder why.
hmm, i see a mix of windows and linux line breaks in the main.agc file.
maybe the compiler was confused.
please open it with notepad and edit all line breaks and try again.
if the problem pesist please upload as zip again.

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
x3meblue
15
Years of Service
User Offline
Joined: 11th Dec 2008
Location: Nuremberg, Germany
Posted: 5th May 2015 04:42 Edited at: 5th May 2015 04:42
I opened in Notepad++ but i don't see any line break issues. Also, i use the official AGK2 Ide. I changed the file encoding but it doesn't help...

The problem is that in the moment when the game is starting and you are flying a bit to the left and shoot, the enemy spaceship in the first colum/ middle row gets deleted without being hit by a bullet. This didn't happened when you played it?

AGK2 Tier 1 / GameGuru / DB PRO / ProMotion 6.5
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th May 2015 09:37 Edited at: 5th May 2015 09:39
Quote: "The problem is that in the moment when the game is starting and you are flying a bit to the left and shoot, the enemy spaceship in the first colum/ middle row gets deleted without being hit by a bullet. This didn't happened when you played it?"


yes i saw too.
if me have time i will debug it more.

AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th May 2015 21:04
try this one below.
i change the linux linebreaks to windows.
one mistake was to create a bullet sprite but not set the position.
means create bullet sprite was at position 0,0 until the set set position was called in your render functions.
the collision system used the real sprite position.



AGK 108 (B)19 + AppGameKit V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
x3meblue
15
Years of Service
User Offline
Joined: 11th Dec 2008
Location: Nuremberg, Germany
Posted: 5th May 2015 22:05
Yes! It's working! Thank you so much!
This was the problem, that i didn't set the sprite position immediately after sprite creation. Now everything is working fine..puuuh

AGK2 Tier 1 / GameGuru / DB PRO / ProMotion 6.5

Login to post a reply

Server time is: 2024-11-25 21:34:44
Your offset time is: 2024-11-25 21:34:44