How to Make a C64 Game in BASIC Ep.1 [HOW2] | Nostalgia Nerd
HTML-код
- Опубликовано: 21 сен 2024
- BASIC Programming... it's a skill we think is long forgotten on today's youth. In reality, we can still do it, it's just not as abundant as it was in the 80s. It was the default landing page of everyone who turned on their home computer in that era, so there was little choice but to learn it, especially if you had no games. But this was where creativity blossomed, it's where the surge of 1980s game development came from... the bedroom coders, the school kids and even the adults switching career path in favour of their latest hobby. To make a game today you usually buy a piece of software which does most of the work for you... some kind of RPG maker or FPS creator which has layers upon layers of code, slowing down the whole process and really not making the most out of the lightning fast processors of today. Most games were coded in a few kilobytes in the 80s. Today, you can't even fit an email into that space. BASIC Programming did more than allow you to make games. It was a true creative outlet where you could do pretty much ANYTHING you wanted. Your logic was tested to the max, as you figured out the best way to code up a particular routine, all whilst using your problem solving skills to cram it in as little space as possible.
In this series, I'm aiming to bring a little bit of that back, by teaching you how to make a game in BASIC. I'm specifically targeting Commodore BASIC here, as it seems the most accessible, and it's one I spent a good time using back in the early '90s. This episode is an introduction to making a BASIC Game, so I'm taking a gentle introduction to programming in BASIC, with some key elements, but over the coming episodes the goal is to create a fully functional game in C64 BASIC, which you can then tinker and develop to your heart's content. Hopefully if I can get one person to dust off their trusty C64 and get tinkering, then I'll be happy.
This episode is looking at creating a simple guessing game, using random numbers.
Here's the final listing;
10 print "*Insert Clear Screen Character*"
20 let x=int(rnd(1)*6)
20 print "The Computer has chosen a number between 0 and 5. Can you guess it?"
40 input G
50 print "*Insert Clear Screen Character*"
60 If G=X then print "Well Done.":Goto 90
80 print "Tough Luck - You're Wrong."
90 Print "Do you want another go? If so, please type Y and press the return key."
100 Input A$
110 If A$="Y" Then Goto 10
120 Goto 100
☟Subcribe☟
www.youtube.co...
✊Support Me! ✊
Patreon: www.patreon.co...
Visit my eBay Shop: ebay.to/1QQpYyy
Buy From Amazon (affiliate): amzn.to/1OzCQWR
★Nerd Social★
Twitter: / nostalnerd
Face: / nostalnerd
Instagram: / nostalgianerd
Web: www.nostalgiane...
★Equipment★
Corel Video Studio Ultimate X7
Corel Paint Shop Pro X6
Blue Snowball Microphone
WinVICE Commodore 64 Emulator
♜Resources♜
First and Last tracks are Night Drive Turbo and Reflection of Paradise by the amazing Rad Universe - / raduniverse
Commodore 64 Image courtesy of Wikipedia/Wikimedia
HOW2 BG Intro from '90s kids programme HOW2 courtesy of Scottish Television Enterprises. Nostalgia at it's finest.
I suddendly felt the urge to buy a commodore and create a c64 game, i found this series, i discovered that it was never continued, i fell into depression. Now the C64 mini is out, PLEASE, GO ON WITH THIS SERIES
To save typing, you do not need to use "LET". You can also use the "?" instead of typing "PRINT", it will show up as "PRINT" when you list the program. You can also type "gO" (g = shift O) instead of "GOTO", it will show up as "GOTO" when listed. To list, you can type "L" plus shift "i". There were a lot of shortcuts for the C64 to save some typing. You could also insert cursor movements between the quotes for printing and it would move the cursor the way you want when it was printed. Good for placing text at specific location on screen. The C64 actually has some cursor locate commands built in, but you needed to call them in machine language or know the SYS address for it (which I have in some notes somewhere). There was actually a SYS call for clearing the screen if printing a clear didn't suit your tastes (SYS command called a machine language subroutine at the address specified).
I had some good times programming that machine.
Great work, thank you. I spent more hours than I care to remember programming in BASIC, first on the Atari 400, then Commodore vic 20, then Commodore 64, then QBasic on the PC, finally AMOS on the Amiga 1200... I found some of my old cassette tapes the other day with "Word pro v2" on them for the Vic 20, which was my attempt to create a word processor on an unexpanded vic 20 in BASIC. All it did, really, was accept keyboard input at the cursor location, and F1 allowed a "save" of the whole screen to a specified flename on tape, while F3 allowed a loading of the whole screen. Even just cramming that into the tiny memory of the unexpanded vic in basic was a task, but i was proud of it. Now, I wouldn't have the foggiest idea how to do it, hahaha
I'm having a good time using the c64 maxi to write basic games again like I used to back in the 80's. I start with a very simple idea "swinging a golf club and seeing how far the ball goes". No graphics. Just 4 lines and eventually I expand it to hundreds of lines as I keep expanding the idea. I used to eventually add graphics but I don't really care these days. It's a fun diversion and one bug can so focus your mind that hours can go why without notice while you think yourself through the code trying to find it.
"A better way is to step out onto the pitch and start playing", this is 100% true, I never would have learned to program if I didn't dive right into something way over my head and learn by necessity.
You're very natural at teaching and I think this will be of genuine use to people who want to code but feel intimidated by it. I used to enjoy making simple programs on my Speccy back in the 80s and QBasic on my DOS PC in the 90s and even had delusions of becoming a professional. I then hired a book on machine code from my local library and realised I was out of my depth! Nowadays I just stick to the occasional simple web app as HTML/Javascript as it's all my simple brain can understand.
I sure would love a follow up to this..
Agreed
this was the first game i ever wrote on the Commodore when I was 7. so many great memories. thank you
Wow, nice show... its been abot 20 years since i touched basic.... oh such memeories.... this videos removes abot first 100 pages of any manual and a lot of confusion for starters... oh if only i had tutor like that back in the days... great video, thank you very much for nostagic memories
I had fun programming my Commodore 64 and VIC-20 as a kid, back in the day... learned a lot about programming concepts.
C64 blue screen reminds me of my childhood. I was 8 when my parents bought me one. That blue screen caused alot of tears but also joy.
I remember the days. I wrote so many games on my C64 back in the day.
BlackburnBigdragon I find JVM to be a good modern equivalent to learning basic on c64 because with JVM you can make complex programing from layers of simple code which the Linux kernel builds into complex program for you and you can go back and edit the program in its original stage of being a collection of simple codes vs something a c++ program where you must built the nativity into a complex program which makes the difference of 5 minutes vs 2 hours to find the code were you forgotten a symbol.
You brought back so many good memories from the "How 2" intro. That was a great TV show. That's where I first learnt about non-Newtonian fluids where Craig cut the stream of pouring liquid. Awesome.
Another way to generating integers without the INT keyword:
10 X% = RND(0) * 10
20 PRINT X%
The % sign tells the interpreter to expect a signed 16 bit number, so has a range of -32768 to +32767, so it will automatically round it to an integer (I think it rounds down)
My first "computer". You've come a long way baby.
You could have added this line to the beginning of the program :
15 X = RND(-TI)
that would initialize the random number generator and then you won't have the same sequence every time you reboot
Getting happy flashbacks to programming in BASIC on my VIC-20, when I was something like 6 or 7 years old. I was a little computer geek, and I loved every minute of it!
Just found your channel, cool stuff, loved learning from this video! Very cohesive teaching style you've got going on. When can we expect Ep. 2?
I'm so surprised you don't have more viewers 😲
This is such a great way to get my retro computer fix haha
For the listing in your description, instead of "*Insert Clear Screen Character*" you could also write chr$(147). Does the same thing, just looks a bit nicer on paper.
I'm guessing when you started this you didn't realize how much work it would be. But I hope it's still on your list of things to revisit, because it's a great idea!
Oh man, this was really awesome! Thanks!
I learned a lot about what programming was like on early systems.
This video was a little beginner for me so I can't wait for further more advanced episodes. I'm very interested in how graphics like sprites and draw commands were created and handled on these systems.
I love the part at 5:00 with the long pause, and then "question mark". I found that really funny for some reason.
I think he was trying to decide if he wanted to correct the spelling mistake or pretend he didn't see it.
Thanks ! I got one last year and I've been planning on coding a video game since 1988...
Been a programmer since 2003 put the project of my own game on the back burner and now i the time.
But I've never coded basic : COBOL, C, , C++, java, js, xthml, etc...
Thanks for this, I've just this week added a c64c to my collection and was thinking of learning basic coding! Awesome.
I was such a soft kid whenever we'd visit WHSmith in the 80s all I'd write is
10 Print "Hello"
20 Goto 10
Everyone else wrote swear words. It never even crossed my mind to do that :)
I haven't messed around with BASIC as a programming language. More used to C++, though I would like to go backwards and learn more for the old PCs. I have attempted 6502 Assembly with a Commodore 64 Emulator. Would use my real C64 but my tv fell on it and its no longer functioning. Man is assembly rough. I have got as far as understanding the algorithm to multiply binary numbers using the carry bit. Due to time constraints in my life, I just haven't got any farther with it.
I love programming I found a coding game on the Nintendo DSI and 3DS called Petit Computer and SmileBASIC they both use Basic and are a blast to make programs and games on. My 1st game was a chose your own path text game mixed with a maze-like dungeon my 2ed game was a slot machine game, I spent weeks working on the animation not using sprits just symbols. I would spend hours just adding code and would find my self looking at 400 new lines of code thinking how did I add all this with no programming experience. lol
At this point it's fair to say you do have programming experience... If you tried to get into modern programming, especially comething high-level and simple like phyton, you would probably find it very easy and entertaining. Phyton does have some similarities to Basic, and it's often used as a learning ground for new programmers, but it's still an incredibly powerfull language. If you wanted, you could build an entire game engine and game worth of the best productions with it, but of course there are better and more efficient ways of doing so by using C++/C# or Java.
I rember there was a "guess my number" program in the Commodore 64 User's Manual. It would give you some hints too, such as "my number is lower" or "my number is higher". I remember I was quite enthusiast of this program when I first typed it in (I was 9 or 10). There were also a dice throwing simulator and a maze generator, both using random numbers.
For example, this one line program will draw a maze:
10 print chr$(205.5+rnd(1));: goto 10
My biggest achievement in C64 basic was a Cross-stitch pattern maker program for my wife. It was mostly done in basic, but with ML routines to manipulate the multi-color mode. Many, many hours of hard work!
Excellent - I just got myself an old C64 (bread bin type) from Ebay, so I'm trying to relearn all my basic knowledge.
Looking forward to seeing more of your videos :)
This brings back good memories, loved programming back in the day. Also probely the reason why i love to use Linux today :)
Unless a programs starts with....
10 POKE 53280,0 : POKE 53281,0
...it sucks
And poke 646,5 for that traditional greenscreen look...
does nothing
BSM?
i so agree i started every one with this but i made the border white instead.
Did you ever make a part two???
Zane Revai Came here to ask the same thing.
😢
Its been 5 years and still no
Here is a better one that rolls TWO dice.
5 PRINT "CLR-HOME"
10 X = INT(RND(1)*6)+1:Y=INT(RND(1)*6)+1:Z=X+Y:REM ROLLS TWO DICE, GENERATING RANDOM NUMBERS BETWEEN 1 AND 6 FOR EACH AND ADDS THEM.
20 PRINT "THE COMPUTER HAS ROLLED THE DICE. CAN YOU GUESS THE TOTAL (BETWEEN 2 AND 12)?"
30 INPUT G. IF G < 2 OR G > 12 THEN PRINT "YOUR GUESS MUST LIE BETWEEN 2 AND 12": GOTO 30:REM REJECTS OUT-OF-RANGE GUESSES IMMEDIATELY
40 IF G Z THEN PRINT "SORRY, YOU GUESSED WRONG."
50 IF G = Z THEN PRINT "WELL DONE!"
60 PRINT "DO YOU WANT TO TRY AGAIN (Y/N)?"
70 GET G$:IF G$="" THEN GOTO 70:REM RETRIES EMPTY KEY BUFFER
80 IF G$="Y" THEN GOTO 20:IF G$="N" THEN GOTO 90
85 GOTO 70:REM REJECTS ANY ANSWER EXCEPT Y OR N
90 PRINT "OK, SEE YOU AGAIN SOON.":END
Excellent video. I'm looking forward to part two.
Clear home should be shift clear home.
You are correct. Still it gives people a bit of a challenge.
Nostalgia Nerd True😊
Thanks! Im gonna try this on my C64 Mini tonight!
POKE 211,X : POKE 214,Y : SYS 58732 - this will set the cursor at the location specified.
SYS 58692 - same as the CLR/HOME, clears the screen.
POKE 775,200 - disable LIST
POKE 775,167 - enable LIST
You are really good at teaching programming thanks for helping
90 Print "Do you want another go?"
100 Get A$ : If A$"Y" And A$"N" Then 100
110 If A$="Y" Then 10
120 If A$="N" Then Print "Goodbye!"
I remember making a text game rpg on here (I even made a social media replica out of boredom one night)
Before this video the only thing I could do in basic was:
10 print "Hello World!"
20 go to 10
run
I tried writing this program on N-88 basic for the NEC PC-88 computer and well, it kinda worked! I could guess numbers and stuff, but some of the code (like clearing the screen and restarting the game after I got a number wrong) didn't work because the PC-88 and the C64 have some different functions, and well, I don't really know what are the PC-88 equivalents to them... But still, I think I've learned a thing or two about basic from this video!
10 PRINT "WHAT KIND OF EMULATOR DO U USE?"
20 PRINT "THANK YOU SO MUCH!"
RUN
WHAT KIND OF EMULATOR DO U USE?
THANK TOU SO MUCH
READY.
More seriously: Vice is a great one, for a lot of Commodore computers.: vice-emu.sourceforge.io/
This was great. Used it to make a coin flip where it guess 2 numbers then if they were the same it was heads
I used to code a lot (Basic and Assembly language) on the C64 back in the days. Now, almost 30 years later, I'm back at it, because I decided to write a Basic V2 interpreter in Java. It's shocking how man quirks this language actually has that I either forgot or never knew about back then.
I hope that your tutorial programs will be limited to text output for some time, so that I can use them as test cases for my interpreter...
Made a short little number guessing game. Turns green when right, Red if wrong
....and even then i fucked up.... it should be...
goto 60
40 print" wrong try again"
50 goto 10
60 print "well done... your in"
70 run file "nastolgia nerd"
new how2 tutorial looks nice :D
i tried to code this on a TI-99/4a. It didn't work, time to get a C64.
If you want to copy and paste basic in to a emulator you will need to convert all the code into lower case as won't display properly otherwise.
Nice, it's pretty straightforward. I wonder how would you program graphics... the 8-bit guy said it's not so convenient. What were the most popular programs/games programmed in BASIC?
I remember having a few simple games made in basic. i dont think any real games ever were coded in basic since it is very slow compared to assembly code. I did small graphics (Sprites) by drawing them on paper and calculating their values by hand. (Binary to decimal). The DATA command was then used in basic. Ah those memories.
Most of the "games" I programmed using the RND function were for pen and paper RPGs and table top games like battletech where I would tell the computer all the variables for a particular task such as how many hexes the target was away, the type of weapon being fired and how fast the target was moving and it would tell me if the shot hit and how much damage it did. which saved time I would of spent rolling a dice and looking up the various tables and such and made the game run much smoother.
Nice Nerd, looking coding on C64 is always great!
it's remind me of the batch programming
10 print "Willy"
20 goto 10
Used to do that in boots 30 something years ago. :D
why was this the only c64 basic guide you made? i think it would be a really good series.
I code in BASIC and I love it
10 print "what is the password"
20 input a$
30 if a$ = "nastolgia nerd video was great" goto 50
40 print "wrong try again"
50 goto 10
- this is how i used to password protect on my amstrad cpc in the day and thought i was a smart ass.
What if someone was smart and looked at the source code.
Is Nostalgia Nerd How 2 Basic? *get it*
Can you make a simplified Doom clone in SimpleBasic? I’d really like to see that done. Raycasting is possible in it, as is simple polygonal 3D.
scnclr was usually clear screen in most commodore basic languages good video
That intro reeks of age
Where is the clear screen character on my c64 emulator?
the one that looks like a heart in a box.
VERY cool, keep up the good work!
That was super helpful. Thanks. I just spent some time looking for part 2 because I just bought original Commodore 64 and want to learn to code in basic. Now I know of assembly and not sure where to start. I suppose the guide that came in the box is a good start. But after that...?
This video has really helped me start learning to code. I hope you'll continue the series, because you're really good at making this all make sense.
there is a version of BASIC i remember on C64 that conformed to the PRINT CLS function instead of the heart symbol , it so long ago i can't remember which one
is there LET command in commodore's language? as i remember it was only x=... without LET.
LET is optional
sweet sweet memories!
One thing I don't get is why the text just splits when you go to the next line halfway through a word, I think my obsessive compulsive is coming out. Great idea for a series though will be dusting off my c64 for this!!!
Bit late now - But I wish I had a video like this when I was a kid!
reminds me of how javascript deals with random number generating.
Great tutorial, thank you very much! =D
it would be cool if the program told you the number the computer picked.
When it got to the point when it kept running the program every time. I couldn't stop the program.
Escape or Caps lock are usually mapped to the 64 Stop key.
any chance you could do a few more of these please?
That is pure spaghetti code. No need for that in 2016 or later...
10 2020
20 STILL WAITING FOR PART 2
Eh, how am I supposed to type the "clear screen" symbol if I'm trying to do this on the VICE emulator, where I assume my Windows keyboard doesn't have such a button?
I just spent whoever long typing out all that stuff above only to notice you weren't telling me to literally type "*Insert Clear Screen Character*". :-o
Why not use the CLS command instead to clear the screen?
"...the computer randomly chooses a number between 0 and 0.9-"
Yeah try telling that to the C64, when around 1:40 the computer instead decided on 4.69653672E -03
Guess the C64 showed you who was really in charge, didn't it?
When did "else" first appear? select case is always handy too, but I'm pretty sure that didnt exist back then
The Commodore 128 had IF/THEN/ELSE. BASIC V 7.0
If they would have made a Commodore 256, it would have had IF/THEN/MAYBE:
10 X=INT(RND(1)*100)+1
20 IF X>50 THEN GOTO 30 MAYBE 40 OR EVEN 50ish
30 GOTO BED
I have a few memories of programming on a C64 (my friend had one). I don't think we ever got much past printing characters to the screen, trying to make text art! it wasn't until many years later I started using Turbo Basic and it all came back to me
ngl, this is fun.
Instead of prompting for another guess I'd just loop until the user gets it right. until $guess == $answer, etc.
Nice!
Video starts at 1:09
This is probably such a common question, but how does one break out of the program? I'm learning basic just for shits, I actually kind of despise programming. But it's fun to fool around with old languages to me for some reason.
You can actually use the command "END" inside a program, or you just let it reach the end of the code.
We have very different definitions of what GAME means :)
So you could do a loop by just using the goto command?
10 FOR X = 1 TO 100
20 PRINT X
30 NEXT X
I am an BASIC-fu guru (meditation)...
Software Failure. Press left mouse button to continue.
Guru Meditation #00000025.65045048
Will there be a part 2?
Good idea for a series. Very glad to hear your rig campaign exceeded its goal!
Great video - is there a 2nd part?
Hi, I would like to ask a question: I'm doing some sprites for the C64 using Spritepad, and want to give my sprites to a programmer to implement them in the code. In the options I can chose between .prg .bin and .spd also when I chose .prg, the program is asking me to put a number (maybe I have to put a different number for every sprite I create)?....thank you!
I am using an Emulator, how do I get the clear screen symbol there? emulating on retropie with raspberry pi and a german (qwertz) layout, though retropie or the emulator is configured for US
i didn't know to much about Comodore64 until i saw your channel...e wasn't to famous in the Americas for me. i saw it once were im from in Puerto Rico.
is there a way to save your program to a cartridge? I know there are some places that make new circuit boards and sell the components and cases needed. I would love to make my own even if just for my own sake.
Oh I've liked this before. Guess I watched it before! I forget.
Good, but now I need to know how to put it on a floppy disk.
save "NAME",8
replace NAME with the name that you want your program to have (KEEP THE QUOTES), and replace 8 with the port ID that your floppy drive is connected to (the first port is 8 then there are ports 9, 10 and 11)
if you want to save to tape then simply don't input a drive port ID, though i personally recommend floppy cuz it
1. Loads faster
2. JiffyDOS machines cannot read from tape for some reason
3. If you save your program on a disk that you have GEOS files on, then you can run the program from GEOS :D (though it's pretty useless since to run it from GEOS you gotta boot GEOS from the BASIC prompt first and you might as well just load the program directly from the BASIC prompt anyway)
I'm running vice version 3.3, C64 emulator.
On Linux, on a macbook, with an azerty keyboard layout (Belgian), yep...
I can't find the dark heart, is it possible to input it?
I used this instead:
10 PRINT CHR$(147)
list
run
I also did a:
115 IF A$="N" THEN GOTO 130
120 GOTO 100
130 END
Also, with the 90 GOTO 10
example, I couldn't break it. Normally a press on the 'esc' button on my keyboard is enough. But I eventually just had to shutdown the computer (the emulator that is, haha).