Paulo Laureano Because coding is fun!

Learn to code in the C language (2/3)




Gentle introduction to coding computers, using the C programming language, in well under 90 minutes (this is part 2 of 3).

After the first three "gentle introduction lessons", in part 1, here is a pack of the following four chapters. I will do another series of videos with an example game and more advanced subjects (graphics, sound, etc). You have to start somewhere and this first hour is really a soft way to create some sort of familiarity with what C code looks like and how to read it.

You get a link to a free MagPi magazine issue and links to the example code in the video description on Youtube.

You can see the video and then read the first three chapters of the magazine, but I recommend you do it the other way around: read the first three chapters and then see the video.

Do not be in a hurry to "read every lesson" or "watch every video"! Your time will be better spent trying to write code similar to the examples and experimenting with your new found skills. In fact, it is crucial that you take it slow, type code, make mistakes and learn with them.

Example 4 used in the video:

example1


Example 5 used in the video:

example2

Example 6 used in the video:

example3

Example 7 used in the video:

example4

Example 8 used in the video:

example5

Example 9 used in the video:

example6


Learn to code in the C language (1/3)




Gentle introduction to coding computers, using the C programming language, in well under 90 minutes (this is part 1 of 3).

After the first three "gentle introduction lessons" I will do another series of videos with an example game and more advanced subjects (graphics, sound, etc). You have to start somewhere and this first hour is really a soft way to create some sort of familiarity with what C code looks like and how to read it.

You get a link to a free MagPi magazine issue and links to the example code in the video description on Youtube.

You can see the video and then read the first three chapters of the magazine, but I recommend you do it the other way around: read the first three chapters and then see the video.

Do not be in a hurry to "read every lesson" or "watch every video"! Your time will be better spent trying to write code similar to the examples and experimenting with your new found skills. In fact, it is crucial that you take it slow, type code, make mistakes and learn with them.

Do it in the morning, after a good night sleep (trust me, you will learn faster, caffeine is not a replacement for a good night sleeping). Programming is hard and you are not dumb. If you have questions please leave a comment in the video, I will try to answer as many of those as possible.

Suggestions after the first three lessons:

1 - Write a program that counts up from 0 to 10 (hey, its a reversion of the "ten little Indians" example, how hard can it be?).

2 - how about a program that prints all the numbers that are multiples of 3 (examples 6, 9, 12, etc) bellow 30?

3 - Can you make the previous exercise without declaring floating point numbers (using only type casting, that is explained in this video)?

Have fun! Because learning is meant to be a fun experience. Go for it!




Example 1 used in the video:

example8

Example 2 used in the video:

example9

Example 3 used in the video:

example10

Example 4 used in the video:

example11

Example "drawing sprites & collision" in Python


This example uses python 3 with a Raylib (https://www.raylib.com) wrapper (https://pypi.org/project/raylib/) that uses CFFI API static bindings (this is the fastest approach, and keeps the code as close as possible to the original C, which I feel is the best approach when using a C library).

Create a folder called "resources" (in the same directory as your code) and place the two images (provided bellow) there.

hero_shipufo1


Here is the Python sample code…



example12

Example "mouse wheel input" in Python

This example uses python 3 with a Raylib (https://www.raylib.com) wrapper (https://pypi.org/project/raylib/) that uses CFFI API static bindings (this is the fastest approach, and keeps the code as close as possible to the original C, which I feel is the best approach when using a C library).

https://www.raylib.com/examples/web/core/loader.html?name=core_input_mouse_wheel

The original C example, edited for easier comparison:

example13

The Python version:

example14

Example "mouse input" in Python

This example uses python 3 with a Raylib (https://www.raylib.com) wrapper (https://pypi.org/project/raylib/) that uses CFFI API static bindings (this is the fastest approach, and keeps the code as close as possible to the original C, which I feel is the best approach when using a C library).

https://www.raylib.com/examples/web/core/loader.html?name=core_input_mouse

The original C example, edited for easier comparison:


example15

The Python version:

example16