Author Topic: Star Wars Galaxian  (Read 1842 times)

Guva

  • Full Member
  • ***
  • Posts: 243
  • 🌈 ZX-Spectrum !!!
Re: Star Wars Galaxian
« Reply #45 on: August 09, 2026, 01:49:01 pm »
The latest version just has a mistake
Code: Pascal  [Select][+][-]
  1.   InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, 'SWGalaxian');
  2.   SetConfigFlags(FLAG_VSYNC_HINT);

As SetConfigFlags sets init configuration, it has no effect after InitWindow. It has to either go before InitWindow (as it was previously), or be replaced with SetWindowState to toggle the flag after the window is created.

That's right. SetWindowState(FLAG_VSYNC_HINT) after initializing the window; 
Maybe it will work for @flowCRANE.

It is not clear why SetConfigFlags(FLAG_VSYNC_HINT) does not work;   

Perhaps the idea doesn't work because the -WG flag is forcibly enabled, which indicates that this is a graphical application and something happens when hiding.

I also changed the optimization level, there was something wrong with Intel graphics, but it seemed to be fixed.
compiled it with the master branch to exclude regression.

@flowCRANE Please test it binary from ginthub

Guva

  • Full Member
  • ***
  • Posts: 243
  • 🌈 ZX-Spectrum !!!
Re: Star Wars Galaxian
« Reply #46 on: August 09, 2026, 02:43:48 pm »
@guva

OS:  Debian bookworm LTS
CPU: AMD
GFX: igpu
FPS: ~8000 - ~45000
CPU: 98% (1 thread)
FPC: 3.2.2
RAYLIB: version 6.0 tag release
GalaxianWar: version commit 38eed53

Have same cpu effect user flowCrane

and have small warnings and when exit have AV:
Code: [Select]
./GalaxianWar
INFO: Initializing raylib 6.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  800 x 600
INFO:     > Render size:  800 x 600
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 233
INFO: GL: OpenGL device information:
INFO:     > Vendor:   AMD
INFO:     > Renderer: AMD Radeon Graphics (renoir, LLVM 15.0.6, DRM 3.49, 6.1.0-51-amd64)
INFO:     > Version:  4.6 (Core Profile) Mesa 22.3.6
INFO:     > GLSL:     4.60
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW - X11): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: SYSTEM: Working Directory: /media/ramdisk/work/bin
WARNING: WINDOW: SetConfigFlags called after window initialization, Use "SetWindowState" to set flags instead
INFO: FILEIO: [data/art.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (128x128 | R8G8B8A8 | 1 mipmaps)
INFO: AUDIO: Device initialized successfully
INFO:     > Backend:       miniaudio | PulseAudio
INFO:     > Format:        32-bit IEEE Floating Point -> 16-bit Signed Integer
INFO:     > Channels:      2 -> 2
INFO:     > Sample rate:   48000 -> 48000
INFO:     > Periods size:  3600
INFO: TEXTURE: [ID 3] Texture loaded successfully (256x1024 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/bomb.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/zap.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/expl1.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/blip.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/damage.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/xwingshot1.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/xwingshot2.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/tieshot2.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/tiefly0.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/tiefly1.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/r2d2-1.wav] File loaded successfully
INFO: WAVE: Data loaded successfully (22050 Hz, 16 bit, 1 channels)
INFO: FILEIO: [data/swlogo.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (256x128 | R8G8B8 | 1 mipmaps)
INFO: TEXTURE: [ID 4] Texture loaded successfully (256x128 | R8G8B8 | 1 mipmaps)
INFO: FILEIO: [data/xwing.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 5] Texture loaded successfully (64x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/exhaust1.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 6] Texture loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/shot1.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (4x8 | R8G8B8 | 1 mipmaps)
INFO: TEXTURE: [ID 7] Texture loaded successfully (4x8 | R8G8B8 | 1 mipmaps)
INFO: FILEIO: [data/lives.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 8] Texture loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/rpm.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 9] Texture loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/multishot.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 10] Texture loaded successfully (32x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/bomb1.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (8x8 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 11] Texture loaded successfully (8x8 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/enter.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8 | 1 mipmaps)
INFO: TEXTURE: [ID 12] Texture loaded successfully (32x32 | R8G8B8 | 1 mipmaps)
INFO: FILEIO: [data/esc.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (32x32 | R8G8B8 | 1 mipmaps)
INFO: TEXTURE: [ID 13] Texture loaded successfully (32x32 | R8G8B8 | 1 mipmaps)
INFO: FILEIO: [data/tief_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 14] Texture loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/tiei_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 15] Texture loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/tieb_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 16] Texture loaded successfully (576x32 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/spark_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (512x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 17] Texture loaded successfully (512x64 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/bomexpl_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (16384x256 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 18] Texture loaded successfully (16384x256 | R8G8B8A8 | 1 mipmaps)
INFO: FILEIO: [data/expl_strip.png] File loaded successfully
INFO: IMAGE: Data loaded successfully (2304x64 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 19] Texture loaded successfully (2304x64 | R8G8B8A8 | 1 mipmaps)
INFO: STREAM: Initialized successfully (48000 Hz, 16 bit, Stereo)
INFO: FILEIO: [data/crazy.mod] Music file loaded successfully
INFO:     > Sample rate:   48000 Hz
INFO:     > Sample size:   16 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  10645423
INFO: STREAM: Initialized successfully (48000 Hz, 32 bit, Stereo)
INFO: FILEIO: [data/intro.compat.xm] Music file loaded successfully
INFO:     > Sample rate:   48000 Hz
INFO:     > Sample size:   32 bits
INFO:     > Channels:      2 (Stereo)
INFO:     > Total frames:  9013440
INFO: FILEIO: [data/SFDistantGalaxy.ttf] File loaded successfully
WARNING: FONT: [0x0024] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x0028] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x0029] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x002f] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x004a] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x005b] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x005c] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x005d] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x006a] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x007b] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x007c] Glyph height is bigger than requested font size: 49 > 48
WARNING: FONT: [0x007d] Glyph height is bigger than requested font size: 49 > 48
INFO: TEXTURE: [ID 20] Texture loaded successfully (1024x512 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (48 pixel size | 95 glyphs)
INFO: FILEIO: [data/SFDistantGalaxy.ttf] File loaded successfully
WARNING: FONT: [0x0024] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x0028] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x0029] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x002f] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x004a] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x005b] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x005c] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x005d] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x006a] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x007b] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x007c] Glyph height is bigger than requested font size: 25 > 24
WARNING: FONT: [0x007d] Glyph height is bigger than requested font size: 25 > 24
INFO: TEXTURE: [ID 21] Texture loaded successfully (512x256 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Data loaded successfully (24 pixel size | 95 glyphs)
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully
WARNING: GLFW: Error: 65537 Description: The GLFW library is not initialized
An unhandled exception occurred at $00007EFEBE5C487D:
EAccessViolation: Access violation
  $00007EFEBE5C487D

fpc build option:
Code: [Select]
-B
 -Mobjfpc
 -Sh
 -dRAY_DYNAMIC
 -FE"$HERE/bin"
 -Fl"$HERE/lib"
 -Fu"$HERE/src/*"
 -FU"$HERE/units"
 "$HERE/src/galaxian/GalaxianWar.lpr"

fwiw: link error I report my other message when build raylib 6 when use you header that my error (I make mistake)

Have thank for raylib header and game. Is fun retro game.

1. I've been getting this error if I use a VM
2. OS:  Debian bookworm LTS. not compatible with glibc execute build/ build.sh

flowCRANE

  • Hero Member
  • *****
  • Posts: 1009
Re: Star Wars Galaxian
« Reply #47 on: August 09, 2026, 03:01:22 pm »
@flowCRANE Please test it binary from ginthub

Tested—none of them works efficiently. All executables uses ~17-18% of the CPU time (bad) and ~5% of the GPU time (good). And as you can see in the screenshots, some executables uses ~60MB of RAM and some ~80MB.
« Last Edit: August 09, 2026, 03:03:43 pm by flowCRANE »
Lazarus 4.8 with FPC 3.2.2, Windows 11 — all 64-bit

Working solo on a top-down retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

Guva

  • Full Member
  • ***
  • Posts: 243
  • 🌈 ZX-Spectrum !!!
Re: Star Wars Galaxian
« Reply #48 on: August 09, 2026, 03:04:02 pm »
@flowCRANE Please test it binary from ginthub

Tested—none of them works efficiently. All executables uses ~17-18% of the CPU time (bad) and a few % of the GPU time (good). And as you can see in the screenshots, some executables uses ~60MB of RAM and some ~80MB.

Thanks for the test. Well, for now, let's just set the fps to 60. This is the only option that works.

Thausand

  • Hero Member
  • *****
  • Posts: 613
Re: Star Wars Galaxian
« Reply #49 on: August 09, 2026, 04:47:51 pm »
1. I've been getting this error if I use a VM
This not VM this is run linux direct (terminal).

Quote
2. OS:  Debian bookworm LTS. not compatible with glibc execute build/ build.sh
Yes, that why build raylib manual and dynamic.

AV is happen direct behind (or inside) loop  while not WindowShouldClose() do. Code is never reach code behind wend. Output is write window is success close (INFO: Window closed successfully). I make try except for main loop and add debug. FPC no able for write more detail (have trace for not free memory. This is expect when happen exception) :(

note: all ray4laz directory example core is work ok and have no warning and no av (it make time for test all example).

PS: intel test is ~14% cpu thread for game and have ~700 fps.
« Last Edit: August 10, 2026, 12:23:42 am by Thausand »
A docile goblin always follow HERMES.md

PierceNg

  • Sr. Member
  • ****
  • Posts: 444
    • SamadhiWeb
Re: Star Wars Galaxian
« Reply #50 on: August 10, 2026, 09:10:45 am »
On my AMD Ryzen 7 8845HS desktop running Ubuntu 24.04, both raylib and game built from source, CPU pushed hard even with FPS set to 60.

On another AMD Ryzen 7 6800U computer running Win 11 Home:

- On WSL2 running Ubuntu 22.04, both raylib and game built from source, same high CPU usage.

- From WSL2, cross-compiled both raylib and game to Windows. According to Windows task manager, this version used max 1% CPU and 70MB RAM.

This Windows computer is a GPD Win Max 2 with built-in gaming controls, which work fine with the game.

Two observations:

- The ship's left and right movement feels slow. Is it possible to speed up in application code? The last time I played such a game was Alien Typhoon on Apple ][ decades ago. If I'm not misremembering, that game's ship movement was much faster.

- On Linux, the default raylib backend is GLFW. An SDL backend is also available. I might try rebuilding raylib with SDL backend on Linux to see if the CPU problem is due to GLFW.

PierceNg

  • Sr. Member
  • ****
  • Posts: 444
    • SamadhiWeb
Re: Star Wars Galaxian
« Reply #51 on: August 10, 2026, 10:10:44 am »
I rebuilt raylib with SDL on my Linux. No observable difference for the game in terms of CPU usage, according to top, alas.

PierceNg

  • Sr. Member
  • ****
  • Posts: 444
    • SamadhiWeb
Re: Star Wars Galaxian
« Reply #52 on: August 11, 2026, 10:37:08 am »
Seems raylib has had issues with high CPU usage:

- https://github.com/raysan5/raylib/issues/415
- https://github.com/raysan5/raylib/issues/1640

And several others.

Digging in a little, I rebuilt raylib with this change:

- edit src/config.h, changed line 95

Code: [Select]
#define SUPPORT_PARTIALBUSY_WAIT_LOOP   0
With the change, on my Linux box SWGalaxian now runs at ~3% CPU utilization.

 

TinyPortal © 2005-2018