Guidance
指路人
g.yi.org
software / rapidq / Examples / Game / monster / cool.rq

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $ESCAPECHARS ON
     $RESOURCE comic AS "comic.bmp"
     $RESOURCE creature AS "pic1.bmp"
     $RESOURCE creature2 AS "pic2.bmp"
     $RESOURCE creature3 AS "pic3.bmp"
     $RESOURCE creature6 AS "pic6.bmp"
     $RESOURCE creature7 AS "pic7.bmp"
     $RESOURCE creature8 AS "pic8.bmp"
     $RESOURCE creature9 AS "pic9.bmp"
     $RESOURCE creature10 AS "pic10.bmp"
     $RESOURCE creature11 AS "pic11.bmp"
     $RESOURCE creature12 AS "pic12.bmp"
     $RESOURCE face1 AS "face1.bmp"
     $RESOURCE face2 AS "face2.bmp"
     $RESOURCE face3 AS "face3.bmp"
     $RESOURCE face4 AS "face4.bmp"
     $RESOURCE face5 AS "face5.bmp"
     $RESOURCE face6 AS "face6.bmp"

     DECLARE SUB SetWindowPos LIB "User32" ALIAS "SetWindowPos" (hWnd AS LONG, hWndInsertAfter AS LONG, X AS LONG, Y AS LONG, cx AS LONG, cy AS LONG, wFlags AS LONG)
     DECLARE SUB top
     DECLARE SUB resetform
     DECLARE SUB monstermouseup(btn,x,y)
     DECLARE SUB monstermousedown(btn,x,y)
     DECLARE SUB monstermousemove(x,y,btn)
     DECLARE SUB monsterkeydown(k)
     DECLARE SUB endprog
     DECLARE SUB blink
     DECLARE SUB stomp
     DECLARE SUB walkleft
     DECLARE SUB walkright
     DECLARE SUB ears
     DECLARE SUB talk
     DECLARE SUB eyes
     DECLARE SUB action
     DIM mousedown AS INTEGER
     DIM mx AS INTEGER
     DIM my AS INTEGER
     DIM newx AS INTEGER
     DIM newy AS INTEGER
     DIM newaction AS INTEGER
     DIM frame AS INTEGER
     DIM textpause AS INTEGER
     DIM comictext(50) AS STRING
     textpause = 4
     comictext(1) = "If at first you don't succeed, deny you ever tried!"
     comictext(2) = "Don't worry about avoiding temptation, as you get older it starts avoiding you!"
     comictext(3) = "The only difference between me and a madman is that I am not mad"
     comictext(4) = "I don't work out.  My philosophy is no pain, no pain."
     comictext(5) = "Ever wonder if illiterate people ever get the full effect of alphabet soup?"
     comictext(6) = "A clean tie attracts the soup of the day"
     comictext(7) = "A friend is someone who has the same enemies as you."
     comictext(8) = "After all is said and done, more is said than done."
     comictext(9) = "never play leap frog with a unicorn."
     comictext(10) =  "humpty dumpty was pushed."
     comictext(11) = "I ran out of sick days so I am calling in dead"
     comictext(12) = "I'd rather be over the hill than under it"
     comictext(13) = "All generalizations are false"
     comictext(14) = "The best way to change someone's mind is with a rock."
     comictext(15) = "Bad spellers of the world enight!"
     comictext(16) = "If you must burn our flag, please wrap yourself in it first"
     comictext(17) = "If money could talk, it would say goodbye."
     comictext(18) = "I like cats...\nThey taste like chicken."
     comictext(19) = "Normal people worry me"
     comictext(20) = "I don't suffer from insanity, I enjoy every minute of it"
     comictext(21) = "Huked on foniks werkd fer me"
     comictext(22) = "Don't steal, the government hates competition"
     comictext(23) = "A day without sunshine is like night"
     comictext(24) = "A friend in need is a pest indeed"
     comictext(25) = "As I said before, I never repeat myself"

     RANDOMIZE TIMER

     DIM timtop AS QTIMER
     timtop.enabled = 1
     timtop.interval = 100
     timtop.onTimer = top
     DIM timstomp AS QTIMER
     timstomp.enabled = 0
     timstomp.interval = 250
     timstomp.onTimer = stomp
     DIM timaction AS QTIMER
     timaction.enabled = 1
     timaction.interval = 1000
     timaction.onTimer = action
     DIM timblink AS QTIMER
     timblink.enabled = 0
     timblink.interval = 200
     timblink.onTimer = blink
     DIM timwalkleft AS QTIMER
     timwalkleft.enabled = 0
     timwalkleft.interval = 200
     timwalkleft.onTimer = walkleft
     DIM timwalkright AS QTIMER
     timwalkright.enabled = 0
     timwalkright.interval = 200
     timwalkright.onTimer = walkright
     DIM timears AS QTIMER
     timears.enabled = 0
     timears.interval = 200
     timears.onTimer = ears
     DIM timtalk AS QTIMER
     timtalk.enabled = 0
     timtalk.interval = 200
     timtalk.onTimer = talk
     DIM timeyes AS QTIMER
     timeyes.enabled = 0
     timeyes.interval = 200
     timeyes.ontimer = eyes

     CREATE frmmonster AS QFORM
      top = 50
      left = 20
      DelBorderIcons 0, 1, 2, 3
      borderstyle = 0
      CAPTION = "Creature"
      width = 100
      height = 75
      COLOR = RGB(0,64,64)
      ShapeForm creature, RGB(255,255,255)
      OnKeyDown = monsterkeydown
      CREATE imgmonster AS QIMAGE
       top = 0
       left = 0
       width = 100
       height = 75
       bmphandle = creature
       Transparent = 1
       Stretch = 1
       onMouseDown = monstermousedown
       onMouseMove = monstermousemove
       onMouseUp = monstermouseup
       onDblClick = endprog
      END CREATE
      CREATE imgface AS QIMAGE
       top = 15
       left = 30
       width = 40
       height = 25
       bmphandle = face1
       visible = 0
      END CREATE
     END CREATE

     DIM comicfont AS QFONT
     comicfont.COLOR = 0
     comicfont.name = "Comic Sans MS"

     CREATE frmcomic AS QFORM
      width = 150
      height = 100
      COLOR = 0
      DelBorderIcons 0, 1, 2, 3
      BorderStyle = 0
      ShapeForm comic, RGB(255,255,255)
      CREATE imgcomic AS QIMAGE
       top = 0
       left = 0
       transparent = 1
       width = 150
       height = 150
       bmphandle = comic
      END CREATE
      CREATE lblcomic AS QRICHEDIT
       borderstyle = 0
       COLOR = RGB(253,255,170)
        'transparent = 1
       font = comicfont
       top = 5
       left = 5
       width = 140
       height = 55
       wordwrap = 1
        'autosize = 1
      END CREATE
     END CREATE

     SUB monstermousemove(x,y,btn)
      IF mousedown <> 1 THEN EXIT SUB
      newx = frmmonster.left - mx + x
      newy = frmmonster.top - my + y
      frmmonster.left = newx
      frmmonster.top = newy
      frmcomic.top = frmmonster.top - 30
      frmcomic.left = frmmonster.left + 100

     END SUB

     SUB monstermousedown(btn,x,y)
      IF btn = 1 THEN EXIT SUB
      mousedown = 1
      mx = x
      my = y
     END SUB

     SUB monstermouseup(btn,x,y)
      mousedown = 0
     END SUB

     SUB monsterkeydown(k)
      IF k = 27 THEN endprog
     END SUB

     SUB action
      IF mousedown = 1 THEN EXIT SUB
      newaction = INT(RND*20) +1
      IF newaction < 13 AND newaction > 0 THEN timaction.enabled = 0
      IF newaction = 1 THEN timstomp.enabled = 1
      IF newaction > 1 AND newaction < 7 THEN timblink.enabled = 1
      IF newaction = 7 THEN timwalkleft.enabled = 1
      IF newaction = 8 THEN timwalkright.enabled = 1
      IF newaction = 9 OR newaction = 10 THEN timears.enabled = 1
      IF newaction = 11 THEN
       frmcomic.top = frmmonster.top -30
       frmcomic.left = frmmonster.left + 100
       frmcomic.visible = 1
       joke = INT(RND * 25) + 1
       lblcomic.text = comictext(joke)
       frmcomic.visible = 1
       timtalk.enabled = 1
      END IF
      IF newaction = 12 THEN timeyes.enabled = 1
     END SUB

     SUB stomp
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      IF frame > 20 THEN
       timstomp.enabled = 0
       resetform
       EXIT SUB
      END IF
      IF frame MOD 2 = 1 THEN
       imgmonster.bmphandle = creature2
       frmmonster.shapeform creature2, RGB(255,255,255)
      END IF
      IF frame MOD 2 = 0 THEN
       imgmonster.bmphandle = creature3
       frmmonster.shapeform creature3, RGB(255,255,255)
      END IF
     END SUB

     SUB blink
      imgface.visible = 1
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      IF frame = 1 OR frame = 3 THEN imgface.bmphandle = face3 '
      IF frame = 2 THEN imgface.bmphandle = face4
      IF frame > 3 THEN
       timblink.enabled = 0
       imgface.bmphandle = face1
       imgface.visible = 0
       timaction.enabled = 1
       frame = 0
      END IF
     END SUB

     SUB walkleft
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      keepgoing = INT(RND * 20) + 1
      IF frmmonster.left < 20 OR keepgoing = 1 THEN
       timwalkleft.enabled = 0
       resetform
       EXIT SUB
      END IF
      newx = frmmonster.left
      newx = newx - 10
      frmmonster.left = newx
      IF frame MOD 4 = 2 OR frame MOD 4 = 0 THEN
       imgmonster.bmphandle = creature10
       frmmonster.shapeform creature10, RGB(255,255,255)
      END IF
      IF frame MOD 4 = 1 THEN
       imgmonster.bmphandle = creature9
       frmmonster.shapeform creature9, RGB(255,255,255)
      END IF
      IF frame MOD 4 = 3 THEN
       imgmonster.bmphandle = creature11
       frmmonster.shapeform creature11, RGB(255,255,255)
      END IF
     END SUB

     SUB walkright
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      keepgoing = INT(RND * 20) + 1
      IF frmmonster.left > screen.width - 270 OR keepgoing = 1 THEN
       timwalkright.enabled = 0
       resetform
       EXIT SUB
      END IF
      newx = frmmonster.left
      newx = newx + 10
      frmmonster.left = newx
      IF frame MOD 4 = 2 OR frame MOD 4 = 0 THEN
       imgmonster.bmphandle = creature8
       frmmonster.shapeform creature8, RGB(255,255,255)
      END IF
      IF frame MOD 4 = 1 THEN
       imgmonster.bmphandle = creature7
       frmmonster.shapeform creature7, RGB(255,255,255)
      END IF
      IF frame MOD 4 = 3 THEN
       imgmonster.bmphandle = creature6
       frmmonster.shapeform creature6, RGB(255,255,255)
      END IF
     END SUB

     SUB ears
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      IF frame > 10 THEN
       timears.enabled = 0
       resetform
       EXIT SUB
      END IF
      IF frame MOD 2 = 1 THEN
       imgmonster.bmphandle = creature12
       frmmonster.shapeform creature12, RGB(255,255,255)
      ELSE
       imgmonster.bmphandle = creature
       frmmonster.shapeform creature, RGB(255,255,255)
      END IF
     END SUB

     SUB talk
      imgface.visible = 1
      IF mousedown = 1 THEN EXIT SUB
      frame = frame + 1
      IF frame / 5 > 7 THEN
       timtalk.enabled = 0
       frmcomic.visible = 0
       imgface.bmphandle = face1
       imgface.visible = 0
       frame = 0
       timaction.enabled = 1
       EXIT SUB
      END IF
      IF frame MOD 2 = 0 THEN
       imgface.bmphandle = face2
      ELSE
       imgface.bmphandle = face1
      END IF
     END SUB

     SUB eyes
      imgface.visible = 1
      IF mousedown = 1 THEN EXIT SUB
      IF frame > 20 THEN
       timeyes.enabled = 0
       imgface.visible = 0
       imgface.bmphandle = face1
       timaction.enabled = 1
      END IF
      frame = frame + 1
      IF frame MOD 4 = 1 OR frame MOD 4 = 3 THEN
       imgface.bmphandle = face3
      ELSEIF frame MOD 4 = 2 THEN
       imgface.bmphandle = face5
      ELSE
       imgface.bmphandle = face6
      END IF


     END SUB

     SUB resetform
      imgmonster.bmphandle = creature
      imgface.visible = 0
      imgface.bmphandle = face1
      frmmonster.Shapeform creature, RGB(255,255,255)
      timaction.enabled = 1
      frame = 0
     END SUB

     SUB endprog
      END
     END SUB

     SUB top
      SetWindowPos(frmmonster.Handle, -1, 0, 0, 0, 0, &H1 OR &H2)
      IF newaction = 11 THEN
       SetWindowPos(frmcomic.Handle, -1, 0, 0, 0, 0, &H1 OR &H2)
      END IF
     END SUB

     frmmonster.SHOWMODAL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-03-10 21:59:14