Author Topic: Click Me Game - My First InForm Game  (Read 706 times)

Offline SierraKen

  • Forum Resident
  • Posts: 956
Click Me Game - My First InForm Game
« on: November 12, 2019, 10:49:02 PM »
LOL I just made my very first InForm game. Try to click the button! Some of you might have seen this game before, I just decided to try to make it myself. It starts the score when you click the button.
On a side note, it is possible to keep clicking the button non-stop if you get it just right, it's not hard. lol Was just something I'm goofing around with.
 
(Note: To get the game scroll down to the post with the .zip file. Just this code below won't be enough I learned.)

Code: QB64: [Select]
  1. ': This program uses
  2. ': InForm - GUI library for QB64 - v1.0
  3. ': Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
  4. ': https://github.com/FellippeHeitor/InForm
  5. '-----------------------------------------------------------
  6.  
  7. ': Controls' IDs: ------------------------------------------------------------------
  8. DIM SHARED Label1 AS LONG
  9. DIM SHARED CLICKBT AS LONG
  10.  
  11. ': External modules: ---------------------------------------------------------------
  12. '$INCLUDE:'InForm\InForm.ui'
  13. '$INCLUDE:'InForm\xp.uitheme'
  14. '$INCLUDE:'ClickMeGame.frm'
  15.  
  16. ': Event procedures: ---------------------------------------------------------------
  17.  
  18.  
  19.  
  20.  
  21. SUB __UI_BeforeInit
  22.  
  23.  
  24. SUB __UI_OnLoad
  25.  
  26.  
  27.  
  28. SUB __UI_BeforeUpdateDisplay
  29.     'This event occurs at approximately 30 frames per second.
  30.     'You can change the update frequency by calling SetFrameRate DesiredRate%
  31.  
  32.  
  33. SUB __UI_BeforeUnload
  34.     'If you set __UI_UnloadSignal = False here you can
  35.     'cancel the user's request to close.
  36.  
  37.  
  38. SUB __UI_Click (id AS LONG)
  39.     SELECT CASE id
  40.         CASE Form1
  41.  
  42.         CASE Label1
  43.  
  44.         CASE CLICKBT
  45.  
  46.  
  47.     END SELECT
  48.  
  49. SUB __UI_MouseEnter (id AS LONG)
  50.     SELECT CASE id
  51.         CASE Form1
  52.  
  53.         CASE Label1
  54.  
  55.         CASE CLICKBT
  56.             RANDOMIZE TIMER
  57.             x = RND * 250
  58.             y = RND * 250
  59.             Control(CLICKBT).Top = y
  60.             Control(CLICKBT).Left = x
  61.  
  62.     END SELECT
  63.  
  64. SUB __UI_MouseLeave (id AS LONG)
  65.     SELECT CASE id
  66.         CASE Form1
  67.  
  68.         CASE Label1
  69.  
  70.         CASE CLICKBT
  71.  
  72.     END SELECT
  73.  
  74. SUB __UI_FocusIn (id AS LONG)
  75.     SELECT CASE id
  76.         CASE CLICKBT
  77.  
  78.  
  79.     END SELECT
  80.  
  81. SUB __UI_FocusOut (id AS LONG)
  82.     'This event occurs right before a control loses focus.
  83.     'To prevent a control from losing focus, set __UI_KeepFocus = True below.
  84.     SELECT CASE id
  85.         CASE CLICKBT
  86.  
  87.     END SELECT
  88.  
  89. SUB __UI_MouseDown (id AS LONG)
  90.     SELECT CASE id
  91.         CASE Form1
  92.  
  93.         CASE Label1
  94.  
  95.         CASE CLICKBT
  96.             s = s + 1
  97.             s$ = STR$(s)
  98.             sc$ = "Score: " + s$
  99.             Caption(Label1) = sc$
  100.     END SELECT
  101.  
  102. SUB __UI_MouseUp (id AS LONG)
  103.     SELECT CASE id
  104.         CASE Form1
  105.  
  106.         CASE Label1
  107.  
  108.         CASE CLICKBT
  109.  
  110.     END SELECT
  111.  
  112. SUB __UI_KeyPress (id AS LONG)
  113.     'When this event is fired, __UI_KeyHit will contain the code of the key hit.
  114.     'You can change it and even cancel it by making it = 0
  115.     SELECT CASE id
  116.         CASE CLICKBT
  117.  
  118.     END SELECT
  119.  
  120. SUB __UI_TextChanged (id AS LONG)
  121.     SELECT CASE id
  122.     END SELECT
  123.  
  124. SUB __UI_ValueChanged (id AS LONG)
  125.     SELECT CASE id
  126.     END SELECT
  127.  
  128. SUB __UI_FormResized
  129.  
  130.  
  131.  
« Last Edit: November 13, 2019, 05:15:45 PM by SierraKen »

Offline bplus

  • Forum Resident
  • Posts: 4613
  • B+ nots
Re: Click Me Game - My First InForm Game
« Reply #1 on: November 12, 2019, 11:41:12 PM »
Hi Ken,

Remember to post your form file too, .frm, best to put everything in zip so it's just extract and run through IDE compiler. You can't assume other people have InForm.

I am a little rusty but I think I have the package of files needed to go with InForm app.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2233
  • LET IT = BE
    • QB64.org
Re: Click Me Game - My First InForm Game
« Reply #2 on: November 13, 2019, 07:38:35 AM »
When you distribute your uncompiled InForm-based programs, the minimum you should add to your zip for distribution, besides your own data files (if any), is:

  • Your .bas file
  • Your .frm file
  • falcon.h
  • InForm/InForm.ui
  • InForm/xp.uitheme
  • InForm/InFormVersion.bas

That way you're including the InForm library files and anyone with QB64 on their system will be able to compile your program, even without having the full InForm package installed.

However, if you intend to distribute only your binary (not including the source code - probably not in this forum), you don't need to ship anything besides the binary itself. InForm-based programs are self-contained. In this case you'd only ship any files needed for your program to run, like icons, data files, images, etc.
« Last Edit: November 13, 2019, 07:45:10 AM by FellippeHeitor »

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2233
  • LET IT = BE
    • QB64.org
Re: Click Me Game - My First InForm Game
« Reply #3 on: November 13, 2019, 07:46:37 AM »
Here's an example of package: 

Offline SierraKen

  • Forum Resident
  • Posts: 956
Re: Click Me Game - My First InForm Game
« Reply #4 on: November 13, 2019, 12:56:00 PM »
Thanks both of you. I wasn't sure and eventually I was going to ask about it. I do have one question though, is it OK that I save my .bas and .frm files in a different directory than QB64? I've been doing that forever for .bas files. Can I still put all the files as you say in the one .zip file the way you showed me? I actually have my QB64 folder inside my QBasic folder and keep all my .bas files in just the Qbasic folder. Inform still works this way but I just want to make sure it's still good your way inside the .zip file before I post it here. Thanks.

Offline bplus

  • Forum Resident
  • Posts: 4613
  • B+ nots
Re: Click Me Game - My First InForm Game
« Reply #5 on: November 13, 2019, 03:55:26 PM »
I would definitely recommend putting each InForm project in separate folder. It makes it easy to make zip file of the folder to attach to your post.

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2233
  • LET IT = BE
    • QB64.org
Re: Click Me Game - My First InForm Game
« Reply #6 on: November 13, 2019, 04:13:54 PM »
Thanks both of you. I wasn't sure and eventually I was going to ask about it. I do have one question though, is it OK that I save my .bas and .frm files in a different directory than QB64? I've been doing that forever for .bas files. Can I still put all the files as you say in the one .zip file the way you showed me? I actually have my QB64 folder inside my QBasic folder and keep all my .bas files in just the Qbasic folder. Inform still works this way but I just want to make sure it's still good your way inside the .zip file before I post it here. Thanks.

No problem keeping your files elsewhere in your hard drive.

Offline SierraKen

  • Forum Resident
  • Posts: 956
Re: Click Me Game - My First InForm Game
« Reply #7 on: November 13, 2019, 05:14:38 PM »
Here is the game, for QB64 programmers. The .exe is not included. The game is not impossible although at first it will seem like that. Just keep clicking the mouse real fast and toward the button. Soon you will  be right on top of the button and can click forever if you want on the button until you just don't want to click anymore. :) It's a goofy game. lol But it's my first one using InForm. :)



« Last Edit: November 13, 2019, 05:16:54 PM by SierraKen »

Offline bplus

  • Forum Resident
  • Posts: 4613
  • B+ nots
Re: Click Me Game - My First InForm Game
« Reply #8 on: November 13, 2019, 11:14:43 PM »
LOL Oh man, a bit of a cruel streak in you! ;-))

Code: QB64: [Select]
  1. SUB __UI_MouseEnter (id AS LONG)
  2.     SELECT CASE id
  3.         CASE Form1
  4.  
  5.         CASE Label1
  6.  
  7.         CASE CLICKBT
  8.             RANDOMIZE TIMER
  9.             x = RND * 250
  10.             y = RND * 250
  11.             Control(CLICKBT).Top = y
  12.             Control(CLICKBT).Left = x
  13.  
  14.     END SELECT
  15.  
« Last Edit: November 13, 2019, 11:16:08 PM by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 956
Re: Click Me Game - My First InForm Game
« Reply #9 on: November 13, 2019, 11:34:59 PM »
LOL! The funny thing is, it wasn't even what I set out to make to begin with. I was just going to have the button move around. But I wanted to see what some of the SUBs did so I could get the right one and a better feel to them. So I just tried that first one and it came out like that. I was shocked because it's the same game a friend of mine made many years ago in Visual Basic LOL! So I kept it. :)))

Offline bplus

  • Forum Resident
  • Posts: 4613
  • B+ nots
Re: Click Me Game - My First InForm Game
« Reply #10 on: November 14, 2019, 12:16:09 AM »
It's really great you have ventured into the land of InForm!

Offline FellippeHeitor

  • QB64 Developer
  • Forum Resident
  • Posts: 2233
  • LET IT = BE
    • QB64.org
Re: Click Me Game - My First InForm Game
« Reply #11 on: November 14, 2019, 12:45:52 AM »
That was fun, SierraKen. Thanks for sharing!

Offline SierraKen

  • Forum Resident
  • Posts: 956
Re: Click Me Game - My First InForm Game
« Reply #12 on: November 14, 2019, 11:40:44 AM »
Thank you both! I will be learning more about it soon.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1415
Re: Click Me Game - My First InForm Game
« Reply #13 on: December 17, 2019, 07:02:11 PM »
Fine!
It is a good joke.
You let me remember IQ test made in QB45!
Also it has been ported to QB64, but in ASCII interface.
Can You  find it on this forum or on the other (.net)? I don't remember well and it doesn't matter!
Programming isn't difficult, only it's  consuming time and coffee