Tichun
Posts: 68
Joined: Wed Jul 06, 2016 1:36 pm

Hello, Sanity! - want to learn low level programming

Tue Dec 06, 2016 5:54 pm

Hi.
I cannot find a sane way to start programming.
Where and how do I learn to make simple, gameboy era (2D, 2-bit depth) game in C(99) with understanding of how it's done?

From what I have read OpenGL ES 1/2 and SDL seem like the only ones I can choose from
(although there is a game 'alex4' in repo which uses allegro and looks a bit alike to what I want to achieve)
and GL being the one that does not hide so much under the hood compared to the other one, which is what I value.
But how were those 'ancient games' made? There was no such thing as opengl and so on..
Instead of C I could eventually accept assembly but the portability would be extinct.
As a platform I have no big expectations, if it ran only on Debian it would not be the end of the world but the more platforms it ran on the better it would be?
If it had one codebase for arm/x86 linux, android, windows, mac I would be interested in it (no java though, please).
Then I don't want it to run only under X11 as Wayland approaches and also I prefer to use bare command line in tty but then I worry about it not being hw accelerated..(not for performance reasons for now but I want to learn how to use gpu and tty is not hw accel.?)
It would be nice if the compatibility with Debian would not be broken after some OS upgrades.
From what I see musl libc seems nicer than glibc (and has worse performance :()

After lots of this kind of questions I have, I don't know how to put the plan into action, I have trouble finding broad documentation (probably tutorial books would be of my interest in the current state) and learning doing the actual development part.

I hope you'll be able to decode what I mean. Apologies for that messy write up.

WilliamGaatjes
Posts: 56
Joined: Mon Oct 03, 2016 6:02 pm

Re: Hello, Sanity! - want to learn low level programming

Tue Dec 06, 2016 7:53 pm

Although i never had any serious programming course, there is one thing i learned quickly : No matter what software( for example assembly or c or c#) you write, there is always the divide and rule principle. Divide your plan in pieces and smaller pieces. Each peace is a software function that can possibly be divided in smaller functions. The whole key is to do a structured way of programming that is easy to understand and maintain or to augment.

ghans
Posts: 7867
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Hello, Sanity! - want to learn low level programming

Wed Dec 07, 2016 7:13 am

You have to decide whether you want hardware-acceleration or software rendering.
Software rendering may be fast enough for your 2D games or it may not. If you want
a fast 3D game i would dare say circumventing exisiting libraries is not only stupid but
nearly impossible (see OpenGLES support).

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Hello, Sanity! - want to learn low level programming

Wed Dec 07, 2016 9:40 am

Tichun wrote:Hi.
I cannot find a sane way to start programming.
What is your current level of programming ability?

Can you write "hello world" in C. Can you write a program to multiply 2 matrixes in C?

You'll need the latter - or at least have the skills to write such a program if you want to start writing simple 2D games.

Start by bouncing a ball round the screen, then turn it into "pong".

But you need a graphics library..
Where and how do I learn to make simple, gameboy era (2D, 2-bit depth) game in C(99) with understanding of how it's done?

From what I have read OpenGL ES 1/2 and SDL seem like the only ones I can choose from
SDL (version 1.3) is more than fast enough on the Pi to do pseudo 3D stuff - like Wolfenstein 3D from a C program. I can almost do that from my BASIC interpreter which runs 20-30 times slower than C, so no need for fancy GPU stuff at this level.

So give us more information - what can you currently do?

-Gordon
--
Gordons projects: https://projects.drogon.net/

hippy
Posts: 5584
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Hello, Sanity! - want to learn low level programming

Wed Dec 07, 2016 11:14 am

Tichun wrote:But how were those 'ancient games' made?
Most used a 'frame buffer'; a memory held bitmap of pixels to display. That was either the actual display memory itself or a separate memory area with the hardware / software / firmware copying that out to the physical display.

The simplest displays were monochrome, pixels could be on or off; set a bit in the frame buffer and a pixel will be set on the screen. For more advanced displays multiple bits were used to set the colour or brightness of a single pixel.

From just one basic primitive, setting an individual pixel, routines can be developed to draw lines, circles, squares, fill areas, show characters and text, etc.

Graphics capabilities and performance were limited because the hardware only supported displaying the bitmap and by how quickly those routines could run. To improve performance hardware and software support for sprites ( and later polygons ) was added. Then things like texture mapping and other clever stuff came along with the development of libraries to make it easier to use such things.

When developing games now you can either go 'old school' and use a frame buffer and build everything up from there, or choose a graphics library where you only need to know how to do things and less about how it's done behind the scenes.

For the sort of games you describe a frame buffer approach should be good enough and should be fairly easy to do. Once you figure out how to create a frame buffer and get that displayed, can set and clear individual pixels, you have the starting point for layering more on top.

Morphology
Posts: 36
Joined: Tue Jan 10, 2012 11:16 am
Contact: Website

Re: Hello, Sanity! - want to learn low level programming

Fri Dec 09, 2016 10:12 pm

Take a look at Raylib: http://www.raylib.com/

A simple graphics library specifically designed as an aid to teaching games software programming.

Ray has added around 60 code examples, and the compile and build instructions are simple and robust. It really is a very simple way to get to understand how a game can be constructed and how you can interact with it from the outside world.

Morph

Return to “C/C++”