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] I don't understand how Sprite ID's work

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Oct 2021 09:42
As the tittle said

I load in sprites like this



I then am making arrows in game after everything is loaded like this



When a Arrow is created the arrow numbers are the same already generated numbers for my level. crazy

When I delete them my level also deletes lol. I thought the app does not make the same numbers as already generated numbers?

I'm checking the numbers and it is true, there the same.

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

Go to answer

Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Oct 2021 10:36
Well, I think my pc is being hacked by some one.

When I turn my internet off my program runs just as I tell it to.

but when I turn my internet on my sprite numbers are all the same as my preloaded numbers.

that is very odd.

Ill have to check ips.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Oct 2021 13:25
800,000 arrows, really?

AGK does recycle sprite ID's when the hard limit is reached, yes, but there is an internal check to see if a sprite with that ID already exists, its in the source (cHashList.h) and its failsafe, and I really doubt someone is hacking your PC and changing sprite ID.

As noted from your previous thread if sprite ID is being reused then its something you have done wrong.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 29th Oct 2021 13:30
In your FireArrow function, why is your for loop starting at 800000 and going to the s variable?
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Oct 2021 13:48
Quote: "800,000 arrows, really?"

i dont see 800,000 arrows since we don't know what s is. if s = 1,600,000,000, then yes.

and, i hope you're using DeleteAllSprites (which i would never use "between levels") because that's the only way you're going to delete the first 70 background_1 sprites since you're not recording those anywhere in the code provided and, therefor, have no sprite ID's to reference when deleting them manually, otherwise.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Oct 2021 14:33
Yeah fair point, what is the value of "s"?

if s=800010 then just (for i=0 to 10), I don't understand the context of the code.


Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Oct 2021 14:59
Just an FYI (pertaining to the title of this thread)

This file manages all the ID's generated by AppGameKit, sprites, objects, text, everything that gets an ID auto generated is piped through it, line 318 (GetFreeID) is called to get a new ID and it in turn calls (GetItem) to check if the ID is already in use, when a hard limit is reached (MAX_SPRITES in this case) it will wrap round and try to find the next available unused or freed ID, the pool of available ID's (MAX_SPRITES ) is the same as the 32bit signed integer limit (0x7fffffff or 2,147,483,647), the likelihood of a wraparound in any one game is highly unlikely and the possibility of AppGameKit reusing a currently occupied ID is impossible.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Oct 2021 15:00
Let's start with the first loop where you create the sprites. Clearly each background sprite is the same, just positioned different. It'd be more efficient to clone the sprite.



As for the fireArrow() function, I'm with everyone else as to why you would start your loop at 800,000 when the value of "i" isn't being explicitly used for anything. I would also suggest modifying the name of the function to better state what it actually does, because it's not firing anything but it does create the arrow. If you tell us the intended goal we can more than likely show you a better way to achieve what you're after.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
OriginalKronos
6
Years of Service
User Offline
Joined: 10th Nov 2017
Location:
Posted: 29th Oct 2021 18:09 Edited at: 29th Oct 2021 18:12
What about something like this. This way you dont have to track the array length.

Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Oct 2021 19:37 Edited at: 29th Oct 2021 19:39
I am not creating 80000 arrows, it creates one arrow with a system number because I'm creating it using this=createsprite(), the 80000 is irrelevant, that can be anything.

does no one see what I said?

the system is assigning the same id numbers, how can my sprite number be 80000 if the system is assigning them?

now maybe I can get some help here now there is understanding on the issue.

Quote: "an ID auto generated is piped through it"


Then why is mine not? why is my level sprites the same number as my arrow sprites? sounds like it is not filtering anything.

Quote: "possibility of AppGameKit reusing a currently occupied ID is impossible."


Then why is it happing to me?

I create a sprite with thissprite=createsprite()

it makes a sprite with a ID

I do the same thing making arrows, it does not pay attention to what sprite id I make unless my internet is off, sound odd?


Quote: "Let's start with the first loop where you create the sprites. Clearly each background sprite is the same, just positioned different. It'd be more efficient to clone the sprite."


Agreed, I like the idea.

Quote: "What about something like this. This way you don't have to track the array length."


That's what I'm about to do, thank you for answering, My code works good, unless I'm online, and I think that is strange in its self.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Oct 2021 19:50
Its Russian bots, you have been targeted by the KGB, they are hiding nuclear launch codes in your game sprite ID's, you need to hand your game over to the CIA immediately to prevent Armageddon!



Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 29th Oct 2021 20:10 Edited at: 29th Oct 2021 20:27
This post has been marked by the post author as the answer.
Quote: "the 80000 is irrelevant, that can be anything."


Then why are you starting your for loop at 800000? Why not start it at 0? Your for loop is creating a variable, called i, assigning it an initial value of 800000, and moving it toward s with each iteration of the loop. You're not actually using the i variable anywhere in the loop as Phaelax pointed out, so it looks like there is no point to setting it to 800000 in the first place. It has no relation to any of the sprites you're creating either, so we're wondering what is your reasoning for doing this.

Quote: "I create a sprite with thissprite=createsprite()

it makes a sprite with a ID"


Can you define what you mean by ID here? The thing to understand is that you are not giving the sprite a name or an ID of thissprite. thissprite is NOT a sprite ID, it's just an integer variable that gets assigned a value that matches the ID of the sprite created. Sprite IDs are always integer values and a sprite's ID cannot be changed after you create it. If you were to change the value of thissprite, either by assigning it a new value or using it in another CreateSprite statement (as you're doing with background_1 in your first code snippet), all that would change would be the value of thissprite, NOT the sprite ID that was created. You would no longer be able to control the sprite using thissprite, because its value would no longer match the ID of the sprite created.

Consider these two snippets as though they are the only lines of code you have in a new project (each snippet being in it's own empty project).





As AppGameKit begins automatically assigning sprite IDs at 100001, these two snippets do exactly the same thing. They both result in creating a sprite with an ID of 100001 and a variable, called mySprite, also with a value of 100001. Again, mySprite is not an ID in either of these snippets. It's just an integer variable and has no direct relation to the sprite created.
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Oct 2021 22:03 Edited at: 29th Oct 2021 22:05
Quote: "Its Russian bots, you have been targeted by the KGB, they are hiding nuclear launch codes in your game sprite ID's, you need to hand your game over to the CIA immediately to prevent Armageddon"


Im sorry but i laughed out loud to that one.

I was being hacked, I checked, but I also changed my code. I set my internet security to filter out any incoming connections to my pc.

Quote: "Then why are you starting your for loop at 800000? Why not start it at 0?"


experimenting to see if it would change the value and it doesn't.

hendron

I see what you mean and I changed my code and it works, I forgot to add .insert and I also changed the 80000



Thank you all for your help, this was a nightmare but it is working now.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 29th Oct 2021 22:06
Quote: "I was being hacked, I checked, but I also changed my code. I set my internet security to filter out any incoming connections to my pc."


The odds are astronomical that someone is hacking your computer and changing your sprite IDs, lol. You're almost certainly just doing something wrong or misunderstanding something. If you could provide some complete code samples that demonstrate issues you're having, it'll be much easier to help you.
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 29th Oct 2021 22:33 Edited at: 29th Oct 2021 22:36
Quote: "The odds are astronomical that someone is hacking your computer and changing your sprite IDs, lol."


Well that is not what was happing, I was being hacked, but my code was wrong.

But my program worked when the internet was off so I believe someone was changing something, the ips that where hacking me was from another country from the usa.

It also could be in the program its self, because the way it was written it should have never worked at all.

But the odds are not astronomical

it is easy to remotely connect to any one if they are allowing it in there security.

SO I do not see how it is astronomical

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Oct 2021 23:25
Hate to say "I told you so" ... but ...

Me wrote: "As noted from your previous thread if sprite ID is being reused then its something you have done wrong."


Could you please mark this thread as solved, the title will show in web searches and indicates that AppGameKit has a show stopping bug when in fact its user error..

Quote: "Im sorry but i laughed out loud to that one."


That was the general idea, comrade!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-03-28 12:48:29
Your offset time is: 2024-03-28 12:48:29