News for hackers. Stuff that matters.
Re:Space Invaders from Scratch by nils-m-holm on Sunday May 27, 2018 @11:42AM (#17167329)
Writing a Space Invaders clone is such a rewarding task! :)

Here's mine (using Xlib): https://www.t3x.org/xt3x/index.html

Re:Space Invaders from Scratch by CodeWriter23 on Sunday May 27, 2018 @04:34PM (#17168971)
Space Invaders was something I wrote in BASIC as a side project while in high school. Then with each new language I needed to learn, I wrote Space Invaders in that language to get me up to speed quickly.
Re:Space Invaders from Scratch by jamiek88 on Sunday May 27, 2018 @07:14PM (#17169656)
Me too!

BBC basic, had an acorn electron at home with nearly the same BASIC installed so I could work on it outside of school but getting the timings right for both machines was hard.

Ended up with two versions selected at runtime.

Me and my best pal at school both wrote versions when we weren’t collaborating on tools to hack the Econet system!

Great times.

Re:Space Invaders from Scratch by scottlu2 on Sunday May 27, 2018 @12:06PM (#17167497)
A Javascript based one: https://codesandbox.io/s/2px9y0p480
Re:Space Invaders from Scratch by ivan_ah on Sunday May 27, 2018 @12:24PM (#17167626)
Nice! 2k lines of js, but it's all there and quite readable.

The gif-backed DemoMode is also very cool.

Re:Space Invaders from Scratch by bigiain on Sunday May 27, 2018 @09:15PM (#17170077)
Heh - I remember doing this in ascii-art on an Osbourne CP/M machine, first in Basic and later in Z80 assembler. I used the wiring diagram in the owner manual (!!!) to work out how to make a joystick I could plug into the parallel port. I was maybe 13 at the time...
Re:Space Invaders from Scratch by DEADBEEFC0FFEE on Monday May 28, 2018 @06:01AM (#17171587)
Increasing few people know what the hell your on about. Parallel port, you were lucky. 15 pin analogue for me.
Re:Space Invaders from Scratch by mar77i on Monday May 28, 2018 @08:45AM (#17172114)
15 pin analogue? Luxury. I had to manually wire a piece of wire to a microchip to attach a joystick made of dinosaur bone.
Re:Space Invaders from Scratch by krapp on Sunday May 27, 2018 @09:21PM (#17170101)
Since everyone is showing off theirs here is my half-assed attempt: https://bitbucket.org/kennethrapp/spaceinvaders
Re:Space Invaders from Scratch by aerique on Monday May 28, 2018 @05:18AM (#17171461)
And here's mine: https://aerique.itch.io/alien-conquerors

It was written in Haxe and compiled to Flash. Doesn't really work anymore in most browsers. I should find the source and recompile as HTML5.

Re:Space Invaders from Scratch by dirkc on Monday May 28, 2018 @06:48AM (#17171726)
I had to play until killing all the aliens at least once!
Re:Space Invaders from Scratch by aerique on Monday May 28, 2018 @10:05AM (#17172464)
Haha, nice to hear it still works and well done!
Re:Space Invaders from Scratch by anoakie on Sunday May 27, 2018 @03:00PM (#17168498)
I implemented Space Invaders from scratch, but in a roundabout way... By writing a well documented 8080a emulator that can play dumps of the arcade roms: https://github.com/anoakie/siemu
Re:Space Invaders from Scratch by nyrulez on Sunday May 27, 2018 @12:08PM (#17167509)
This brings back some fond memories. I once made a 3D OpenGL clone of space invaders for a graphics course (Windows only). It made a bunch of changes and was actually playable and reasonably challenging...don't know if it even works today

http://www.cs.northwestern.edu/~agupta/_projects/space_invad...

Re:Space Invaders from Scratch by opencl on Sunday May 27, 2018 @09:30PM (#17170125)
It runs fine on W10, just needs vsync forced on to play at a reasonable speed.
Re:Space Invaders from Scratch by AnotherHustler on Monday May 28, 2018 @12:54AM (#17170663)
If you want to be OCD about it - here's how the original arcade game worked...

http://www.computerarcheology.com/Arcade/SpaceInvaders/

Re:Space Invaders from Scratch by sehugg on Sunday May 27, 2018 @08:51PM (#17170018)
Here's my version targeted for the original 8080 hardware, in C: http://8bitworkshop.com/v2.1.1/?platform=mw8080bw&file=game2...
Re:Space Invaders from Scratch by weeber on Sunday May 27, 2018 @11:53AM (#17167416)
Interresting, but the OpenGL setup is not necessary?
Re:Space Invaders from Scratch by MikkoFinell on Sunday May 27, 2018 @12:47PM (#17167754)
Why not?
Re:Space Invaders from Scratch by grenoire on Sunday May 27, 2018 @01:32PM (#17168008)
The author is handling sprite rendering entirely on the CPU, he's only using OpenGL to put a bitmap on the window. Little bit unnecessary.
Re:Space Invaders from Scratch by flohofwoe on Sunday May 27, 2018 @03:09PM (#17168546)
GLFW+GL provides a portable way to do this though. Otherwise you'd need to mess with platform-specific window systems.

(something like minifb would be a more minimal option though: https://github.com/emoon/minifb)

Re:Space Invaders from Scratch by Narishma on Sunday May 27, 2018 @03:58PM (#17168817)
SDL is more than enough for something simple like this. You don't need to mess with OpenGL.
Re:Space Invaders from Scratch by weeber on Sunday May 27, 2018 @05:14PM (#17169141)
Yes with SDL Surfaces.
Re:Space Invaders from Scratch by krapp on Sunday May 27, 2018 @09:18PM (#17170094)
Textures would be better. Surfaces are raw data, but textures are optimized for the individual hardware.
Re:Space Invaders from Scratch by newnewpdro on Sunday May 27, 2018 @03:40PM (#17168731)
SDL2 is pretty popular these days
Re:Space Invaders from Scratch by Grieverheart on Monday May 28, 2018 @01:52PM (#17173758)
One of my goals is to reuse parts of the engine for future projects where hardware acceleration might be used.
Re:Space Invaders from Scratch by weeber on Sunday May 27, 2018 @05:12PM (#17169135)
Exactly!
Re:Space Invaders from Scratch by aquova on Sunday May 27, 2018 @09:11PM (#17170069)
A little bit off topic, but what are the best libraries for drawing simple graphics like this? I've been looking into making a small graphics project and I'm not sure which is the best to use. It only needs to draw basic shapes like ellipses, or rectangles, or just specific pixels. I've been looking into SDL2, as that seems relatively popular and portable, but I'm curious to see if there's any other libraries that are recommended.
Re:Space Invaders from Scratch by sfifs on Sunday May 27, 2018 @09:17PM (#17170087)
While this may seem heretical to many, why not consider SVG or HTML5 canvas? Widely supported, Ultra portable and very readable code unless you are looking for stuff that needs fancy acceleration.
Re:Space Invaders from Scratch by feiss on Tuesday May 29, 2018 @10:50AM (#17179600)
Html Canvas is easy and accessible for anybody, a safe choice. If you look for something native and accelerated, the best thing I found is Tigr https://bitbucket.org/rmitton/tigr/src

I really miss 486 days, when all you needed to paint pixels on screen full speed was 2 ASM instructions and writing to video memory. Full freedom and creativity without any technical barrier.

Re:Space Invaders from Scratch by vardump on Monday May 28, 2018 @05:15AM (#17171446)
"From scratch" made me expect something like "From NAND to Tetris".

http://www.nand2tetris.org/

Or Space Invaders not on modern hardware, or at least on an emulated 8-bit system.

Re:Space Invaders from Scratch by zorkw4rg on Monday May 28, 2018 @07:11AM (#17171805)
now that unreadable shader trick might be neat and all, but since GLSL supports if statements why not use this and make it readable? There certainly won't be any performance issues with rendering a single triangle, but I suppose people want to feel clever?

https://rauwendaal.net/2014/06/14/rendering-a-screen-coverin...

Re:Space Invaders from Scratch by Grieverheart on Monday May 28, 2018 @02:04PM (#17173829)
Hi zorkw4rg. Thanks for having a look at the tutorials. What makes the vertex shader not readable in your opinion? If you substitute the different values gl_VertexID can take (0,1,2), it's not hard to calculate the values of gl_Position.
Re:Space Invaders from Scratch by zorkw4rg on Friday June 01, 2018 @04:28PM (#17209863)
Its certainly not hard to calculate but a if this index then this vertex coordinates, and so on, seems significantly simpler than having to calculate anything at all? It sure what be more verbose though.
Re:Space Invaders from Scratch by dexterdog on Sunday May 27, 2018 @03:39PM (#17168728)
He seems to have skipped over the creation of the universe step at the beginning.
Re:Space Invaders from Scratch by crooked-v on Sunday May 27, 2018 @07:52PM (#17169824)
Well, we still don't know what programming language the universe runs on, so properly documenting that part would be a bit tricky.
Re:Space Invaders from Scratch by chii on Sunday May 27, 2018 @09:18PM (#17170092)
I'm fairly certain that mathematics is the language that the universe is written in...
Re:Space Invaders from Scratch by tabtab on Tuesday May 29, 2018 @12:25PM (#17180600)
No, we use math to model it, but whether our models are "perfect" may be very difficult to ever know. Since we cannot model every atom, we don't know whether the differences between our model and reality are because our models are wrong or if we simply have imperfect inputs (starting positions) in them.
Re:Space Invaders from Scratch by dexterdog on Monday May 28, 2018 @08:49AM (#17172129)
But what language was that written in? I always assumed it was logo because it's turtles all the way down.
Re:Space Invaders from Scratch by Grieverheart on Monday May 28, 2018 @01:53PM (#17173767)
Maybe I'll write a Haskell tutorial...