Posted: 29th Oct 2021 9:42
As the tittle said

I load in sprites like this

+ Code Snippet
for m =0 to 70
rem load in backgrounds	
background_1=CreateSprite(BackGround)
SetSpritePosition(background_1,x,0)
SetSpriteSize(background_1,100,100)
SetSpriteUVBorder(background_1,2)
SetSpriteDepth(background_1,100)
SetSpriteColor(background_1,200,200,200,255)
inc x,100
next m


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

+ Code Snippet
function FireArrow ( s as integer ,X,Y)
	
	local i as integer
	
	for i=800000 to s
	    Arrow.length             = Arrow.length + 1
	    Arrow[Arrow.length].x     = 50
	    Arrow[Arrow.length].y     = 50
	    
	   Arrow[Arrow.length].ID    = CreateSprite ( ArrowImage )
	    SetSpriteAnimation(Arrow[Arrow.length].ID,475,77,16)
	    SetSpriteFrame(Arrow[Arrow.length].ID,1 )
	    Arrow[Arrow.length].angle = random ( 0, 359 )
	    Arrow[Arrow.length].speed = random ( 1, 9 ) / 10.0
	    //Arrow[Arrow.length].Delete=1
	    SetSpriteSize 				( Arrow[Arrow.length].ID, 20,5 )
	    SetSpriteGroup( Arrow[Arrow.length].ID, -10 )


	   SetSpritePositionByOffset 	( Arrow[Arrow.length].ID, X,Y )   

   
	    setspritephysicson(Arrow[Arrow.length].ID,2)
	    SetSpritePhysicsMass(Arrow[Arrow.length].ID,0.0001)

	next i
	
endfunction


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.
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.
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.
Posted: 29th Oct 2021 13:30
In your FireArrow function, why is your for loop starting at 800000 and going to the s variable?
Posted: 29th Oct 2021 13:48
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.
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.
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.
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.

+ Code Snippet
background_1 = CreateSprite(BackGround)
SetSpritePosition(background_1, 0, 0)
SetSpriteSize(background_1, 100, 100)
SetSpriteUVBorder(background_1, 2)
SetSpriteDepth(background_1, 100)
SetSpriteColor(background_1, 200, 200, 200, 255)


x = 100
for m = 1 to 70
	clone = cloneSprite(background_1)
	SetSpritePosition(clone, x, 0)
	inc x, 100
next m


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.
Posted: 29th Oct 2021 18:09
What about something like this. This way you dont have to track the array length.

+ Code Snippet
Type TArrow
	ID as integer
	X as float
	Y as float
	Angle as float
	Speed as float

endType	


ArrayOfArrows as TArrow[]

for i = 1 to 500
	ArrayOfArrows.Insert(SetUp_Arrow(50+i,50))
next



function SetUp_Arrow(px as float, py as float)
	
	arrow as TArrow
	arrow.ID = CreateSprite(0)
	arrow.Angle=random(0,359)
	arrow.Speed = random(1,9)/10.0
	a = arrow.ID
	SetSpriteAnimation(a,475,77,16)
	//SetSpriteFrame(a,1)
	SetSpriteSize(a,20,5)
	SetSpritePositionByOffset(a,px,py)
	SetSpritePhysicsOn(a,2)
	SetSpritePhysicsMass(a,0.0001)
	
endFunction arrow
Posted: 29th Oct 2021 19:37
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.

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.

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?


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.

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.
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!
Posted: 29th Oct 2021 20:10
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.

t 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).
+ Code Snippet
myImage = LoadImage("image.png")

mySprite = 100001
CreateSprite(mySprite, myImage)


+ Code Snippet
myImage = LoadImage("image.png")

mySprite = CreateSprite(myImage)



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.
Posted: 29th Oct 2021 22:03
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.

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

+ Code Snippet
 function SetUp_Arrow(px as float, py as float)
     
    arrow as TArrow
    
    arrow.ID = CreateSprite(ArrowImage)
    arrow.Angle=random(0,359)
    arrow.Speed = random(1,9)/10.0
    ThisArrow = arrow.ID
    SetSpriteAnimation(arrow.ID,475,77,16)
    SetSpriteFrame(arrow.ID,1)
    SetSpriteSize(arrow.ID,20,5)
    SetSpritePositionByOffset(arrow.ID,px,py)
    SetSpritePhysicsOn(arrow.ID,2)
    SetSpritePhysicsMass(arrow.ID,0.0001)
    
   ArrayOfArrows.Insert(arrow)
endFunction arrow


Thank you all for your help, this was a nightmare but it is working now.
Posted: 29th Oct 2021 22:06
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.
Posted: 29th Oct 2021 22:33
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
Posted: 29th Oct 2021 23:25
Hate to say "I told you so" ... but ...

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..

Im sorry but i laughed out loud to that one.


That was the general idea, comrade!