Syötteet : funktiot

MOUSEWY


   KUVAUS

Kertoo hiiren pystysijainnin pelimaailmassa, eli tämä funktio on objektiyhteensopiva.

Tulos on kokonaisluku.

   KÄYTTÖ
MOUSEWY ()

Katso myös: MOUSEY, MOUSEWX

   ESIMERKKI
FrameLimit 40
DrawToWorld ON

ShowMouse LoadImage("Media\cursor.bmp")

hero= LoadObject("Media\guy.bmp",18)

Repeat

    'move camera with arrows
    TranslateCamera KeyDown(205) -KeyDown(203),KeyDown(208) -KeyDown(200)

    'rotate the game character
    TurnObject hero, -40

    'Lue hiiri
    mx=MouseX()
    my=MouseY()
    

    Color cbwhite
    Text 10,10,"RuutuX:"+ mx
    Text 10,30,"RuutuY:"+ my

    worldx= MouseWX()
    worldy= MouseWY()

    Color cborange
    Text 10,50,"Mouse World X:"+ worldx
    Text 10,70,"Mouse World Y:"+ worldy
    
    'check if the coordinates overlap the object
    If worldx>ObjectX(hero) -16 And worldx<ObjectX(hero)+16
        If worldy<ObjectY(hero)+16 And worldy>ObjectY(hero) -16
            'draw a box around the object
            'Remember DRAWTOWORLD!
            Color 0,255,0
            Box ObjectX(hero) -16,ObjectY(hero)+16,32,32,OFF
        EndIf
    EndIf


    DrawScreen

Forever

<<TAKAISIN