objects query

BlitzMax Forums/BlitzMax Beginners Area/objects query

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

unless I made the instance global? Or the value global?
I have a global of the instances in my globals file.

I have a type tplayership.

I have instanced ship:tplayer
and targetship:tplayership

i have a function to draw the targetship, which i call in the main loop.

'--------------------
'draw a ship anywhere
'--------------------
Function DrawShip( image:timage, x,  y )
	SetRotation(0)
	SetColor 255,255,255	
	SetScale(1.0 *newscale, 1.0*newscale)
	SetAlpha(1.0)
	SetBlend(ALPHABLEND)
	MidHandleImage (image)

	Local targetship:tplayership = New tplayership
		
	'draws the ship if the shiplist is empty. Shiplist gets a ship when I press T
	If ListIsEmpty(ship.shiplist) = False
		DrawImage(image, x , y )
		DrawText("target shieldpower= "+targetship.shieldpower,100,100)
	End If
	
	'adds object to shiplist, other code is just part of my testing
	If KeyHit(KEY_T)
		ListAddLast(ship.shiplist, targetship)
		targetship.x = x
		targetship.y = y
		targetship.shieldpower = 200
	End If
End Function


now i have my collision in the imagescollide function set to targetship.x targetship.y

but it isn't working. The X and Y value of the instance targetship is staying = to X and Y of the "ship" instance. the ship instance here is my ship by the way at the center of the screen. so needless to say my weapons explode as i fire them.

I cant get the targetship.x or y to change to its own values.... shouldnt each instance, no matter if its created from the same type, have its own x and y value.

the x and y are in fields in tplayership.

in my loop i call drawship(imageIwant, 400,400) to create the ship at x and y 400. but i have a drawtext of targetship.X and Y on the screen and it doesn't read 400,400 it reads and creates the target ship at my X and Y in the center of the screen. even though it draws the graphic of the ship in the correct place, isn't that weird? My function draws it correctly to 400,400
yet the targetship.x, and Y aren't correct.

or is that only correct because drawimage(,image,x,y) in the function works, and thats why at least the image is being drawn correct.