Author Topic: QB64 Simon  (Read 4673 times)

0 Members and 1 Guest are viewing this topic.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
QB64 Simon
« on: February 29, 2020, 10:46:46 pm »
I was going through some of my old code and came across the Simon game I created back in 2015. I don't believe I ever posted it here. It's an exact replica of the Simon game from the 1980's (well, I added the QB64 bee graphic).

Game play can be done with keyboard, mouse, or both. Press F1 for a help screen.

The .ZIP file below contains the source code and asset files needed to compile and play the game.
simon.png
* simon.png (Filesize: 41.22 KB, Dimensions: 646x665, Views: 416)
* Simon.zip (Filesize: 236.77 KB, Downloads: 331)
« Last Edit: March 01, 2020, 03:52:02 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 Simon
« Reply #1 on: March 01, 2020, 03:19:06 pm »
As usual, beautiful code and documentation!

I had my usual issue with _SCREENMOVE (even in v1.4) but everything is fixed when I move screen to my middle of screen and click a button. It starts up at the bottom of my screen and when I drag title bar up part of the image is missing.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64 Simon
« Reply #2 on: March 01, 2020, 03:44:19 pm »
Yes, I'll fix the _SCREENMOVE _MIDDLE issue and reupload the .ZIP file with the change.

***

Ok, just uploaded the fixed .ZIP. I added a small _DELAY .25 after _SCREENMOVE _MIDDLE. This seems to take care of these types of issues.
« Last Edit: March 01, 2020, 03:53:01 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 Simon
« Reply #3 on: March 06, 2020, 11:16:24 am »
Yes, I'll fix the _SCREENMOVE _MIDDLE issue and reupload the .ZIP file with the change.

***

Ok, just uploaded the fixed .ZIP. I added a small _DELAY .25 after _SCREENMOVE _MIDDLE. This seems to take care of these types of issues.

Man this is frustrating! (see attached snap from updated zip, the image still continues below the bottom edge of my screen), Terry even changed the delay to .5!

This is exactly why I gave up on _MIDDLE some time ago. I would like to put this game up under Game Board and Terry has already accommodated one request.

The change is easy enough for anyone annoyed by _MIDDLE
Code: QB64: [Select]
  1. _SCREENMOVE 300, 40 '      move game screen to middle of desktop
  2. '_DELAY .5 '           slight delay to move to middle of screen >>  no longer needed
That's the beauty of having the source code.


Centering Simon.PNG
* Centering Simon.PNG (Filesize: 62.4 KB, Dimensions: 796x760, Views: 359)
« Last Edit: March 06, 2020, 11:50:44 am by bplus »

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: QB64 Simon
« Reply #4 on: March 06, 2020, 01:25:34 pm »
I have no idea why _MIDDLE causes such issues on some machines? The game is centering on my computer.
In order to understand recursion, one must first understand recursion.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 Simon
« Reply #5 on: March 06, 2020, 03:40:45 pm »
I have no idea why _MIDDLE causes such issues on some machines? The game is centering on my computer.

The problem with _MIDDLE is often from a race condition on some machines.

If you ever watch, QB64 *always* starts in a 640x400 screen (for SCREEN 0).  Usually, one of the first lines of code in a program is something similar to SCREEN _NEWIMAGE(800, 600, 32), with _SCREENMOVE _MIDDLE immediately after.

And ^there’s the glitch...

You’re in one screen.   You’re clearing that screen.  You’re creating a new screen.  It takes Windows a few fractions of a second to do this process and register the new screen handle...

And _SCREENMOVE _MIDDLE occurs at some point in this process.  If it occurs before the original screen is freed, your old window centers, disappears, and the new window pops up wherever windows wants to put it.  If it triggers after the new window is registered, it centers properly...   It all depends on that race condition and which window  it’s working with.

Bplus posted some code above like this:

SCREENMOVE MIDDLE
DELAY...

This is an example of non-effective code, in an attempt to address the issue at hand.  The glitch falls between SCREEN and SCREENMOVE, and with the race between which screen is registered when screenmove is called; not *after* the SCREENMOVE....

I would imagine if that delay was *BEFORE* the SCREENMOVE, the command would work properly as it’d give windows time to clear the old screen and create the new one and register it, before it tried to move the wrong (or non-existent) window. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 Simon
« Reply #6 on: March 06, 2020, 04:14:21 pm »
Code: QB64: [Select]
  1. _DELAY .1 '                                                        slight delay to move to middle of screen
  2. _SCREENMOVE _MIDDLE '                                              move game screen to middle of desktop

Confirmed! So the delay is needed to get SCREEN loaded before moving.

Even a delay of .1 works, on my system.
« Last Edit: March 06, 2020, 04:16:46 pm by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: QB64 Simon
« Reply #7 on: March 07, 2020, 10:37:57 pm »
Granted after becoming radioactive I only have a half-life!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: QB64 Simon
« Reply #8 on: September 11, 2020, 05:01:20 pm »
LOL I'm glad I searched for this game first before trying to make one myself. This is INCREDIBLE!!! Awesome job Terry!