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 / [SOLVED] Some problem with dynamic arrays logic.

Author
Message
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 14th Jun 2019 09:41 Edited at: 14th Jun 2019 09:44
Hi
Could you read the Galanian_tester_collision_tirs_joueur_et_tirs_ennemis() function. What's happen after the remove(s). Is Galanian_tableau_tirs_ennemis.Length at the FOR line is updated and decrease by one after the remove ?
Correct function ?
(i've some array out of bound errors inside the project... Galanian_tableau_tirs_joueur[i].Sprite, Galanian_tableau_tirs_ennemis[j].Sprite)
Thanks





The author of this post has marked a post as an answer.

Go to answer

Riusz
8
Years of Service
User Offline
Joined: 27th Feb 2016
Location:
Posted: 14th Jun 2019 16:44
Hello,

I've try somthing like

and the fct is called on every step of my loop so the length seems to be updated too.

To avoid out of bound errors you could maybe step the array decrementally :

The index will always be in bound.

Riusz
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 14th Jun 2019 23:25 Edited at: 14th Jun 2019 23:25
This post has been marked by the post author as the answer.
When you remove an item you need to reduce the index by 1 otherwise you will skip over the next item and/or go out of bounds
So something like this
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 16th Jun 2019 19:36
many thanks.

Login to post a reply

Server time is: 2024-11-22 21:34:01
Your offset time is: 2024-11-22 21:34:01