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

0 Members and 1 Guest are viewing this topic.

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
StarBlast: Latest Version (2018.7.10)
« on: July 10, 2018, 03: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....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #1 on: July 10, 2018, 03: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
* StarBlast_2018-7-10.zip (Filesize: 2.47 MB, Downloads: 220)
I may not always finish what I've started....

FellippeHeitor

  • Guest
Re: StarBlast: Latest Version (2018.7.10)
« Reply #2 on: July 10, 2018, 04: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.
* StarBlast_2018-7-10_KEYDOWN_MOD.bas (Filesize: 104 KB, Downloads: 190)

FellippeHeitor

  • Guest
Re: StarBlast: Latest Version (2018.7.10)
« Reply #3 on: July 10, 2018, 04: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$.

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #4 on: July 11, 2018, 12: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....

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #5 on: July 11, 2018, 01:10:36 pm »
Hi SirCrow,

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

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #6 on: July 11, 2018, 01: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....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
StarBlast: MP3 audio doesn't work
« Reply #7 on: July 11, 2018, 02: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.
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: QB64: [Select]
  1. In file included from ../../src/minimp3.c:24:0:
  2. ../../src/libc.h:57:36: error: conflicting types for ‘uint64_t’
  3.          typedef unsigned long long uint64_t;
  4.                                     ^~~~~~~~
  5. In file included from /usr/include/stdint.h:37:0,
  6.                  from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
  7.                  from ../../src/libc.h:26,
  8.                  from ../../src/minimp3.c:24:
  9. /usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ was here
  10.  typedef __uint64_t uint64_t;
  11.                     ^~~~~~~~
  12. In file included from ../../src/minimp3.c:24:0:
  13. ../../src/libc.h:58:37: error: conflicting types for ‘int64_t’
  14.          typedef   signed long long  int64_t;
  15.                                      ^~~~~~~
  16. In file included from /usr/include/stdint.h:34:0,
  17.                  from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
  18.                  from ../../src/libc.h:26,
  19.                  from ../../src/minimp3.c:24:
  20. /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration of ‘int64_t’ was here
  21.  typedef __int64_t int64_t;
  22.                    ^~~~~~~
  23. ar: temp/minimp3.o: No such file or directory
  24. g++: error: parts/audio/decode/mp3_mini/os/lnx/src.a: No such file or directory
« Last Edit: October 06, 2019, 10:12:23 am by SirCrow »
I may not always finish what I've started....

FellippeHeitor

  • Guest
Re: StarBlast: Latest Version (2018.7.10)
« Reply #8 on: July 11, 2018, 04: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: QB64: [Select]
  1. typedef __uint64_t uint64_t;
  2. 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, 04:15:25 pm by FellippeHeitor »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #9 on: July 11, 2018, 04: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"

FellippeHeitor

  • Guest
Re: StarBlast: Latest Version (2018.7.10)
« Reply #10 on: July 11, 2018, 04:19:35 pm »
Could you do the change I mentioned and tell us if it works, Petr?

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #11 on: July 11, 2018, 04:27:54 pm »
I repair it as you write  AND IT WORKS!

FellippeHeitor

  • Guest
Re: StarBlast: Latest Version (2018.7.10)
« Reply #12 on: July 11, 2018, 04: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?

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #13 on: July 11, 2018, 07: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....

Offline SirCrow

  • Forum Regular
  • Posts: 144
    • View Profile
Re: StarBlast: Latest Version (2018.7.10)
« Reply #14 on: July 12, 2018, 12: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....