Author Topic: Star Wars Galaxian  (Read 1844 times)

Guva

  • Full Member
  • ***
  • Posts: 243
  • 🌈 ZX-Spectrum !!!
Star Wars Galaxian
« on: August 07, 2026, 11:12:00 pm »
Star Wars: Galaxian

Port Description:
Originally developed by Alexandr "Shirson" Nevskiy using the exEngine, this project is a port to FPC and raylib. V-Sync now works flawlessly.

Gameplay:
The gameplay is heavily inspired by the classic Galaxian and features a Star Wars theme.


Controls:
- Left/Right Arrow Keys – Move the ship (X-Wing).
- Spacebar – Fire.


Key Features:
The game features three distinct enemy types, each with unique characteristics:

  • TIE Fighter – The standard mass-produced fighter. Fires dual lasers. Destroying one awards 1,000 points.
  • TIE Interceptor – Fires a spread of four lasers, covering a much wider area than the TIE Fighter. Awards 2,000 points.
  • TIE Bomber – Drops slow-moving bombs that explode to cover a massive area. Awards 3,000 points (and trust me, they are worth every point :)).
Enemies spawn off-screen and assemble into formations that sweep back and forth across the screen. The number of stages is theoretically infinite, featuring 5 main formation types.

  • Enemies do not attack while assembling into formation (take advantage of this, or things will get tough later!).
  • The fewer enemies remain, the more frequently they attack.
  • Occasionally, enemies break off to form temporary strike groups and attack together.
  • If the player is shot down, the game monitors the battlefield and waits for a safe moment to respawn. Enemies are ordered to abort their current attacks and return to formation.
  • Destroying an enemy in formation causes it to explode immediately. However, if destroyed in mid-flight, there's a chance it will lose control and spiral downward in an arc, leaving a trail of fire.
  • Colliding with an enemy results in instant death.


Power-Ups:
For every 70,000 points, a random power-up spawns on the battlefield. There are three types:

  • Red "Rapid Fire" – Increases your fire rate. Can be stacked up to three times.
  • Green "+1 Life" – Grants an extra life.
  • Blue "Multi-Shot" – Adds a spread to your shots. Can be stacked up to two times.
Note: If your ship is destroyed, all collected power-ups are lost.


Additional Details:
  • Both in flight and in formation, enemies like to show off by doing barrel rolls and flips (they're just rookies, what do you expect?).
  • I've tried my best to capture the authentic Star Wars atmosphere, complete with the music, a Lucas-style opening crawl (well, almost :)), the scrolling text, and I've even adopted the classic phrasing style :)

Have fun playing, and may the Force be with you! :)




Binary & Source Code:

Source code on Github https://github.com/GuvaCode/SWGalaxian/tree/main

Binary for Win64 or Lin64 on Itch.io https://guvacode.itch.io/swgalaxian

flowCRANE

  • Hero Member
  • *****
  • Posts: 1009
Re: Star Wars Galaxian
« Reply #1 on: August 08, 2026, 12:27:35 am »
I don't think I'll ever live to see the day when games start treating my computer with respect and stop cooking my CPU...

Full utilization of a single CPU core (16–17% on a hexa-core processor) activates CPU turbo mode forcing the clock speed to 3.5GHz, and the CPU fan runs at full speed. Dude, Hollow Knight: Silksong uses less CPU time despite being a million times more complex...

Is raylib so crappy that it can't run efficiently?
« Last Edit: August 08, 2026, 12:29:54 am 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 #2 on: August 08, 2026, 10:08:57 am »
I don't think I'll ever live to see the day when games start treating my computer with respect and stop cooking my CPU...

Full utilization of a single CPU core (16–17% on a hexa-core processor) activates CPU turbo mode forcing the clock speed to 3.5GHz, and the CPU fan runs at full speed. Dude, Hollow Knight: Silksong uses less CPU time despite being a million times more complex...

Is raylib so crappy that it can't run efficiently?

Dude, maybe someone just has a crappy system. On my pathetic Intel Pentium CPU G4400 3.30GHz × 2 with a GeForce GT 1030, the load is less than 3 percent.
The problem isn't the 'crappiness' of the game or raylib — it's how modern CPUs react to constant 100% load on a single core. And I don't know who's to blame here that the CPU decides to turbo boost from just one attempt to do some work.

Guva

  • Full Member
  • ***
  • Posts: 243
  • 🌈 ZX-Spectrum !!!
Re: Star Wars Galaxian
« Reply #3 on: August 08, 2026, 10:09:43 am »
But the problem might be that VSync is enabled here, and you have a high refresh rate monitor. Then you just need to limit the rendering with SetTargetFPS(60);
I think I'll do just that — it makes sense.

olatov

  • Full Member
  • ***
  • Posts: 110
Re: Star Wars Galaxian
« Reply #4 on: August 08, 2026, 11:07:09 am »
Nice one, well done! Compiled from source on a Mac, plays really well.
The blue power up makes the biggest difference, got me up to stage 47 :)

flowCRANE

  • Hero Member
  • *****
  • Posts: 1009
Re: Star Wars Galaxian
« Reply #5 on: August 08, 2026, 02:05:34 pm »
Dude, maybe someone just has a crappy system. On my pathetic Intel Pentium CPU G4400 3.30GHz × 2 with a GeForce GT 1030, the load is less than 3 percent.

Dude, none of that — Intel® Core™ i5-9500T, so six cores, each 2.2GHz up to 3.7GHz in turbo mode. As I mentioned earlier, a behemoth like Hollow Knight: Silksong uses less CPU time than your simple demo (see attachment).

Quote
The problem isn't the 'crappiness' of the game or raylib — it's how modern CPUs react to constant 100% load on a single core.

The CPU responds correctly to a constant load by increasing its clock frequency to nearly its maximum. The problem isn't the processor's behavior (which is the effect); the problem is the very existence of a constant load (which is the cause) — there shouldn't be any such load at all.

Quote
And I don't know who's to blame here that the CPU decides to turbo boost from just one attempt to do some work.

It's not the CPU's fault that the game is forcing it to execute a plethora of instructions and monopolize the time of a single core. The game is to blame, because it either generates frames recklessly or does not sleep the thread between successive frames. So the culprit is either the game code, which for some reason doesn't limit the frame rate to the monitor's refresh rate or a reasonable value (like 60 or 100 ups); or raylib, which can't freeze the game thread between frames, putting a massive strain on the CPU. Either way, it's a terrible design and a source of embarrassment.

The '80s are long gone; modern PCs aren't like Atari or NES, and it's time to finally realize that. Every application — especially games — should use only as much CPU time as it needs and return the rest to the system by putting the thread to sleep. If the monitor has a 60Hz refresh rate (like mine), the game should render no more than 60 frames and sleep through the remaining time between frames using dedicated mechanisms for that purpose (such as sleeps, waitable timers, or VSync).

Otherwise, it will massively waste the processor's time, which will pointlessly increase its clock speed, take CPU time away from other processes, overheat the CPU, and thus drain the battery much faster and waste electricity. And that's exactly what your game is doing — it's pointlessly wasting CPU time and electricity, so it's time to fix it instead of blaming my system.


I'm working on a game myself (Free Pascal + SDL3), and I know exactly what I'm talking about. But my game doesn't eat up as much CPU time as it can, but only as much as it needs — at 60fps, it uses 2–3% of CPU time without causing the clock speed to increase (which remains at 1.1–1.3 GHz). This is because the main loop has a fixed update rate (60ups), while the time between consecutive frames is either slept using VSync or using the SDL_DelayPrecise function (which internally uses waitable timers on Windows).

I respect users, their PCs and wallets — I recommend you start doing the same.
« Last Edit: August 08, 2026, 02:24:51 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 #6 on: August 08, 2026, 03:23:04 pm »

I respect users, their PCs and wallets — I recommend you start doing the same.

I still don't understand what you're talking about. If something isn't working right in the crappy, then we need to figure it out instead of throwing around baseless accusations. Calling the library 'crappy' as you put it — no one is forcing you to play with it or use it.

flowCRANE

  • Hero Member
  • *****
  • Posts: 1009
Re: Star Wars Galaxian
« Reply #7 on: August 08, 2026, 04:44:59 pm »
I still don't understand what you're talking about.

What I'm talking about is that your demo is so inefficient that it behaves more like a cryptocurrency miner, not a game.

Quote
If something isn't working right in the crappy, then we need to figure it out instead of throwing around baseless accusations.

So instead of calling my system “crappy”, you should figure out what's wrong — why such a simple game is eating up all the available CPU time. These are not baseless accusations, but a factual observation.

I asked, “Is Raylib so crappy that it can't run efficiently?” — because something is definitely wrong. And since I don't know whether the game or the raylib code is to blame, it's not my job to find the cause and solve the problem to ensure adequate performance. The current state and performance of this demo are unacceptable and reflect poorly on raylib, because it makes it seem as though this library is unable to function properly on modern CPUs.

Quote
[…] no one is forcing you to play with it or use it.

And I don't — I use SDL, and I don't cook the CPU. 8)
« Last Edit: August 08, 2026, 05:11:05 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.

Fred vS

  • Hero Member
  • *****
  • Posts: 3963
    • StrumPract is the musicians best friend
Re: Star Wars Galaxian
« Reply #8 on: August 08, 2026, 05:25:27 pm »
I still don't understand what you're talking about.

What I'm talking about is that your demo is so inefficient that it behaves more like a cryptocurrency miner, not a game.

Quote
If something isn't working right in the crappy, then we need to figure it out instead of throwing around baseless accusations.

So instead of calling my system “crappy”, you should figure out what's wrong — why such a simple game is eating up all the available CPU time. These are not baseless accusations, but a factual observation.

I asked, “Is Raylib so crappy that it can't run efficiently?” — because something is definitely wrong. And since I don't know whether the game or the raylib code is to blame, it's not my job to find the cause and solve the problem to ensure adequate performance. The current state and performance of this demo are unacceptable and reflect poorly on raylib, because it makes it seem as though this library is unable to function properly on modern CPUs.

Quote
[…] no one is forcing you to play with it or use it.

And I don't — I use SDL, and I don't cook the CPU. 8)

Dear flowCrane,

I've tested several Guva games that use Raylib, and they're all incredibly smooth and fast. I haven't noticed all these horrors you describe. I have an Intel 7i CPU and 32MB of RAM, and I ran the tests under Linux.

Before calling people and projects "crappy," you'd do well to take a good look at yourself and your PC in the mirror.

PS: SDL 2 or 3 are the crappiest, even if, according to you, they use fewer resources.

SDL3 is strictly a hardware abstraction layer. It provides windowing, input, and raw audio, but it does not include a 3D engine, font rendering, or math libraries. Raylib includes a complete 2D/3D renderer, a font loader, textures, audio, and an integrated math library (raymath.h) out of the box.

To build a fully featured game in SDL3, you must download, link, and manage separate libraries like SDL_image, SDL_ttf, and SDL_mixer. Raylib bundles everything into a single static library with zero external runtime dependencies.

Raylib uses an intuitive, immediate-mode execution model. You tell the engine to draw a shape, and it appears instantly. SDL3 requires you to manage complex render targets, textures, and vertex structures.

Raylib allows you to drop into a 3D camera view using a single line of code (BeginMode3D(camera)). SDL3 has no native understanding of 3D space, forcing you to write your own OpenGL/Vulkan backend or use an external library.

Respect is paramount.
« Last Edit: August 08, 2026, 06:13:52 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Scoops

  • Full Member
  • ***
  • Posts: 113
Re: Star Wars Galaxian
« Reply #9 on: August 08, 2026, 06:36:52 pm »
i dont want to take sides but flowCRANE can you post a screenshot of your win 11 idle sytem info compared to sytem info when running game, my main concern is its just windows, hogs resources no matter how good you think your setup is. thankyou.
ps. i saw previous sytem info you posted,but use this game not another as example for your system usage.

pps. on my debian 13 mate desktop , cpu 6% 87.6 mega memory used. Old laptop Intel® Celeron(R) N4000 CPU @ 1.10GHz × 2, 7,5 G ram
« Last Edit: August 08, 2026, 07:26:10 pm by Scoops »

Fred vS

  • Hero Member
  • *****
  • Posts: 3963
    • StrumPract is the musicians best friend
Re: Star Wars Galaxian
« Reply #10 on: August 08, 2026, 06:40:55 pm »
i dont want to take sides but flowCRANE can you post a screenshot of yout win 11 idle sytem info compared to sytem info when running game, my main concern is its just windows, hogs resources no matter how good you think your setup is. thankyou.

Here what I get (see picture).
But it is under Linux, I did not try yet for Windows.

[edit] Added result on my win11 machine.


« Last Edit: August 08, 2026, 07:12:04 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

hukka

  • Jr. Member
  • **
  • Posts: 64
    • Github
Re: Star Wars Galaxian
« Reply #11 on: August 08, 2026, 07:15:52 pm »
FWIW I'm getting an average CPU usage of 0,2% on my Windows 11/Ryzen 7/RTX 4060Ti system.
But I've been hit with the 100% CPU usage problem in the past with my own projects on some systems.

flowCRANE

  • Hero Member
  • *****
  • Posts: 1009
Re: Star Wars Galaxian
« Reply #12 on: August 08, 2026, 07:40:33 pm »
I've tested several Guva games that use Raylib, and they're all incredibly smooth and fast. I haven't noticed all these horrors you describe. I have an Intel 7i CPU and 32MB of RAM, and I ran the tests under Linux.

Great. Just because it works for you doesn't mean it works for everyone else. It actually works terribly for me.

Quote
Before calling people and projects "crappy," you'd do well to take a good look at yourself and your PC in the mirror.

I didn't call this library crappy; I asked if it is crappy — and that's a fundamental difference. And I asked about this not because I'm vicious, but because this game is cooking my CPU, and since it uses raylib, I suspected it was raylib's fault (because while skimming through the source code, I didn't encounter a custom main loop).

Quote
SDL3 is strictly a hardware abstraction layer. It provides windowing, input, and raw audio, but it does not include a 3D engine, font rendering, or math libraries. Raylib includes a complete 2D/3D renderer, a font loader, textures, audio, and an integrated math library (raymath.h) out of the box.

Exactly — raylib provides a mountain of functions, even though a given project might not need most of them at all.

Quote
To build a fully featured game in SDL3, you must download, link, and manage separate libraries like SDL_image, SDL_ttf, and SDL_mixer. Raylib bundles everything into a single static library with zero external runtime dependencies.

No, you don't have to. Especially since SDL3 includes built-in support for textures and an audio mixer, so for most projects, SDL3 alone is enough — no need for SDL_image or SDL_mixer. On the other hand, SDL_ttf is used when font rendering is required (SDL is not a game engine, but a multimedia API).



i dont want to take sides but flowCRANE can you post a screenshot of your win 11 idle sytem info compared to sytem info when running game, my main concern is its just windows, hogs resources no matter how good you think your setup is. thankyou.

Sure, see attachments. Typically, on idle, CPU utilization remains at 3–5% at clock speeds between 1GHz and 1.5GHz.

However, when I run this demo, the CPU's turbo mode kicks in, the clock speed increases to about 3.5GHz, and the game process consumes 17–18% of the CPU's time and boils it (the fan kicks into high gear). This isn't a problem with my CPU or my system — it's a problem with this demo.
« Last Edit: August 08, 2026, 07:42:31 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.

CM630

  • Hero Member
  • *****
  • Posts: 1788
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Star Wars Galaxian
« Reply #13 on: August 08, 2026, 08:06:02 pm »
Not my type of game, but I tried it.
CPU load flickered between 0 % and 1 % with an internal vga.
The CPU is introduced in 2012, definitely not a gaming machine.
Лазар 4,8 32 bit (sometimes 64 bit); FPC3,2,2

Paolo

  • Hero Member
  • *****
  • Posts: 786
Re: Star Wars Galaxian
« Reply #14 on: August 08, 2026, 08:24:05 pm »
here win-10&64, CPU see image (8%)

 

TinyPortal © 2005-2018