Space Invaders

Game development specific discussions.
Post Reply
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Space Invaders

Post by ixiz9 »

I've uploaded a space invaders type game to github. Happy to discuss with anyone interested.
Please forgive any style or other errors. I'm new to Freebasic (and Github) though not new to programming.
https://github.com/ixiz9/freebasic-game ... e-invaders
Last edited by ixiz9 on Jan 04, 2023 18:23, edited 1 time in total.
paul doe
Moderator
Posts: 1745
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Space Invaders

Post by paul doe »

Code: Select all

Aborting due to runtime error 7 (null pointer access) at line 411 of C:\Programming\other-projects\freebasic-games-main\space_invaders\assets.bas::MAKEBASES()
To catch these kind of errors, compile the code with the -exx switch and run the executable from the command line (so you can see the output).
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Thanks for trying it out.
I'd love to understand why this is not working for you.
Obviously, this is working for me, and I always run from the command line. I tried with the -exx flag but everything worked.
I am running on a chromebook on the built-in Linux. I see you are running on Windows, so that might be the problem. I will try on Windows.
Based on the line number you posted it is most likely that this line is failing for you and returning 0.
gaming.bas line 142:
dim as fb.Image Ptr img = ImageCreate(wid*xfactor, height*yfactor, RGB(255,0,255), 32)
where the values should resolve as
dim as fb.Image Ptr img = ImageCreate(24, 24, RGB(255,0,255), 32)
This line is likely returning 0. I could check for that and avoid the crash, but all I could do at that point is abort the program. I have no idea why that call would fail.

It did work for me on Windows 11 on a small Dell notebook. One odd thing I noticed was the that screen was much too big. It appears that on Windows 11 FB respects the "Scale" setting so the window ends up too large. I'll see if I can do something about that.
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Hi.
I have uploaded a new version to github that will hopefully address this problem.
I have tested it under both ChromeOS and Windows.
Please take a look. Thank you.
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Sorry, due to some error on my part I had to move the repository to
https://github.com/ixiz9/freebasic-game ... e-invaders
paul doe
Moderator
Posts: 1745
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Space Invaders

Post by paul doe »

Code: Select all

Aborting due to runtime error 7 (null pointer access) at line 184 of C:\Programming\other-projects\freebasic-games2-main\space-invaders\gaming.bas::TEXT2SPRITE()
The line in question is:

Code: Select all

    w = sp.ci(c).image->width
paul doe
Moderator
Posts: 1745
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Space Invaders

Post by paul doe »

ixiz9 wrote: Jan 02, 2023 3:06

Code: Select all

   dim as fb.Image Ptr img = ImageCreate(wid*xfactor, height*yfactor, RGB(255,0,255), 32)[/tt]
where the values should resolve as

Code: Select all

  dim as fb.Image Ptr img = ImageCreate(24, 24, RGB(255,0,255), 32)[/tt]
This line is likely returning 0. I could check for that and avoid the crash, but all I could do at that point is abort the program. I have no idea why that call would fail.
The call could fail due to not setting the screen mode before calling imageCreate, or because you're passing invalid parameters to it. You can use assertions to check if the parameters are correct.
paul doe
Moderator
Posts: 1745
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Space Invaders

Post by paul doe »

Sure enough:

Code: Select all

C:\Programming\other-projects\freebasic-games2-main\space-invaders\gaming.bas(185): assertion failed at TEXT2SPRITE: sp.ci( c ).image <> 0
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Hi
Thanks for trying it again.
Is this with the latest version that I posted last night?
Did it ask you for a resolution at the start? Which one did you choose?
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Hi paul doe,
I tried this now using the latest Freebasic (1.09) on Windows compiled with both 32 and 64 bit compilers. I tried it on Intel integrated graphics, AMD integrated graphics and NVidia dedicated graphics and I cannont reproduce this error.
Can you provide a little more info on your set up?
I am also happy to send youanother version of the source with added debugging support to try to track down this error.
aurelVZAB
Posts: 667
Joined: Jul 02, 2008 14:55
Contact:

Re: Space Invaders

Post by aurelVZAB »

well
what i see is a broken link error 404 :?
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

I had to move the repository for a bit (there's a message about it a little below). Anyway I now moved it back so both links should work.
Makoto WATANABE
Posts: 232
Joined: Apr 10, 2010 11:41
Location: Japan
Contact:

Re: Space Invaders

Post by Makoto WATANABE »

Dear ixiz9;

Thanks to you, I was able to enjoy the nostalgic game on my Win10 PC.
It's winter in Japan right now, but my hands were sweating.
Unfortunately, the game is over before the invaderes icon change.
I want to improve my skills when I have time and enjoy changing scenes.
ixiz9
Posts: 14
Joined: Jan 01, 2023 4:50

Re: Space Invaders

Post by ixiz9 »

Hi Makoto

Thanks so much for you kind words.
Makoto WATANABE wrote: Jan 18, 2023 15:30 Unfortunately, the game is over before the invaderes icon change.
Can you explain a bit more. When do you expect the icon to change?
Post Reply