Strict Graphics 800,600,0,60 Global gui:tgui = New tgui 'SetColor 255,255,255 'mainloop Repeat gui.update() gui.draw() Flip;Cls Until KeyHit(key_escape) 'draws the mouse + a rectangle Type tgui Field x=0,y=0 Field mouse:tmouse = tmouse.create() Method draw() DrawRect x,y,300,200 'mouse.draw() EndMethod Method update() 'mouse.update() EndMethod EndType Type tmouse Extends tgui Field x,y Method draw() DrawOval x,y,10,10 EndMethod Method update() x = MouseX() y = MouseY() EndMethod Function create:tmouse() Local mouse:tmouse = New tmouse Return mouse:tmouse EndFunction EndType
It's probably something very basic I haven't learned. But it's bugging me quite a bit. Can someone help?
I really want to have the mouse type inside the gui type so I can do gui.mouse.update() and whatnot. I also wish to have mouse extend gui, such that I can "see" the mouse from other tgui extends, for collisions and whatnot. For instance, tgui:twindow which is extended from gui, would want to see if mouse's lmb is pressed (gui.mouse.lmb) by doing 'if mouse.lmb', naturally refering to gui.mouse.lmb, but since the window is also a child of gui, it could see it.. Does that make any sense?
Maybe I'm supposed to have the mouse stuff built into the tgui type for my purposes, or as a global?