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] Is it me or is the array system mixed up?

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 30th Apr 2023 03:38
If I say this in a open loop



Only one enemy looses health, is not the reason for a array to hold information for many objects and there health and other things?
but I find in many, many times there are errors in the array. Here it is being made.



And here is when I load in my enemies



So I do not know why it will not see my other object in the array, It only addresses the one other loaded object.

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

Go to answer

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 30th Apr 2023 14:20 Edited at: 30th Apr 2023 14:25
How are you calculating the distance? And is there a particular reason you are running the for loop in reverse order? Why not just use for x = 0 to AllEnemys.length?

Also, this is unrelated to your question, but you really shouldn't be loading the same image multiple times. Load the image once and re-use it, or you will be wasting a ton of memory if you have a lot of enemies.



then in your enemy loading loop



or you could just cut the Image and ImageS properties and use the globals directly in SetObjectImage.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 30th Apr 2023 22:32
Hi, I know about the image loading, but this was just a test and never got around to change this, thanks for noticing it.

I will try to run it forward, this could be the problem, Ill let you know.



Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Apr 2023 22:48 Edited at: 30th Apr 2023 22:50
i never use DIM but are DIM'd arrays Global by default?

&, why DIM and not set a length?
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 30th Apr 2023 22:57
Quote: "are DIM'd arrays Global by default?"


Yes sir.

Quote: "why DIM and not set a length?"


It is a open array for now till I figure out what goes where and why, I might keep it this way as i am going to load in objects in game, but not enemies.

I always use a open array for testing issues, it is faster and easy as I do not know the amount yet.

I fill the array And it works.

But if I remember, it was you who showed me this way, So I always start out that way.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Apr 2023 23:06 Edited at: 30th Apr 2023 23:07
the method looks familiar but i never used DIM which i thought required a dimension based on the examples (hence why i never use it) while you provide none (i didnt think that would compile - apparently the parameter is optional).

anyway, i'll still never touch DIM. GL!
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 30th Apr 2023 23:28 Edited at: 30th Apr 2023 23:28
Perhaps This is why I am having problems,

No, setting a open dimension is ok and I do it all the time as long as you fill that dimension properly, At least that is what I learned.

Well if you never use DIM how would you put a group of enemies into a array you can use? I always want to code better then I know how.

And I also know I always learn form you.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th Apr 2023 23:54
This post has been marked by the post author as the answer.
Without using DIM, this is the way I create n objects.

Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st May 2023 00:34
nz0

Ok I see, so there is no dimensions in it at all, I will try this and see what happens.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st May 2023 00:51
That works and I guess setting the dim was causing problems.

Thank you guys.

Login to post a reply

Server time is: 2024-11-21 13:32:27
Your offset time is: 2024-11-21 13:32:27