Paolo Posted April 6, 2023 Share Posted April 6, 2023 Ok, folks here's the thing: my son -who was discussing programming and graphics library on a dicussion group- had the thought to search about PONG and how to program it, considering issues related to graphics libraries needed and such. Fact is that as soon as he started searching "howto code PONG game in C++", he was flooded of search results in the likes of "first off, download Unity or OpenGL". I couldn't do less than start laughing, and I told him I'd have to post here the fact. May you help me commenting properly the issue? Thank you! 🙂 Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted April 6, 2023 Share Posted April 6, 2023 When I did a search, the first hit I got seemed reasonable: https://austinmorlan.com/posts/pong_clone/ It walks thru the process of creating a Pong clone using C++ and SDL (https://www.libsdl.org/). Using SDL would be my suggestion. It's a "light-weight" library geared towards game development that does a good job at taking care of the basic platform specific stuff (graphics, audio, input)... which makes it easy to compile cross-platform (Windows / Mac OS / Linux). 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 6, 2023 Author Share Posted April 6, 2023 4 minutes ago, splendidnut said: ... Using SDL would be my suggestion. It's a "light-weight" library geared towards game development that does a good job at taking care of the basic platform specific stuff (graphics, audio, input)... which makes it easy to compile cross-platform (Windows / Mac OS / Linux). Thank you splendidnut, he also found some replies suggesting SDL and it's surely lighter than Unity; yet I think it's still overkill. Where would you drew the line between loading libraries and writing your own code il full? Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted April 6, 2023 Share Posted April 6, 2023 17 minutes ago, Paolo said: yet I think it's still overkill. Where would you drew the line between loading libraries and writing your own code il full? What's the goal here? No library usage? You can always go buy an old Dos programming book, install DosBox and Open Watcom C/C++. Program Pong from scratch. I need a bit more clarity on what your requirements are. Any Windows-style programming is going to require using libraries. If you want bare-metal, you'll have to resort to DOS or some retro platform. 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 6, 2023 Author Share Posted April 6, 2023 2 hours ago, splendidnut said: What's the goal here? No library usage? You can always go buy an old Dos programming book, install DosBox and Open Watcom C/C++. Program Pong from scratch. I need a bit more clarity on what your requirements are. Any Windows-style programming is going to require using libraries. If you want bare-metal, you'll have to resort to DOS or some retro platform. The goal is "acedemic". Just to understand at which point using a library is needed, being a PONG program a pretty straightforward task. Hence the question about drawing the line between using a library vs. creating a your own set of functions. I think the ultimate goal is to understand the mechanics of a graphics library. (I confirm, I just asked him :-D) BTW thank for your time and answers! 1 Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted April 6, 2023 Share Posted April 6, 2023 I think searching for old DOS graphics programming information is probably a good approach. It should help you keep clear of any library usage outside of the C standard library. There were graphics libraries back then, but typically everyone wrote their own so there should be a lot of information out there. That's where I got my start. Most of that knowledge is still applicable in a modern environment even when using OpenGL, DirectX, or SDL (the "low-level" libraries). For example, I typically write my own graphic primitive operations for blitting images, drawing lines and rectangles, etc.. and only use SDL to provide an image buffer and an interface to the underlying OS (Windows / Mac OS). 1 Quote Link to comment Share on other sites More sharing options...
zzip Posted April 6, 2023 Share Posted April 6, 2023 1 hour ago, Paolo said: The goal is "acedemic". Just to understand at which point using a library is needed, being a PONG program a pretty straightforward task. Hence the question about drawing the line between using a library vs. creating a your own set of functions. I think the ultimate goal is to understand the mechanics of a graphics library. (I confirm, I just asked him :-D) BTW thank for your time and answers! Problem is there's so many graphics modes these days and no standard. And if you tried to do raw graphics yourself, it may not play well with the OS/UI you are running. Something like SDL takes care of that kind of housekeeping task, and you can tell it what size screen you want, what pixel format and a number of other parameters. After that you can choose to set raw pixels to draw your objects, use line/rectangle drawing routines or use sprites, your choice on how low-level you want to go. 1 1 Quote Link to comment Share on other sites More sharing options...
+DrTypo Posted April 7, 2023 Share Posted April 7, 2023 If you use Visual Studio, you can try oneLoneCoder's pixel game engine: https://github.com/OneLoneCoder/olcPixelGameEngine It's just a header file to include in your cpp files. It's easier to set-up and use than SDL. You can access to the pixel data, there are a few graphic primitives (drawing line, rectangle, circle, text and sprites). It handles mouse and keyboard input. It's practically impossible to get more basic than that. Direct access to the hardware is simply not allowed on modern machines. You must at least use default Windows/Linux/MacOS system libraries. PixelGameEngine does that for you. 3 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 8, 2023 Author Share Posted April 8, 2023 My son thanks you for all the answers and the insights. 1 Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted April 8, 2023 Share Posted April 8, 2023 One I used in the past, but I don't know if you can actually find a copy anywhere anymore, was Marmalade SDK. That was just a Framework/Library that didn't have anything in the way of built-in collision, I don't think, but I could be wrong. I used it in conjunction with another library that sat on top of it (can't remember what it was called now) and created a version of the old 8-bit/16-bit game Loopz with it (no collision detection needed). Whenever I want to learn a new engine or library, PONG is always my go-to project. I guess this is for older-style libraries rather than fully-fledged game engines like Unity or Unreal? 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 10, 2023 Author Share Posted April 10, 2023 On 4/8/2023 at 11:50 PM, Tickled_Pink said: I guess this is for older-style libraries rather than fully-fledged game engines like Unity or Unreal? Yup! It's a search he's doing about how old-style stuff works, and Unreal/Unity step in the way of understanding it... It's too much of a black box to let him understand low-level things. Quote Link to comment Share on other sites More sharing options...
zzip Posted April 10, 2023 Share Posted April 10, 2023 On 4/6/2023 at 10:38 PM, DrTypo said: If you use Visual Studio, you can try oneLoneCoder's pixel game engine: https://github.com/OneLoneCoder/olcPixelGameEngine It's just a header file to include in your cpp files. It's easier to set-up and use than SDL. You can access to the pixel data, there are a few graphic primitives (drawing line, rectangle, circle, text and sprites). It handles mouse and keyboard input. It's practically impossible to get more basic than that. Direct access to the hardware is simply not allowed on modern machines. You must at least use default Windows/Linux/MacOS system libraries. PixelGameEngine does that for you. That's cool! For a library that purports to be "simple" the amount of setup SDL requires is a bit annoying. I miss the days of Atari BASIC where you could write a program that draws graphics in seconds. 3 Quote Link to comment Share on other sites More sharing options...
nadir Posted April 22, 2023 Share Posted April 22, 2023 On 4/6/2023 at 2:22 PM, splendidnut said: I think searching for old DOS graphics programming information is probably a good approach. It should help you keep clear of any library usage outside of the C standard library. There were graphics libraries back then, but typically everyone wrote their own so there should be a lot of information out there. That's where I got my start. Brings back some memories. I was mostly into doing graphical simulations, but I did do a Pong clone in C, with the graphics routines written in Assembly back on my old 10 mhz XT clone with DOS 3.2 back in the day! Code long since lost to history unfortunately, like almost everything I wrote back before GitHub existed... 2 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 22, 2023 Author Share Posted April 22, 2023 7 hours ago, nadir said: Brings back some memories. I was mostly into doing graphical simulations, but I did do a Pong clone in C, with the graphics routines written in Assembly back on my old 10 mhz XT clone with DOS 3.2 back in the day! Code long since lost to history unfortunately, like almost everything I wrote back before GitHub existed... Aaawww! Too bad you lost the code! But thanks for the memories of the good ol' days 🙂 1 Quote Link to comment Share on other sites More sharing options...
+bent_pin Posted April 22, 2023 Share Posted April 22, 2023 If you want your son to really learn how to program pong with just C++, I recommend an Arduino nano every and an array of LEDs and some shift registers. It will teach him about buffers and raw graphics as well as requiring him to race a beam of sorts. IMHO, it's a close analog to the 8-bit Atari academic in C++. I'll help you set it up if you go that path, 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 23, 2023 Author Share Posted April 23, 2023 23 hours ago, bent_pin said: If you want your son to really learn how to program pong with just C++, I recommend an Arduino nano every and an array of LEDs and some shift registers. It will teach him about buffers and raw graphics as well as requiring him to race a beam of sorts. IMHO, it's a close analog to the 8-bit Atari academic in C++. I'll help you set it up if you go that path, Hmm... I think he almost took your suggestion, but heading to the Gameboy route instead. He decided that your solution would have steered him too much towards the "let's solder wires and transistors" approach 🙂 (he said he doesn't want to build a Pong cabinet, hehe) Now he is examining how to put stuff onscreen, since in the "pure" programming department he seems quite comfortable. Any advice on that? Quote Link to comment Share on other sites More sharing options...
+bent_pin Posted April 23, 2023 Share Posted April 23, 2023 1 hour ago, Paolo said: would have steered him too much towards the "let's solder wires and transistors" approach 🙂 (he said he doesn't want to build a Pong cabinet I understand that completely. He is learning Gameboy programming? Lot's of youtube videos on Gameboy programming in C. He will still be using libraries though. My suggestion is that he learn first with the facilities as they exist and then extend it by exploring how to make simple ASM functions and subroutines. The Sharp CPU in it is not worth learning the full assembly for, but it is a sister-set to the Z80. Both of those being subsets of the 8080 are worth learning. Why? Many handheld devices including most TI calculators are or were based on the Z80 and can readily be hacked and upgraded by pushing a hex file. Also, the eZ80 which is ISA compatible is still recommended for new device design. 1 Quote Link to comment Share on other sites More sharing options...
Paolo Posted April 24, 2023 Author Share Posted April 24, 2023 12 hours ago, bent_pin said: He is learning Gameboy programming? Lot's of youtube videos on Gameboy programming in C. Yes, to learn the fundamentals. 12 hours ago, bent_pin said: My suggestion is that he learn first with the facilities as they exist and then extend it by exploring how to make simple ASM functions and subroutines. Great advice! 12 hours ago, bent_pin said: Why? Many handheld devices including most TI calculators are or were based on the Z80 and can readily be hacked and upgraded by pushing a hex file. Also, the eZ80 which is ISA compatible is still recommended for new device design. Interesting insights, thanks! 1 Quote Link to comment Share on other sites More sharing options...
Mr SQL Posted April 28, 2023 Share Posted April 28, 2023 On 4/6/2023 at 12:53 PM, Paolo said: The goal is "acedemic". Just to understand at which point using a library is needed, being a PONG program a pretty straightforward task. Hence the question about drawing the line between using a library vs. creating a your own set of functions. I think the ultimate goal is to understand the mechanics of a graphics library. (I confirm, I just asked him :-D) BTW thank for your time and answers! Great academic exercise and goal! This 1K PONG tutorial on the ZX-81 may be helpful to watch: The ZX-81 has a PONG graphics library with pixel set and reset commands. BASIC Programming may be insightful regarding the library question. Atari, Apple, ZX-81 and TRS-80 BASIC were designed to build PONG games. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.