pikuma
pikuma
  • 28
  • 710 599
Understanding Bit-Shifting Operators
This video is an extremely beginner-friendly introduction to how bitshifting works & how bitshifting was useful in older game programming code.
We'll start by taking a look at the math behind positional notation, and how bitshifting in code can be used as multiplication and division by 2.
We'll also look at some examples of bitshifting in the source code of Wolfenstein 3D (github.com/id-Software/wolf3d).
Chapters:
00:00:00 Introduction
00:02:40 Counting numbers
00:08:23 Multiplication in base 10
00:14:34 Division in base 10
00:19:56 Multiplication & Division in base 2
00:29:27 Shifting left & right in older CPUs
00:36:12 Examples of code
00:47:13 Arithmetic vs. logical shifts
00:54:13 Relevance of bit-shifting nowadays
For comprehensive courses on computer science, retro programming, and mathematics, visit: www.pikuma.com.
Also, don't forget to subscribe to receive updates and news about new lectures and tutorials:
ua-cam.com/channels/8GR0g1deJB_gxWxi_vuxhA.html
Enjoy!
Переглядів: 1 399

Відео

Creating a Game Loop with C & SDL (Tutorial)
Переглядів 46 тис.Рік тому
This video is a beginner-friendly introduction on how to create a game loop using C & SDL. We'll start by discussing how to install SDL on Linux, macOS, and Windows, and we'll then proceed to create a very simple C application that uses SDL to control game objects. We'll briefly discuss how to create an SDL window, render simple objects on the screen, cap our framerate, and achieve framerate-in...
Triangle Rasterization
Переглядів 23 тис.Рік тому
This video is an introduction to how triangle rasterization works. We'll start by discussing a parallel algorithm for polygon rasterization based on an article written by Juan Pineda in 1988. We'll review the basic algorithm and implement a simple version using C & SDL. But more than just a simple rasterizer, we'll cover some other important ideas in this video: - Rasterization rules (top-left ...
My Top-3 (Retro) Linux Distros
Переглядів 4,5 тис.Рік тому
This is a very short video in response to @Akitando about my top 3 Linux Distros of all time, excluding the one I currently use. This is not really a very useful or informative video since I've decided to list the 3 distros that were the most important historically in my professional life. They are not the most powerful or the most interesting distros out there, but they were the ones that got ...
Verlet Integration
Переглядів 22 тис.Рік тому
This video explains Verlet integration and some other important numerical methods in the context of game programming. We'll start by learning how numerical integration works. The first numerical integration we'll review is called Euler method, and it's a beginner-friendly way of understanding about simulating movement. Euler integration is the most basic numerical integration technique, and it ...
Voxel Space (Comanche Terrain Rendering)
Переглядів 24 тис.Рік тому
This video explains one of my favorite algorithms ever: The Voxel Space engine. This technique was used to render the terrain in the Comanche: Maximum Overkill game. We'll start with a high-level overview of the technique, and proceed to write a very short implementation using C and a graphics framework called DOS-Like. Source code: github.com/gustavopezzi/voxelspace DOS-Like framework: github....
How C++ Vector Works
Переглядів 20 тис.Рік тому
In this video, we'll take a closer look at C vectors (STL implementation of a dynamic array). We'll learn how C vectors are implemented, and code a very simple custom class with the absolute minimum needed from a dynamic array data structure. std::vector is a sequence container that encapsulates dynamic size arrays in C . The elements are stored contiguously, which means that elements can be ac...
How Retro Video Game Graphics Work
Переглядів 14 тис.Рік тому
This video is a light conversation about how old-school video game graphics work. We discuss how popular arcade machines and other game consoles from the 70s and 80s display graphics on the screen. Special mentions to early Arcade, the Atari 2600, and the Nintendo Entertainment System. Pong Simulation at Circuit Level: www.falstad.com/pong/index.html Atari 2600 Programming with 6502 Assembly: p...
Linear Collision Resolution in 2D Game Physics
Переглядів 10 тис.2 роки тому
In this video, you will learn a game physics technique to resolve collisions between rigid bodies. We'll learn the linear impulse method, used to resolve collisions by applying linear impulses to the bodies that are colliding. For a full course on 2D Game Physics, visit: courses.pikuma.com/courses/game-physics-engine-programming Chapters: 00:00 Introduction 02:09 The Impulse Method 03:19 Collis...
Tools to make a Game Engine in C++
Переглядів 50 тис.2 роки тому
This video is a summary of my favorite C libraries and dependencies to create a game engine from scratch. Game development has always been a great helper to get my students motivated to learn more about more advanced computer science topics. Creating a game engine is a great opportunity for us to grow as programmers. Links: Create a 2D Game Engine with C : courses.pikuma.com/courses/2dgameengin...
3D Software Rendering Graphics Pipeline
Переглядів 19 тис.2 роки тому
This video goes over the stages of the graphics pipeline I like to use in my 3D software rendering projects. One of the first things game programming students read in most graphics books is the famous "Graphics Pipeline." Surprisingly, the term confuses some programmers, especially because most books already present more complex pipelines used by OpenGL, Direct3D, and Vulkan. That's why I decid...
Vector Rotation (Derivation & Geometric Proof)
Переглядів 11 тис.2 роки тому
Most game programmers know that we can use a matrix to rotate a vector around the origin. They also probably know that a vanilla rotation matrix looks something like this: [ cosθ -sinθ ] [ sinθ cosθ ] But, do you want to understand where these formulas come from? In this video, we'll learn how to derive the formulas for vector rotation in 2D, including the mathematical geometrical proof of how ...
Perspective Projection Matrix (Math for Game Developers)
Переглядів 48 тис.2 роки тому
In this video you'll learn what a projection matrix is, and how we can use a matrix to represent perspective projection in 3D game programming. You'll understand the derivation of a perspective projection matrix in 3D computer graphics. The matrix I'll derive is as used by left-handed coordinate systems like DirectX (OpenGL uses a right-handed system). In perspective projection, objects that ar...
Matrix Multiplication (A Simple Review)
Переглядів 7 тис.2 роки тому
This video explains how to perform matrix multiplication. This is a simplicity-first overview of the multiplication algorithm and it's aimed at programmers and game developers. For comprehensive courses on computer science, programming, and mathematics, visit: www.Pikuma.com. Don't forget to subscribe to receive updates and news about new courses and tutorials: ua-cam.com/channels/8GR0g1deJB_gx...
Collision Detection with SAT (Math for Game Developers)
Переглядів 22 тис.2 роки тому
In this video, you'll learn a collision detection algorithm called the "Separating Axis Theorem." This quick tutorial will explain the intuition behind the SAT algorithm, and give you an example of how to implement polygon-polygon collision using the Separating Axis Theorem in the context of physics engines. The SAT is probably one of the most popular collision detection algorithms out there, t...
Math for Game Developers: Fundamentals of Calculus
Переглядів 21 тис.3 роки тому
Math for Game Developers: Fundamentals of Calculus
Why do we use SDL with C & C++?
Переглядів 41 тис.3 роки тому
Why do we use SDL with C & C ?
C++ Objects: Stack vs. Heap
Переглядів 7 тис.3 роки тому
C Objects: Stack vs. Heap
Math for Game Developers: Why do we use 4x4 Matrices in 3D Graphics?
Переглядів 65 тис.3 роки тому
Math for Game Developers: Why do we use 4x4 Matrices in 3D Graphics?
Introduction to Object-Oriented Programming with Lua
Переглядів 18 тис.3 роки тому
Introduction to Object-Oriented Programming with Lua
Installing Lua on Windows Terminal & VS Code
Переглядів 84 тис.3 роки тому
Installing Lua on Windows Terminal & VS Code
How to link SDL 2 with Visual Studio on Windows (2021)
Переглядів 44 тис.4 роки тому
How to link SDL 2 with Visual Studio on Windows (2021)
GDB Debugging: How to Debug a C/C++ program
Переглядів 36 тис.4 роки тому
GDB Debugging: How to Debug a C/C program
How to Install Lubuntu Linux?
Переглядів 2,5 тис.4 роки тому
How to Install Lubuntu Linux?
What is Bash Scripting?
Переглядів 46 тис.4 роки тому
What is Bash Scripting?
UNIX vs Linux: Differences & Similarities Explained
Переглядів 14 тис.4 роки тому
UNIX vs Linux: Differences & Similarities Explained
What is the Linux Operating System?
Переглядів 6 тис.4 роки тому
What is the Linux Operating System?
Master Lua Programming (Course Promo)
Переглядів 4,2 тис.4 роки тому
Master Lua Programming (Course Promo)

КОМЕНТАРІ

  • @SiuLoong
    @SiuLoong 7 годин тому

    Mate??

  • @user-wt2sg8kg1x
    @user-wt2sg8kg1x День тому

    great explanation

  • @peterjansen4826
    @peterjansen4826 3 дні тому

    My big objection to Ubuntu these days: Snap. I am ok with it being an option, I am ok with Canonical offering it, I am not ok with removing packages and then installing the Snap, I am definitely not ok with the developers writing some function to automatically use the Snap install command when the user types "apt install <program>" and that for fundamental programs like the Firefox browser. Not cool in my book (not respecting users their decisions, one reason why I ran away from Windows) but mostly my objection is that it costs too much effort for me as tthe user to fix my system. Usually the Snap is much slower (it seems that Flatpak does a bit better and I would love to see a comparison between these both and nix), it requires more memory (not a huge deal but it does matter) and of course there are problems with breaking theming though I am willing to believe that that now mostly has been solved. Other than Ubuntu I don't really care that much but I do need a system with more recent updates because I like to play games. I have been on Arch in the last 5 or so years, I like it but it isn't perfect (issues with some packages not being done the way I would prefer it). I would also be fine with Fedora or SUSE. The distro is just a starting point and you can make any distro work, it is just about which distro gives you the least amount of work for your usecase. Maybe a tool like Distrobox can help in cases where you do have a problem, not sure. For example the install-process of MATLAB being a hell for Arch-users (due to the developer making some weird choices).

  • @peterjansen4826
    @peterjansen4826 3 дні тому

    Guys, can we agree that getting ready to play with SDL on Linux and macOS is a lot easier compared to doing that for Windows. 😆Just saying, Microsoft can learn a lot from the open source world (macOS is based on FreeBSD, hence the same workflow) about userfriendliness for software-management. Just typing one command to install a text editor (vim) or an IDE and SDL2 and 10 seconds later you can already start your project. On Windows you first have to find the right websites for both Visual Studio and SDL, you get a very slow install process for Visual Studio (I never understood why that takes so long) and when you finally get ready to start your project you have to puzzle how to get it done in the GUI while you are a beginning programmer and barely know what all of that means.

  • @peterjansen4826
    @peterjansen4826 3 дні тому

    On Arch anyone who has a general gaming-setup has SDL2 too (used by many games) and the name of the package is sdl2 so people can figure that out. :)

  • @RelativeResonance
    @RelativeResonance 4 дні тому

    I think we could reduce calculations by prioritising the normals, that are similar in direction to the vector that goes from object A to B

  • @ViniciusSoaresBatista
    @ViniciusSoaresBatista 4 дні тому

    Your passion for teaching is inspiring

    • @pikuma
      @pikuma 4 дні тому

      Grande Vinícius. O tópico ajuda nesse caso. :)

  • @davidadewoyin468
    @davidadewoyin468 5 днів тому

    Just an awesome explanation

  • @Happymacer_P
    @Happymacer_P 6 днів тому

    FWIW, shifting is common in microcontroller code as often we need a particular bit at a different location in the byte.

  • @Happymacer_P
    @Happymacer_P 6 днів тому

    Beautiful explanation thanks… any chance to do a video on using logic to do arithmetic?

  • @pedrocosta1742
    @pedrocosta1742 8 днів тому

    Hallelujah😄

    • @pikuma
      @pikuma 8 днів тому

      Grande!

  • @StiffAftermath
    @StiffAftermath 9 днів тому

    Have you seen John Lin's voxel engine yet? It is mind-blowing!

    • @pikuma
      @pikuma 9 днів тому

      I was not aware of that project! Amazing. Thanks for the tip.

    • @StiffAftermath
      @StiffAftermath 9 днів тому

      @@pikuma thank you for your awesome work! I love voxel tech! If you see it, I'd love to hear your thoughts!

  • @luisf.r8146
    @luisf.r8146 14 днів тому

    I dont understand why exactly we have to test a->b and b->a. In wich case theres a collision between a and b and not between b and a?

  • @IshakHeor
    @IshakHeor 15 днів тому

    Thank you Gustavo !!! you are an incredible teacher, you have thought me so much... I am AAA game engineer, but I am still learning and will be. Started the Atari course and took the GameEngine one, and the rest will follow ;) If you don't mind a suggestion for your next course( very excited for the PS one ) GameBoy programming would be incredible. Cheers!

  • @MrNickolay1986
    @MrNickolay1986 16 днів тому

    I don't understand how just dividing by w you can normalize everything. If I have this vertex { -2.0, 0.0, 0.5 } and my projection parameters are fov = 60, aspect = 1.0, Znear = 0.1 and ZFar = 1000, I get w = 0.5. Projected X will be -3.46 and obviously, if you divide -3.46 by 0.5 it's the same as doubling it.

  • @losertrader4925
    @losertrader4925 17 днів тому

    I get it now. The bigger the field of view, the bigger the objects 😂

    • @pikuma
      @pikuma 17 днів тому

      😱 Oh no! Hahaha.

  • @parinamais
    @parinamais 18 днів тому

    being able to find y' at the end made me so happy 😄 you are an awesome teacher!

    • @pikuma
      @pikuma 18 днів тому

      Told you! :) Great one.

  • @parinamais
    @parinamais 18 днів тому

    your classes are amazing!! ty very very very much

  • @johnz6877
    @johnz6877 19 днів тому

    Wolfenstein 3d and Comanche came out in the same year, but you would never guess by just looking at them.

  • @parinamais
    @parinamais 19 днів тому

    this is amazing, you are a great teacher!! ty

  • @bruce8217
    @bruce8217 20 днів тому

    Great video although already seen it on your personal website. Would love it if you did a video on what skills are needed as a Game Developer maybe a high level overview even if it is just pointing to other videos you already done so there is some sort of pathway for people. I've seen a few students who have done a 'Game Design Degree' and they only seem to get taught the bare essentials of C# and then the focus is on Unity / Modelling / Animation and Rigging. Anyway here is my wishlist for what video you should do next (either paid or free) Data Structures and Algorithms and applying it in a Game. Pointers.. maybe a brief video on that I've purchased most of your courses and they are great but I'd love it if you made your next one focusing on portable hardware. I'd personally love it if you did something with one of those Tamagotchi devices.. heck even a Furby lol or a Pocketstation or Dreamcast VMU but I'd get it if you wanted to do something with more broader appeal like a Gameboy. (in ASM ofc not gamemaker stuff a lot of people are using for Gameboy games thesedays.)

    • @pikuma
      @pikuma 20 днів тому

      Hm, great comment. I'll see what I can do. 🙂

  • @atesquik
    @atesquik 21 день тому

    Thank you so much for this video! I needed to make rope physics for a project and at first i didnt understand anything from wikipedia but this video made it really simple.

  • @kera9798
    @kera9798 22 дні тому

    great stuff

  • @justinmonroe8683
    @justinmonroe8683 23 дні тому

    So I think I ununderstand, it looks to me this specific transforming by translation using matrices, with the added dimension represented by one, being a way to regulate so that unit vectors remain accurate, which is reliant upon origin. At least that's what my brain allowed this very early morning 😂

  • @yuriorkis_scream
    @yuriorkis_scream 24 дні тому

    Great work! Thank you for detailed explanation of such an important thing for all people who doing some staff in computer graphics!

  • @MohamedHassan-iq6rk
    @MohamedHassan-iq6rk 24 дні тому

    COOLEST thing heard this Year ♥

  • @hobbit125
    @hobbit125 24 дні тому

    Creating a Game Loop in an extremely old version of C & SDL.

  • @stormbringer1330
    @stormbringer1330 25 днів тому

    Wonderfull explanation of verlet integration. Clear, simple and explicit. Thanks a lot for this.

  • @Chevifier
    @Chevifier 26 днів тому

    Im gonna try doing this with compute shaders

  • @DogeOfWar
    @DogeOfWar 26 днів тому

    when you added SDL2.lib and SDL2main.lib to the dependencies, how did you know to add them? if I were to do this myself from scratch where would I be able to see or discover "oh, I need to add SDL2main.lib in addition to just SDL2.lib"?

  • @DogeOfWar
    @DogeOfWar 26 днів тому

    Why is it not considered redundant effort by WIndows MSVC projects to have to manually add the lib to BOTH the library directories AND the linker? what is the reason for it not being able to deduce the linkage based on the included libs?

  • @HartleySan
    @HartleySan 27 днів тому

    At first, I didn't know where you were going with the shearing, but you blew my mind there at the end. Bravo!

  • @davidemarchese7569
    @davidemarchese7569 27 днів тому

    if the objects in my scene are subject to acceleration will the method still work?

    • @pikuma
      @pikuma 27 днів тому

      Absolutely. All the forces of your system will result in an acceleration, which will change their velocities, which will then change their position. Collision check happens after the pisition was updated and the resolution proceeds from there.

  • @tullman3craggs102
    @tullman3craggs102 28 днів тому

    feel when now its github download link, and theres no lib folder

  • @StfuSiriusly
    @StfuSiriusly 28 днів тому

    nice video but the audio issues are crazy

  • @BigCatOfficial
    @BigCatOfficial Місяць тому

    love the way you go through things. true understanding and logical connection of related topics. fantastic content

  • @namdao2672
    @namdao2672 Місяць тому

    now it all make sense thanks to you

  • @mrdkaaa
    @mrdkaaa Місяць тому

    Ok, for whatever reason, instead of tracking the vector, you're looping through all the pixels in the bounding box (And repeat ten times what a bounding box is. Everything so insanely long winded.) and wasting time with the cross product. Then when you get to optimization with a fixed step, you still keep going through all the X's. It's so painful to watch.

  • @HanatosHD
    @HanatosHD Місяць тому

    Oh my god, thank you so much for your explanation. I'm making a video game about a sewing mechanic and I needed to simulate the rope. This help a lot

  • @vitoralmeidasilva
    @vitoralmeidasilva Місяць тому

    Aleluia! :)

    • @vitoralmeidasilva
      @vitoralmeidasilva Місяць тому

      Btw, here is the Makefile that I used to compile the program using a Linux machine: build: gcc *.c `sdl2-config --libs --cflags` -lGL -lGLEW -lm -lpthread -o voxel clean: rm voxel run: ./voxel

    • @pikuma
      @pikuma Місяць тому

      Feito! 🙂👍

  • @laminak1173
    @laminak1173 Місяць тому

    It reminds me the time of demomakers in the 90s

  • @designordu159
    @designordu159 Місяць тому

    install on linux: quite easy. install on mac: hmmm! easy too install on windows: incantations n magic spells, windows need true love kiss to work

  • @FernandoNomellini
    @FernandoNomellini Місяць тому

    Muito bom !

  • @GoatsOnAParachute
    @GoatsOnAParachute Місяць тому

    This video is missing a huge component: how to calculate the collision normal n. For spheres, I think this is the difference vector between the two centers of the spheres at time of collision.

    • @pikuma
      @pikuma Місяць тому

      This is part of collision detection and collision information, which is shape-dependent.

    • @GoatsOnAParachute
      @GoatsOnAParachute Місяць тому

      @pikuma But for the spheres example in this video, it's what I said above correct?

    • @pikuma
      @pikuma Місяць тому

      @@GoatsOnAParachute Yes. Spheres are easy to detect and find the collision info. 🙂👍

  • @burntt999
    @burntt999 Місяць тому

    oh dear lord.. 3 hours whew. i'll be back! SUPER happy that this is online.. i've been wanting to find a place that would teach me the voxel graphics/engine/ whatever. bless you sir. but i'm gonna need to start this on a fresh day.

  • @user-lt8id9lv4x
    @user-lt8id9lv4x Місяць тому

    Bro let's contact please