Author Topic: Battleship 5  (Read 4038 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Battleship 5
« on: March 09, 2020, 08:00:26 am »
I spotted Battleship in the Games forum and figured I would play it. After all, it had been two years, since I played it last....

As this may not be a QB64 bug, per se and I cannot reply to the battleship posting in the "Games" forum, I figured that I would post it here. There are a couple of things that I need to raise.

1. The downloadable file seems to be only about 20+ bytes... Fortunately I already had a copy of the game stored on an old drive.
2. Ran the 2015-05-24 version (in both 1.3 1nd 1.4) and it popped up an error:
unhandled Error #258
Line: 115 (in main module)
Invalid handle

Bit strange as All files (program, images, sounds etc) are all in the one directory.

Any assistance would be appreciated.
Logic is the beginning of wisdom.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Battleship 5
« Reply #1 on: March 09, 2020, 11:12:10 am »
Hi!
I downloaded the game zip file. and It is 2.5MB in size. I run it & it works smoothly.
Can be your browser fault.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #2 on: March 09, 2020, 11:16:09 am »
Hi Ashish,

I just fixed it! I was double checking to make sure it worked with 2 downloads.

I thought I checked the Download at Games but now I think I checked the zip found at the link since the download at Games was clearly messed up.

@johnno56  thanks for your report, it should be OK now.
PS I got that error message too from something??? but it was working in new zip, I checked twice!
PPS I also checked the zip from the link in Games Battleship and that was OK too.
PPPS Double checked Battleship 5-AI.zip on reply #14
https://www.qb64.org/forum/index.php?topic=218.msg1195#msg1195

Still wondering where that error popped up from? Line #115 was referring to the Handle for "ship-black.png" the one that is supposed to have a transparent background for silhouette. Check that file if you encounter error again. Maybe there is a problem loading it.
« Last Edit: March 09, 2020, 04:28:47 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Battleship 5
« Reply #3 on: March 09, 2020, 02:49:04 pm »
Very impressive, esp. the fonts and flames.

Now where did the ice cream go?
It works better if you plug it in.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Battleship 5
« Reply #4 on: March 09, 2020, 05:27:03 pm »
bplus,

Firstly: Thank you for fixing the link. Downloaded just fine.
Secondly: The error re: line 115 still exists.

I figured it might have something to do with the image itself. Loaded all the images into Gimp. Converted all of them to 'png's. Modified the listing. (insert 'bad move' buzzer sound here) Well. That idea didn't work. I realize that the program was created prior to QB64 1.2 back in 2018. At that time the game ran fine. (Yes. I was using Linux) You guys report the game runs 'smoothly'. I am forced to conclude that 1) My now newer version of Linux Mint is probably missing this or that (highly technical term... lol) or 2) The 64bit Linux version of QB64 is also missing this or that. I am still confused as I have not come across an errors running any recent programs on this forum... I need coffee...

ps: I am going to look for an 'earlier' version of bship... just to test a theory...
« Last Edit: March 09, 2020, 05:28:43 pm by johnno56 »
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #5 on: March 09, 2020, 06:05:42 pm »
bplus,

Firstly: Thank you for fixing the link. Downloaded just fine.
Secondly: The error re: line 115 still exists.

I figured it might have something to do with the image itself. Loaded all the images into Gimp. Converted all of them to 'png's. Modified the listing. (insert 'bad move' buzzer sound here) Well. That idea didn't work. I realize that the program was created prior to QB64 1.2 back in 2018. At that time the game ran fine. (Yes. I was using Linux) You guys report the game runs 'smoothly'. I am forced to conclude that 1) My now newer version of Linux Mint is probably missing this or that (highly technical term... lol) or 2) The 64bit Linux version of QB64 is also missing this or that. I am still confused as I have not come across an errors running any recent programs on this forum... I need coffee...

ps: I am going to look for an 'earlier' version of bship... just to test a theory...

Dang! Ironic that you were the one who provided the assets.

OK, can you cut out that part of code and see if the rest of the files are working OK?
If it is just the first screen splash, we could work it another way, if it's just that one.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Battleship 5
« Reply #6 on: March 09, 2020, 07:05:19 pm »
I found the 2018-05-23 version. That version ran without error using QB64 1.3 but 1.4 kicked up "the error".

Graphics in this version are the same as the latest version. Curious. I will continue to test with and without special effects.

Gotta go. Taking our grand-daughter out for her swimming lessons...

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #7 on: March 09, 2020, 08:46:06 pm »
See next reply first

I found the 2018-05-23 version. That version ran without error using QB64 1.3 but 1.4 kicked up "the error".

Graphics in this version are the same as the latest version. Curious. I will continue to test with and without special effects.

Gotta go. Taking our grand-daughter out for her swimming lessons...

J

I am looking over the code and see that allot of images are being loaded before the image throwing the error is first at bat.

Here is an checkImageLoad& function that shuts down the program and tells you which image didn't load. And I show you how to test with image in question.
Code: QB64: [Select]
  1.  
  2. 'shipblack& = _LOADIMAGE("ship-black.png")  '<<< comment out file in question
  3. shipblack& = checkImageLoad&("ship-black.png", shipblack&) 'and run it through load checker
  4.  
  5. 'this function shuts down a program if an image file isn't loaded
  6. FUNCTION checkImageLoad& (file$, hdl&)
  7.     IF _FILEEXISTS(file$) THEN
  8.         hdl& = _LOADIMAGE(file$)
  9.         IF hdl& = -1 THEN CLS: PRINT file$ + " can't be loaded.": SLEEP: END ELSE checkImageLoad& = hdl&
  10.     ELSE
  11.         CLS: PRINT file$ + " does nor exist.": SLEEP: END
  12.     END IF
  13.  
This code worked in Battleship 5-AI and successfully handled the file in question at line #115.

If the image in question doesn't load go up the chain and see if any of them do.
Maybe the loads are taking longer because of all the images and  we need to stick in a _delay or 2 in between loads.
« Last Edit: March 09, 2020, 09:43:40 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #8 on: March 09, 2020, 09:42:32 pm »
@johnno56

BTW before doing another experiment with loading files makes sure you have:

"Output Exe to Source Folder"

bullet-ed under the Run Menu of the IDE in your new QB64 v1.4

You have to do this with every new version. Nothing will load from where you expect until you do this.
« Last Edit: March 09, 2020, 09:45:20 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Battleship 5
« Reply #9 on: March 09, 2020, 11:52:49 pm »
Well... this is egg on face... 'Output Exe to Source Folder" (on v 1.4) was indeed 'not' checked...

Oh. By the way... The game now runs on v 1.4...!

My guess would be that there just 'might' be a causal relationship between both events...

I ran the game several times (with and without effects) and, as usual, lost each and every time...

Many thanks for all your efforts... Now... Let's look at a 'cheat' function..... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #10 on: March 10, 2020, 12:39:20 am »
Yeaaaaaa !!!

The game you helped me so much with, now works for you. Thank goodness

If you are serious about a cheat, maybe a brief look at sonar?
Oh we could make the computer take random pot shots instead of systematically hunting you down and annihilating you. :)
 
I've been thinking about allowing one or more ship(s) to move in 1 of 4 directions they are headed.
Oh I just had a thought, that would be Takes a Thief in 2D, hmm.... :)
« Last Edit: March 10, 2020, 12:43:42 am by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Battleship 5
« Reply #11 on: March 10, 2020, 04:06:09 am »
Nah. Kidding about the cheat.. Actually, I'm getting quite used to being killed off... Just like a 'Red Shirt'... lol
Logic is the beginning of wisdom.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Battleship 5
« Reply #12 on: March 10, 2020, 05:31:06 am »
@bplus If anything needed to be amended in the Games post, I assume that you have done it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Battleship 5
« Reply #13 on: March 10, 2020, 11:15:55 am »
@Qwerkey

Yeah Games post fixed, the attached zip didn't have the assets (at least), it wouldn't even unzip as I now recall because it was saying it was empty. Did you check it after your post? Oh, I also redid images so 2 were inserted for display. I thought 3 would be a bit much.

I now remember how I got my error at line #115, I had the bas file loaded in QB64 but NOT saved so EXE would be where the assets files were. That should have given me a clue to Johnno's potential problem sooner than it did.
« Last Edit: March 10, 2020, 11:20:04 am by bplus »