Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- my car keeps hitting the donkey when switching lanes even though I'm already well past it..
- I haven’t looked at the code but the collision detection was buggy even back in the day. You have to switch lanes while there is nothing or a donkey in front of you. If the donkey is in the other lane it registers a hit even if it looks like you passed it
Edit: line 1750 is where it does a simple collision check and yep looks like it registers a collision without checking you’re past the donkey or not
by smackeyacky - have you had anything to drink recently?
- This is what got me into programming. When I was a kid, I had a shitty 386 because my father got a computer second hand from a friend (we were poor). I was playing the game and then pressed a key and it took me to the basic editor. I was confused with what I saw and started changing things. I changed a number and the size of the explosion on the banana got bigger. My best friend at the time went to computer camp and explained to me that it was code. 30 years later I'm still programming.by mempko
- WTF 386 was for me a sci-fi like device I wouldnt dare think about having when I was a kid. I had a very nice 8086 I cherished, with VGA video no less ! (Yes driving a vga card with a 8086 was slow..by makapuf
- Donkey running on a PC 5150:by chaoticmass
- That video should totally have this as the soundtrack beneath it:by nocman
- It says something about what a thoughtful development environment these early BASICs were, that you could make a full simple little game like this in only 131 lines even though they're ostensibly far less powerful than modern languages. I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
Never mind how compact, beginner-friendly, and just plain fun they were to use. It's been said countless times but I'll say it again - we've lost something over the years.
by wk_end - BASIC was higher level (or anyway, more batteries-included) than C. You could probably do this game in 131 lines of javascript straightforwardly.
- raylib might do it in less lines. SDL is designed as a cross platform base layer to wrap in another framework not as something you should be using directly.by tancop
- 131 lines and about 10% of them are the title/copyright banner. Genuinely impressive in it's tersenessby ligne
- Python is the modern Basic replacement, and also has similar fundamental design trade-offs. VB6 was the peak of the OLE/Multimedia paradigm, and was functionally replaced by the web browser script sandbox.
> we've lost something over the years.
Indeed, Information Appliances were never general-purpose computers. Some people used to care about that sort of thing, and left civilization the GNU compilers as one of the most important intellectual artifacts of our generation. =3
by Joel_Mckay - What we lost is simplicity across the stack.
I learned to program with BASIC. It was awful. I didn’t know how awful it was until many years later. So I don’t miss the language. But something I miss is how easy it was to learn what your machine was doing.
The DOS boot and config involved only two files: CONFIG.SYS and AUTOEXEC.BAT, that was it. Most programs were self-contained, so you could copy the directory to a floppy disk and run them on another machine. If you broke something, copy the files again and restart; that was it… I “broke” config and programs many times, and it was a good way to learn.
by diegof79 - Back in the days you would buy printed magazines that contained full basic source code of programs and games and type them on your own text editor. I was a bit too young to do that but I remember watching my older brother just do that and then play games (after finding the typing errors for a while).by prmoustache
- >I'm not sure if you could even get an SDL window open and game loop running in 131 lines of (non-golfed) C.
The basics (window, events, renderer) can be done in about 30 lines:
I don't think you could get all of donkey.bas done in 131 lines, though. SDL3 does ship with an embedded debug font but that seems like cheating. You probably couldn't replicate the drawing code easily, it would probably need to be faked with images, and you'd need a font atlas for the text.#include <SDL3/SDL.h> #include <SDL3/SDL_main.h> static SDL_Window* window; static SDL_Renderer* renderer; int main(int argc, char* argv) { SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_GAMEPAD); SDL_CreateWindowAndRenderer("test", 640, 480, SDL_WINDOW_RESIZABLE, &window, &renderer); SDL_Event event; while(true) { while(SDL_PollEvent(&event) != 0) { if (event.type == SDL_EVENT_QUIT) { goto ENDGAME; } //events go here } // update here SDL_SetRenderDrawColor(renderer,0,0,0,255); SDL_RenderClear(renderer); // render here SDL_RenderPresent(renderer); } ENDGAME: SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); }by krapp - It was really cool! The ease of getting started was definitely one of the selling points for the “home computers” of that era (GW-BASIC ran on IBM compatible PCs instead, but the appeal of BASIC was the same). Brevity was an important feature since a lot of people obtained programs by typing them over from a magazine or recording them from the radio. And of course, there was no such thing as auto-complete (let alone AI generation).
That being said, SDL isn't actually that bad either. A minimal example is about 40 lines of code [1], not counting comments and blank lines, but including lines with just a curly brace which you could easily remove if you were concerned about size. A slightly more serious implementation of Snake runs about 345 lines of code [2].
And to be fair, DONKEY.BAS is also cheating slightly on the line metric by stuffing lines full of statements, like for example:
1. https://examples.libsdl.org/SDL3/renderer/01-clear/ 2. https://examples.libsdl.org/SDL3/demo/01-snake/A$=INKEY$:IF A$=CHR$(27) THEN 1298 ELSE POKE 106,0:IF LEN(A$)>0 THEN LINE (CX,CY)-(CX+28,CY+44),0,BF:CX=252-CX:PUT (CX,CY),CAR%,PRESET:SOUND 200,1by sltkr - I once heard the rumor that DONKEY.BAS was the last piece of code Bill Gates wrote himself at Microsoft. I wonder if it's true.by sedatk
- That has all the hall marks of urban legend, but why let the truth get in the way of a great story.
I have said it for a very long time, Gates wasn't innovative in technology but he absolutely innovated in bringing the most ruthless business practices into software.
by ColdStream - Someone gave my grandfather a Games BASICA floppy that had this and other games on it. But this copy had a few games that had been "modified". I remember in DONKEY.BAS, it would curse at you if you hit the donkey. "YOU STUPID SONOFABITCH". We thought it was hilarious. My grandfather was less pleased. He took it away from us when he found out.by friarpuck
- Modifying those games were the first times I ever touched code! There was one that existed somewhere between DOS 2.0 and 3.2 that simply asked your name, then asked how the hell you got that name. It was maybe half a dozen lines, but easy enough to modify output and learn a bit about variables.
- I learned most of the best cursing I've ever done from my grandfather. He took pride in teaching his grandkids to curse.
He was involved in setting up the radar systems at Pearl Harbor, much good that did.
by dmd - As a kid I modified DONKEY.BAS for my younger brother who wanted to play as a donkey avoiding cars. It was a clumsy modification, I didn't account for the differing size of the pseudo-sprites, but it made him happy.
- Related:
Happy 45th Birthday to the IBM PC and Model F/XT
- The game theory is all wrong, this is a cooperative game, either they both win or both lose. I don't see how the Donkey getting hit by a car should be classified as "Donkey wins"by marcuskaz
- Donkey is also a collective noun for the donkeys and so the army that is the donkey wins.by hahahaa
- Inspired by the 45th anniversary of the IBM PC, I got my slopmachine cracking on a port of DONKEY.BAS to work in a browser. Pretty happy with the result. As a young person I remember being fascinated that you could make a game like this with so little code.by jkrauska
- nothing novel? just a generated port?
- https://codepen.io/manz/pen/RmEQgv
by grimgrin - > I got my slopmachine cracking on a port
For 131 lines?
by zahlman - For anyone unfamiliar with DONKEY.BAS: it’s notable for having been co-written by Bill Gates. More info on its history bere: https://en.wikipedia.org/wiki/DONKEY.BASby jamesdhutton
- 2nd, the wikipedia article has some fun stuff in itby jakzurr