Skip to content

Gravity Pulls

A constant fall has no weight. Add velocity as its own variable and let gravity grow it every loop — the lander starts slow and speeds up, just like a real drop. This is the physics at the heart of the game: velocity that accumulates over time.

  • Commodore 64
  • BASIC

The dot falls at a steady pace, and that’s the giveaway that it isn’t real. Drop something and it speeds up the whole way down — slow at first, then faster and faster. To get that, the fall needs a velocity that grows, and gravity is what grows it.

gravity.bas
10 POKE 53281,0:PRINT CHR$(147)
20 C=20:Y=1:V=0:G=0.02
30 R=INT(Y)
40 POKE 1024+R*40+C,81:POKE 55296+R*40+C,1
50 GOSUB 500
60 FOR D=1 TO 30:NEXT D
70 POKE 1024+R*40+C,32
80 V=V+G
90 Y=Y+V
100 IF Y>21 THEN END
110 GOTO 30
500 POKE 646,1:PRINT CHR$(19);"SPEED:";INT(V*100);"   "
510 RETURN
A C64 screen, black background, a white lander partway down with a readout SPEED: 54 at the top.
Gravity at work: the SPEED reading climbs as the lander falls, because each loop adds a little more velocity. The longer it drops, the faster it goes.

Two variables now describe the fall. V is the velocity — how fast the lander is moving — and G is gravity, a small constant. The physics is line 80: V = V + G. Every loop, gravity adds a little to the velocity. Then line 90 moves the lander by that velocity: Y = Y + V. Early on V is tiny and the lander barely moves; loop after loop V grows, and the fall accelerates.

That’s the embedded concept of the whole game: velocity accumulates. Gravity doesn’t set the speed — it adds to it, over and over, so the speed builds. The readout (the routine at line 500) shows V climbing as you watch, which is the lander getting heavier on its way down. It’s the simplest physics there is, and you’ve written it in one line.

Try this

  • Heavier or lighter. G = 0.02 on line 20 is the strength of gravity. Try 0.04 for a brutal drop or 0.01 for a feather. The right value reads as a fall, not a plummet or a drift.
  • Watch the build. Note the SPEED reading at the top of the screen, then near the bottom. The number is far bigger at the end — proof velocity accumulated the whole way down.

What’s next

Gravity pulls the lander down and there’s nothing you can do about it — yet. In Unit 3 a key fires the thruster, shrinking the velocity, and the game finally fights back.

Run it here

This unit's program, built for you.

Program
gravity.prg
Machine
Commodore 64 (PAL Breadbin)

Download gravity.prg