QB64.org Forum

Active Forums => Programs => Topic started by: TerryRitchie on February 29, 2020, 10:46:46 pm

Title: QB64 Simon
Post by: TerryRitchie 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.
Title: Re: QB64 Simon
Post by: bplus 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.
Title: Re: QB64 Simon
Post by: TerryRitchie 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.
Title: Re: QB64 Simon
Post by: bplus 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.


Title: Re: QB64 Simon
Post by: TerryRitchie 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.
Title: Re: QB64 Simon
Post by: SMcNeill 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. 
Title: Re: QB64 Simon
Post by: bplus 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.
Title: Re: QB64 Simon
Post by: Cobalt on March 07, 2020, 10:37:57 pm
posted mine early last year,

https://www.qb64.org/forum/index.php?topic=984.msg101822#msg101822
Title: Re: QB64 Simon
Post by: SierraKen 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!