Author Topic: StarBlast: Latest Version (2018.7.10)  (Read 99 times)

StarBlast: Latest Version (2018.7.10)
« on: July 10, 2018, 04:08:10 PM »
If you liked my game before, I think you'll like the newest version even more.  If you're like me, you will love to see the floating objects (asteroids or fancy, animated circles, your choice) split into THREE smaller ones.  It was nice when they broke up into 2 new objects, but there's just something extra pleasing about three.  Anyway, that's just a sample of what's new in the latest version of StarBlast:

http://qb64.thejoyfulprogrammer.com/showthread.php?tid=1349&pid=7233&rndtime=15312491871534469706#pid7233
I may not always finish what I've started....

Re: StarBlast: Latest Version (2018.7.10)
« Reply #1 on: July 10, 2018, 04:41:19 PM »
Fellippe, I forgot to mention that I've used _KEYDOWN in the latest version of my game.  It works better than when I first tried it, but there are still some problems. For one thing, if you're turning the ship with the arrows and then you want to fire w/ the SPACEBAR or other key, you can't until you stop turning.  Or, if you're firing and then you press an arrow, it stops firing.  The whole idea, mainly, was so we can do both simultaneously and w/o conflict.  Please see if you can tell me what's wrong with it.  Thanks.

J
I may not always finish what I've started....

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: StarBlast: Latest Version (2018.7.10)
« Reply #2 on: July 10, 2018, 05:25:56 PM »
Because KEYDOWN can be used to check the state of all keys simultaneously (with the obvious limitations of how many keys can be registered simultaneously by your computer) your program must execute ALL scenarios in which that key can act. Your current approach is using GOTO when a key is detected as pressed, which bypasses all other KEYDOWN checks.

What I mean is: user is pressing LEFT key. You check for that and voilà, it's pressed. Then you GOTO where the left key is processed. But then the check for SPACEBAR is never reached in that loop.

What I did in the attachment was a hacky way to detect it all by using GOSUB instead of GOTO. this way each block of code for each key is executed when you're checking them with KEYDOWN, because I set a flag for that.

It may sound confusing, but looking at the code will probably make it clearer. Compile the attachment and run it, to see how you can now move, rotate and shoot all at once.

My changes begin at line 905.

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: StarBlast: Latest Version (2018.7.10)
« Reply #3 on: July 10, 2018, 05:30:09 PM »
Also: You're still checking for INKEY$ and responding to it. I highly recommend that you decide on a method for input and stick to it. Reading the keyboard as you are now is prone to give you more headaches later on. Either go with the _KEYDOWN/_KEYHIT duo *or* INKEY$.

Re: StarBlast: Latest Version (2018.7.10)
« Reply #4 on: July 11, 2018, 01:26:23 PM »
Also: You're still checking for INKEY$ and responding to it. I highly recommend that you decide on a method for input and stick to it. Reading the keyboard as you are now is prone to give you more headaches later on. Either go with the _KEYDOWN/_KEYHIT duo *or* INKEY$.

I will certainly do my best to get it all worked out.  I knew I'd have to do more checks for more scenarios, at least.  Thanks again!
I may not always finish what I've started....

Re: StarBlast: Latest Version (2018.7.10)
« Reply #5 on: July 11, 2018, 02:10:36 PM »
Hi SirCrow,

Very nice game. I played it several times in a row. Thanks for sharing.
Coding is relax (At least sometimes)

Re: StarBlast: Latest Version (2018.7.10)
« Reply #6 on: July 11, 2018, 02:16:17 PM »
Hi SirCrow,

Very nice game. I played it several times in a row. Thanks for sharing.

Thanks!  I know what you mean;  while working on it and testing it, I often end up just playing the game.  I don't want to call it a waste of time, though!
I may not always finish what I've started....

StarBlast: MP3 audio doesn't work
« Reply #7 on: July 11, 2018, 03:20:41 PM »
Oh, by the way, it really would be nice to be able again to play .mp3 or other audio files within my program.  But Linux/Ubuntu has other ideas.  So, I'm stuck with just the SOUND sounds, and I miss the silly little pop sound I used for asteroids exploding.  My own creation, that was!
If anyone can figure out how to make Ubuntu let QB64 play mp3's, I wish you'd let me know.  I've already downloaded the Windows version of QB64 to try with the Wine thing.  Should I just do that?  Is it known to work that way?  Haven't tried it yet.  Thanks!

Code: [Select]
In file included from ../../src/minimp3.c:24:0:
../../src/libc.h:57:36: error: conflicting types for ‘uint64_t’
         typedef unsigned long long uint64_t;
                                    ^~~~~~~~
In file included from /usr/include/stdint.h:37:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
                 from ../../src/libc.h:26,
                 from ../../src/minimp3.c:24:
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ was here
 typedef __uint64_t uint64_t;
                    ^~~~~~~~
In file included from ../../src/minimp3.c:24:0:
../../src/libc.h:58:37: error: conflicting types for ‘int64_t’
         typedef   signed long long  int64_t;
                                     ^~~~~~~
In file included from /usr/include/stdint.h:34:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
                 from ../../src/libc.h:26,
                 from ../../src/minimp3.c:24:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration of ‘int64_t’ was here
 typedef __int64_t int64_t;
                   ^~~~~~~
ar: temp/minimp3.o: No such file or directory
g++: error: parts/audio/decode/mp3_mini/os/lnx/src.a: No such file or directory
I may not always finish what I've started....

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: StarBlast: Latest Version (2018.7.10)
« Reply #8 on: July 11, 2018, 05:14:24 PM »
I'm replying in the dark here as I neither have problems with MP3 audio on my Ubuntu virtual machine nor have I tried the change I'm proposing, but maybe if you edit the file internal/c/parts/audio/decode/mp3_mini/src/libc.h and make lines 57 and 58 read:

Code: [Select]
typedef __uint64_t uint64_t;
typedef __int64_t int64_t;

MAYBE that'll work.

Again, not tried or confirmed. Just a guess. It could wreak havoc too.
« Last Edit: July 11, 2018, 05:15:25 PM by FellippeHeitor »

Re: StarBlast: Latest Version (2018.7.10)
« Reply #9 on: July 11, 2018, 05:18:51 PM »
I tryed (without rewriting as write Fellippe) _SNDPLAYFILE ("sound.mp3") with this error message in Linux Mint:

Quote
In file included from ../../src/minimp3.c:24:0:
../../src/libc.h:57:36: error: conflicting types for ‘uint64_t’
         typedef unsigned long long uint64_t;
                                    ^~~~~~~~
In file included from /usr/include/stdint.h:37:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
                 from ../../src/libc.h:26,
                 from ../../src/minimp3.c:24:
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ was here
 typedef __uint64_t uint64_t;
                    ^~~~~~~~
In file included from ../../src/minimp3.c:24:0:
../../src/libc.h:58:37: error: conflicting types for ‘int64_t’
         typedef   signed long long  int64_t;
                                     ^~~~~~~
In file included from /usr/include/stdint.h:34:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
                 from ../../src/libc.h:26,
                 from ../../src/minimp3.c:24:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration of ‘int64_t’ was here
 typedef __int64_t int64_t;
                   ^~~~~~~
ar: temp/minimp3.o: Adresář nebo soubor neexistuje
g++: error: parts/audio/decode/mp3_mini/os/lnx/src.a: Adresář nebo soubor neexistuje            <- this here is "folder or file not exists"
Coding is relax (At least sometimes)

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: StarBlast: Latest Version (2018.7.10)
« Reply #10 on: July 11, 2018, 05:19:35 PM »
Could you do the change I mentioned and tell us if it works, Petr?

Re: StarBlast: Latest Version (2018.7.10)
« Reply #11 on: July 11, 2018, 05:27:54 PM »
I repair it as you write  AND IT WORKS!
Coding is relax (At least sometimes)

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: StarBlast: Latest Version (2018.7.10)
« Reply #12 on: July 11, 2018, 05:32:47 PM »
Good to hear! Hope it works for SirCrow as well.

I wonder if other Linux distributions are also having issues with MP3 audio... Does anybody else have something to report?

Re: StarBlast: Latest Version (2018.7.10)
« Reply #13 on: July 11, 2018, 08:47:05 PM »
Good to hear! Hope it works for SirCrow as well.

I wonder if other Linux distributions are also having issues with MP3 audio... Does anybody else have something to report?

I will most definitely try it.  Thank you, F and P!
And, by all means, anyone else do report any similar issues in Linux.  Oh, and also, has my game crashed on anyone's Linux system?  For me, sometimes it almost compiles and runs, and other times it runs for a while and then just quits.  But mostly it's OK.  Thanks!

J
I may not always finish what I've started....

Re: StarBlast: Latest Version (2018.7.10)
« Reply #14 on: July 12, 2018, 01:05:45 AM »
Good news!  Editing the file worked and now I have my sounds back in my game.  I once tried to fix the problem with that file, or one like it, but it got me nowhere.  I don't know how you knew what to do, Fellippe, but I'm glad you did.  Thanks.

Now that I can justify working on more new sounds, I hope to get busy with that soon.  I wonder about one thing:  If the asteroids in my game are exploding in rapid succession, can I have the sounds (from the same file) overlapping?  I just doesn't work when it doesn't overlap.  I haven't experimented very much with that.
I may not always finish what I've started....