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

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

GC-Martijn(Posted 2007) [#1]
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


tonyg(Posted 2007) [#2]
... 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.


FlameDuck(Posted 2007) [#3]
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.


GC-Martijn(Posted 2007) [#4]
@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


tonyg(Posted 2007) [#5]
Like this?

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 :


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.