[noob] how to get the image x and y ?

BlitzMax Forums/BlitzMax Beginners Area/[noob] how to get the image x and y ?

H!

I know how to get the x and y with blitz 3D but how must I do this with blitzmax ?

strict
Local button:TImage = LoadImage("incbin::images/button.jpg")

While Not KeyHit(KEY_ESCAPE)
Cls
ResetCollisions

DrawImage button,200,34

drawtext button.X() and button.Y(),0,0

Flip
Wend

---
output 200,34

... how do you get the imagex/y in B3D? Do you mean the image's x/y handle? That case you can either use :
local x:float,y:float
gethandle(x,y)
print x + " " + y

to get the 'universal' handle or
print image.handle_x + " " + image.handle_y

to get a specific images handle. This is using the Image method rather than a function which I can't seem to find.

<EDIT> p.s. or if you really mean xpos,ypos use FlameDuck's suggestion.

TImages do not have coordinates. If you wish to do this, you should create your own type (for instance Button) and give that X:Int, Y:Int and button:TImage fields.

The advantage to this is that the same image can be at more than one position at a time.

@tonyg

must I like it like this ?

strict
Local button:TImage = LoadImage("incbin::images/button.jpg")

local x:float,y:float

gethandle(x,y)


While Not KeyHit(KEY_ESCAPE)
Cls
ResetCollisions

DrawImage button,200,34
print button.handle_x + " " + button.handle_y

drawtext button.X() and button.Y(),0,0

Flip
Wend


-------------

@ FlameDuck
I'm going to make some type's later.
But this was only my "starting with blitzmax" code

Like this?
Strict
Graphics 640,480
Local button:TImage = LoadImage("max.png")
While Not KeyHit(KEY_ESCAPE)
Cls
	DrawImage button,200,34
	DrawText button.handle_x + " " + button.handle_y,0,0
Flip
Wend


Your code had a few errors and, I hope, you understand that in this case button.handle_x/y will be returning 0.
The 'handle' is the drawpoint for the image (like a hotspot).For completeness sake :
strict
' you need a graphics command before loading images
graphics 640,80
' You need to incbin and image before loading it from incbin
incbin "images/button.jpg"
Local button:TImage = LoadImage("incbin::images/button.jpg")

local x:float,y:float
' This is getting the x/y offset applied to EVERY image loaded not just 'button'. Currently it is '0,0'
gethandle(x,y)


While Not KeyHit(KEY_ESCAPE)
Cls
' Only needed for collisions but never mind.
ResetCollisions

DrawImage button,200,34
print button.handle_x + " " + button.handle_y
' There's not no 'Button.x() function
'drawtext button.X() and button.Y(),0,0
drawtext button.handle_x + " " + button.handle_y

Flip
Wend


If you're new to Bmax I strongly recommend you follow Beginner's Guide to Bmax , Learning 2D Game Programming With BlitzMax
and Learning Object-Oriented Programming in Blitzmax . There are a few other use tutorials as well.