Author Topic: Using EGSL for a Graphic/Text Adventure...  (Read 2982 times)

Luposian

  • Guest
Using EGSL for a Graphic/Text Adventure...
« on: June 02, 2013, 04:49:54 AM »
I'd actually like to incorporate the mouse and be able to click on areas of a given scene (each scene being a .png file) to then go in a given direction or to look at or do something.  But how to make those areas invisible, yet the system knows where you're pointing.  Can you specify an invisible "action area" that you can click in, to cause a given action?

Also, is there a way to incorporate all files (data) into a single binary, or must all data files be external to the main program?

I hope I'm not being too confusing in how I'm describing what I'm looking for.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Using EGSL for a Graphic/Text Adventure...
« Reply #1 on: June 02, 2013, 10:28:28 AM »
I'd actually like to incorporate the mouse and be able to click on areas of a given scene (each scene being a .png file) to then go in a given direction or to look at or do something.  But how to make those areas invisible, yet the system knows where you're pointing.  Can you specify an invisible "action area" that you can click in, to cause a given action?

Also, is there a way to incorporate all files (data) into a single binary, or must all data files be external to the main program?

I hope I'm not being too confusing in how I'm describing what I'm looking for.
You can try using mousezone(x1,y1,x2,y2) which gives the result true or false if the mousepointer is in that given rectangle.
All data files must be external to the main program there is now way to create a single binary.

Rick3137

  • Guest
Re: Using EGSL for a Graphic/Text Adventure...
« Reply #2 on: June 02, 2013, 05:52:51 PM »
   Hey Luposian:

 Check out my EGSL Samples area. (#10)
 I mapped out a game board for mouse clicks. You could easily rewrite my code to cover the whole screen.

Luposian

  • Guest
Re: Using EGSL for a Graphic/Text Adventure...
« Reply #3 on: June 04, 2013, 09:51:31 PM »
   Hey Luposian:

 Check out my EGSL Samples area. (#10)
 I mapped out a game board for mouse clicks. You could easily rewrite my code to cover the whole screen.

I'm not sure what you mean... I downloaded the EGSL Samples archive and not sure what filename you're referring to.  Or maybe you mean something different.

Rick3137

  • Guest
Re: Using EGSL for a Graphic/Text Adventure...
« Reply #4 on: June 04, 2013, 11:01:13 PM »
Code: [Select]
      -- By Rick3137  http://rb23.yolasite.com/

      function MakeSquare( row , column )

       local x = 200 local y = -40 local x2 = 0 local y2 = 0
       color (25,225,200)
       x = x + column * 70    y = y + row * 70  x2 = x + 67 y2 = y + 67
       fillbox (x,y,x2,y2)
       color (25,150,150)
       line (x,y,x2,y)  line (x2,y,x2,y2)  line (x2,y2,x,y2)  line (x+1,y2,x+1,y)
       line (x+3,y2,x+3,y)
        for a = 1 , 18 do
          x=x+2 y=y+2 x2 = x2-2 y2 = y2-2
          line (x,y,x2,y)  line (x2,y,x2,y2)  line (x2,y2,x+3,y2)  line (x+3,y2,x+3,y+3)
        end
      end

      function DisplaySquares()
         local a = 0
         for row = 1,10 do
           for column = 1,10 do
               a =  BoardArray [ row ][ column ]
               if a == 0 then MakeSquare ( row , column ) end
           end
         end
      end

      function MakeBoard()
                     color (0,0,0)
                     fillbox(250,20,980,740   )
                     color (0,100,100)
                     fillbox(260,25,975,735   )

      end



  -- Starts Program
     cnt = 0 x = 0 y = 0 key = 0 col = 0 rw = 0 x2 = 0 y2 = 0
    screen (1380,760,32," Board Array Demo ")

      backcolor (0,0,80)
      clearscreen()
         BoardArray  = {}          -- create the Array
    for row = 1,10 do
         BoardArray [ row ] = {}     -- create a new row
         for column = 1,10 do
            BoardArray [ row ][ column ] = 0
         end
    end
    -- you now have a 2d array with 100 elements, ready to use.
    for row = 1,10 do
         for column = 1,10 do
            BoardArray [ row ][ column ] = 0
         end
    end
      MakeBoard()
      DisplaySquares()



        while cnt < 10000
          do
             x = mousex() x2 = x - 270
             y = mousey() y2 = y - 30
             col = floor( x2/70 ) + 1
             rw = floor ( y2/70 ) + 1
              clearscreen()
             drawtext (200,100,x)
             drawtext (200,120,y)
             drawtext (200,140,col)
             drawtext (200,160,rw)
             drawtext (100,100,"x")
             drawtext (100,120,"y")
             drawtext (100,140,"column")
             drawtext (100,160,"row")
             drawtext (40,200,"Hold down Spacebar to end ")
             MakeBoard()
             DisplaySquares()
             redraw()
             wait (100)
             key = getkey()
             if key == 32 then break end
             cnt = cnt + 1
          end

    --  redraw()
      inkey()
      closewindow()     -- This ends the program.