![Andrew Hamel Codes](/img/default-banner.jpg)
- 15
- 142 106
Andrew Hamel Codes
Canada
Приєднався 7 сер 2021
I post a bunch of code related goodies here. Hopefully it doesn't take me long to fill this page with loads of freebies including tutorials / code montages / and interesting demos. Alot of what you see may be available on my GitHub, and some of the live demos may be accessible from my Website. Feel free to check either out or contact me at andrewsgames@andrewhamel.ca! Hopefully I didn't forget anything :)
Sprite Animation in raylib
Here's a basic example of Sprite Animation in raylib. This video does not cover animation states or anything else that would bring it closer to what you'd use for your project: that's for you to figure out!
Just kidding. I will do videos on those too. Subscribe for more!
Source for this video:
github.com/AndrewHamel111/raylib-sprite-animation
My VS Code workflow with raylib:
ua-cam.com/video/xWWqhQ1JnvE/v-deo.html
My video on Tic-Tac-Toe with raylib in C:
ua-cam.com/video/ki5l_It9Q9Y/v-deo.html
Chapters
0:00 Header and Struct Setup
1:32 Equation Demonstration
1:54 Implementation
6:45 Conclusion
Just kidding. I will do videos on those too. Subscribe for more!
Source for this video:
github.com/AndrewHamel111/raylib-sprite-animation
My VS Code workflow with raylib:
ua-cam.com/video/xWWqhQ1JnvE/v-deo.html
My video on Tic-Tac-Toe with raylib in C:
ua-cam.com/video/ki5l_It9Q9Y/v-deo.html
Chapters
0:00 Header and Struct Setup
1:32 Equation Demonstration
1:54 Implementation
6:45 Conclusion
Переглядів: 5 384
Відео
ASTEROIDS in C - raylib demo part 4
Переглядів 1,6 тис.Рік тому
In the last part of my ASTEROIDS series, we tie all the systems together with a proper Game state and some really basic UI. I say it's the last part, but it's not the last video, as I will use what we've built up until now as a foundation for occasional videos on polish / integrating some of the concepts taught in my other videos. Watch Part 3: ua-cam.com/video/60n46KbSvUg/v-deo.html The GIT fo...
ASTEROIDS in C - raylib demo part 3
Переглядів 1,3 тис.Рік тому
In part 3 of my ASTEROIDS series, the player finally gets a chance to defend them-self (not like the Asteroids can actually hurt the player at this point). The player can shoot projectiles that can split larger asteroids and destroy the small ones. Watch Part 2: ua-cam.com/video/abIlGCx_Yq8/v-deo.html The GIT for this project: github.com/AndrewHamel111/raylib-Asteroids My VS Code workflow with ...
ASTEROIDS in C - Raylib Tutorial Part 2
Переглядів 2,9 тис.Рік тому
In part 2 of my ASTEROIDS series, we're adding in the player controller with the iconic acceleration and deceleration. There's a brief time-lapse at the end showing some of the refactor I did between parts, and some of UA-cam's free music (it's gotten a lot better than it was like 5 years ago). Watch Part 1: ua-cam.com/video/abIlGCx_Yq8/v-deo.html The GIT for this project: github.com/AndrewHame...
ASTEROIDS in C - Raylib Tutorial Part 1
Переглядів 18 тис.Рік тому
In anticipation of HYPER METEOR getting it's Steam release, I am tackling our first Raylib mini-series! We're setting out to build an asteroids-like shooter game. The scope for this is fairly limited: we want asteroids spawning and splitting, with a player controller that can move around the screen and shoot projectiles. We'll tie the whole thing together with a health bar and a score, and some...
Drawing SPRITES in Raylib
Переглядів 10 тис.Рік тому
Raylib has some very handy shape drawing functions, but most games will require the use of hand-made textures. Assuming you've bundled all your sprites together on an atlas, this video will help you to discover most of the Texture drawing functions in Raylib, and we get a little peak into how we might be able to animate these sprites. In a follow up video, we'll apply what's covered here to cre...
Easy SCM in VSCode with Local Repositories, Local History, and GIT
Переглядів 938Рік тому
In this video, we cover the Local Repository and Local History features in Visual Studio Code, as well as show how to publish a branch to GitHub. I also occasionally show GitHub Desktop as a reference. A reminder that a GitHub account is COMPLETELY FREE, and you can always make repositories private. However if you're working with materials that you do not have the rights to distribute, you may ...
Refactoring my Apple Game into MULTIPLE C Source Files
Переглядів 2,6 тис.Рік тому
In all my Demos up to this point, we've done everything in a single source file. No custom headers and no extra source files. Today we are following up the previous video on creating a Visual Studio Code Task-ready template which supports multi-file work. We're taking that template and using it to split up the source from my AppleCatch video into multiple files. We'll see there's some refactors...
Unlocking VSCode's power to make GAMES in C
Переглядів 21 тис.Рік тому
In all my Demos up to this point, we've done everything in a single source file. No custom headers and no extra source files. Today we use the VSCode sample project as a starting point directly from the raylib GitHub repo to create a template for multi-file projects we can use moving forward. In the next video, we'll take that template and use it to split up the source from my AppleCatcher vide...
Making the most COMMON "First Game" In Raylib with C
Переглядів 6 тис.Рік тому
If you've taken a game-development class, you may have seen a project like this. Whenever I give a demo of beginner programming to someone, I usually use this project as an example. There's a few elements that make this a really simple project idea: the "player" movement doesn't need to be bounded, since it is naturally bounded by being based on mouse position. It also tackles a very simple exa...
C Language Overview
Переглядів 2,5 тис.Рік тому
For those who have seen some of the demos on this channel but weren't totally familiar with the C language, this may help to cover some of the important basic language concepts. Still trying to work out the audio.. I think the volume is good now but I'm not happy with the quality. It's not an issue with the mic, but rather the rendering. C Language Reference: en.cppreference.com/w/c Recommended...
Making Tic-Tac-Toe in Raylib with C
Переглядів 1,6 тис.Рік тому
This video could be considered a sequel to the Minesweeper video, and perhaps the birth of a series? Nearly every comment on the previous video was overwhelmingly positive and it seemed there was a lot of interest. This video poses alot of questions on what YOU want to see, so please try to answer all of them in your comment below! They've also been summarised below. Please leave any suggestion...
Making Minesweeper in Raylib with C
Переглядів 9 тис.2 роки тому
This video is another casual code-along video similar to the Paper stacking demo, perhaps this time with a bit of a better pace. If you're reading this, I'd like to apologize for the poor quality of the video. I have improved my recording setup and future videos should look a little better. As will be the case on all of these videos, please leave any suggestions or corrections below and I will ...
Getting Started with Raylib - C Tutorial
Переглядів 56 тис.2 роки тому
raylib is a simple and easy-to-use library to enjoy videogames programming. This is the way that the creator of my favourite C API, raysan5 describes his creation. In this video it's a quick "getting started" to explain the basic raylib example and a quick sample of a few of the api's most important features, being textures and sound. Raylib is different to a lot of stuff you've heard of and si...
raylib Demo - Paper's Please Paper Stacking
Переглядів 3,2 тис.2 роки тому
In this video I take a casual / chat-along approach to building a random demo in raylib. The demo I build is a recreation of one of my first raylib demos from a few years ago when I first started learning to use raylib. The source code for the video can be found here, as well as an interactive web build of the demo. github.com/AndrewHamel111/papers-please-stack
Randy that finishes games
How did you know Randy was my real name?
@@andrewhamelcodes712 you won't believe this
Subscribed .
hey, not sure if you address this in a different video but in this part of the code: velocity = Vector2Rotate(velocity, (float)GetRandomValue(-ASTEROID_RANDOM_ANGLE, ASTEROID_RANDOM_ANGLE)); doesnt GetRandomValue only accept integers but you are using floats so theres no rotation or its either -1 or 0 in radians
I think in this case GetRandomValue should have no problem downcasting the -30.0f and 30.0f to ints as -30 and 30 respectively, but you are right that we won't get a proper float value back, it'll just be an int casted back to a float. Then of course it also means that the rotation should be very wrong, it is indeed surprising that the asteroid spawning + splitting implemented later seem to work at all. Normally you'd have [0, 2*PI) of values, but since it's an int we only have {0, 1, 2, 3, 4, 5, 6}. For this simple of a game it seems to work fine, but this is definitely the wrong way to do it!
Good videos
Awesome tutorial, thanks. Could I ask why you are passing the player by pointer in PlayerUpdate but by value in PlayerDraw? Is it because we don't care about modifying the player struct in place when we draw it as we just need the information to pass on to the library?
You're pretty much on the nose: passing by pointer allows the function to modify the struct, which is something I want only Update to do. By passing a copy instead of a reference to Draw, I can enforce that.
Perfect, thanks! I'm a C++ dev by day, so to achieve the same thing in that language I would pass the struct in by const reference, which as far as I am aware isn't possible in C. It's been really interesting to go through these videos and see the differences in approach between the two languages
Incredible video and love the explanations of your entire thought process. One of the best programming videos I've ever seen.
When I start debugging (when using GuiButton() from raygui) it gives me an error "undefined reference to GuiButton" even though I followed all of your steps
Try switching BUILD_MODE from RELEASE to DEBUG at the top of the Makefile. This should cause the -O0 flag to be used when compiling which will prevent the function from being inlined which *may* be what happened when you built. It's hard to say what causes the optimizations, when in doubt I'd switch to debug mode wherever applicable.
@@andrewhamelcodes712 still wont work :/
@@andrewhamelcodes712 I got it to work!
Hello sir. Will you do more C and raylib tutorials? Maybe C++ too? Thanks in advance.
In time I'd really like to do more. It's hard to say when the next will come
I enjoyed following along. I noticed there is a bit of a ghosting effect coming from the asteroids. I'm seeing it in your recording too. Seems to have been fixed in the later parts of the tutorial. Do you know what is causing it? Or may be I am seeing stuff.
I think that's just an artifact of the recording, I didn't notice it before and now can't unsee it 😭
can't install in Macos, thanks for nothing, crap software
VS Code works on MacOS, as does Raylib and Make.. the only crap software mentioned here is Windows!
I much prefer having update and draw be the same function, because traversing all entities on both update and draw means losing out on them still being in the cache. Granted some things can't be drawn at the same time they're updated, but it's probably a non trivial amount, and having them as seperate functions forces your hand.
The choice to separate them like this was made for readability, which in my opinion always comes first until you actually profile on the target platform and determine that such an optimization is needed. Especially when it comes to beginner tutorials, readability is a boon!
Will there be more C raylib tuts/projects? Or can you recommend some other sources?
Great tutorial, Andrew! It's clear you have a great understanding of game logic and design. Haven't checked your later tutorials yet, but I'd find it helpful if you explained more of the logic of the game design, i.e. how you 'knew' to check for nearby mines. In my own experiments, I get stuck on this kind of thing, not so much the coding (there are tons of general C programming books, tutorials, etc.!) as figuring out the flow of the game logic/design. Sorry if that isn't described well!
I understand your comment perfectly. I have to think about this.. I have really struggled to decide what to cover on this channel, but this gives me some ideas.
This is awesome! May I upload my version of the game to my Github account?
I have no ownership over what you create when you watch these videos: share away!
Well worth a subscription!
Thanks for making Raylib videos. I'm not sure what audience you are aiming, but I think that emphasizing the prerequisites would help a lot. Maybe also a simple flowchart showing the relations between the different modules and a simple flowchart showing how the game works. It would certainly help me a lot! At 10:38 you mention, that getting the value via a pointer is faster than calculating - are you sure? In a video Eskild Steenberg "How I Program C" he states that memory is very slow compared to the calculation speed...
It is very nuanced.. they say "measure don't guess" and I did a bad thing and guessed! It varies widely depending on many things, so I'd say make a choice based on what's most readable. Once you get far enough in any project where you're looking at deployment, *that's* when performance should become a concern.
@@andrewhamelcodes712 Thanks for answering and thanks for making videos about Raylib. As far I have discovered, I have to use Image for the creation of graphics and Texture for showing the graphics... For the moment, I writing a small relational database and using Raylib as a graphical interface and it goes well. It's not Raylib that is my biggest hurdle, but the timing for the keyboard and the cursor movement, but it's almost there, so I think, I solve the timing issues. I have two years of C99 experience.
You mentioned Lazarus. I'm actually looking to use Raylib to create an IDE similar to VS and Delphi. The guy who made C# made Pascal :) Delphi has Skia.
It's like Arduino code but for gaming. Nice.
Thanks for a great video about Raylib and sprites and I hope you will make more. From a pedagogical perspective, viewers have to have some understanding of C and basic geometry to follow your videos. I'm quite new to Raylib and C, but the more I learn about Raylib, the more I like it and it shines through, that Raysan have a teaching perspective. Although you have a ton more of C knowledge than I, I dare to ask, why you are not writing: Rectangle *mem = malloc(sizeof(Rectangle) * length); ? :o) I use Raylib as graphical interface for a small relational database with editing, printer and of course a cursor insert/overwrite - tricky for me.
It depends on the background you have, but personally I find much easier to use C++ vectors and not to worry much about memory allocation/deallocation. If for some reason your vector index runs out of range turn on sanitizers and you will immediately find the bug.
I'm not sure where or why I got the impression that explicit casting the return of malloc was necessary.. but it wasn't until veeeeery recently that I learned it's actually bad form to use explicit cast there. It's a great correction to point out.. if only UA-cam didn't delete annotations like a hundred years ago 😂
A great suggestion for those using C over C++! I also do not suggest people directly use heap memory in C++ for simple collections like this :)
@@perelmanych Although I dumped C++ two years ago after learned inheritance, composition and all the basic stuff, I assume sanitize have something to do with freeing resources...
fasting the video is acceptable for 1 or 2min, we can't continue watching 1h of that, if not necessary
HI! I cloned the repo on github and everytime I go and press F5 the terminal says the following: "The terminal process failed to launch: Path to shell executable "C:\RaylibSHIT\cTEST3 aylib-VSCode-Template\mingw32-make.exe" does not exist." Anyone here knows how to fix it?
Quite a well done concise C intro..... one other thing is about increment prefix and postfix; ++i; i++; ++i; // would increment 'i' right a way // i++; // would increment 'i' not now but on the next line of code // I'm a bit rusty with my C but might play around with it and raylib in the near future.
Your videos are great, and your class is one of the best, seriously, I've watched a lot of videos on the topic and my understanding is shallow. Please continue with your raylib tutorial videos, they help a lot, you gained another subscriber. If you want the next topic to show here, it would be a top one about GObject, which is a library for C where you work with OOP using C and you can use Python, Java, among others .....
I have never heard of / seen GObject! Seems interesting..
This was a great series of videos. I really appreciate seeing how other people structure their code.
4:11 You'd be surprised how many 3 hour coding streams I have watched lately, most of it being Jonathan Blow writing something I don't even understand.
Is `Win32` the only configuration available on Windows? There's no x64 config available?
I do have a question? I noticed in video the C standard library has memory management functionality? Interesting as I thought C didn't have memory management? You always hear about that when thinking of using the "C" language. Watch out, "You'll have to manage the memory yourself.
This is exactly what it means: in C you manage your memory yourself, while in high level languages it's usually done by the language itself via something called "Garbage Collector"
I second what @jeffersonsa4200 wrote. Loving the vids! Keep them coming.
Really enjoyed this tutorial. Almost have it all working expect the multi-file part. When attempting those changes I was getting a linker error? I'll try reviewing 12:41 and 13:55 again. I am on a MacBook.
i tried to compile on a proyect from scratch but i didn't work
Hi Andrew, I am a horrible programmer. Been programming with JavaScript & Python for Django and now learning React with JavaScript for 2 years now. I am interested in deepening my knowledge in programming. How much of a learning curve is it to learn C with Raylib for making simple 2D games as a hobby. When you start your project do you have to create a make file? Also, can you run Raylib on vs-code?
Hi, I found learning quite easy and fast since C is a very simple language, at least in my opinion. You already know most of the stuff if you know JS but you are to learn concepts of low-level languages, e.g. pointers, stack and heap, allocating memory and types. Raylib is just a library where every single function is described in the cheatsheet on their website. They also have a ton of examples that you can learn from, both 2D and 3D. Make is a separate tool that‘s not part of the language but it‘s very convenient to use because the C compiler commands are very long. Once you have a Makefile you only need to type „make“ in the terminal to compile the game. So you can also develop it in VSCode.
@@thesergey I played around with C and C++ using Visual Studio Code. Did the basics of conditionals, fizz-buzz, etc, etc, to get a feel for the language. Found out I didn't like C++. You have to write so much just to express an output. I actually like C because it is simple. BUT i never once made Make files before. BUT it's apart of the learning process. I guess I wanted to pick C and make a game as a hobby. Because I hear learning JavaScript as one of your first programming languages can actually harm your growth progress in becoming a good developer. Thank you for your reply I think I will go with C and try and make a very small 2D game. Figured if I invest 1 hour per day this should be good enough for making a game. Thank you once again!
@@DevlogBill Great to see that it's still relevant, haha. Good luck:
This is not a tutorial coz you are speeding up the video while coding, nothing can be understood in the flow and functionality of the code here.
This comment haunts me
Thanks a lot.
This is a very kino video, thank you so much for this. Trying to clean off the rust I have and trying to learn something and I really appreciate the intro you've outlined. Only note is that I believe with the newer raylib you have to define LoadMusicStream variables with "Music" type like: Music music = LoadMusicStream("music.ogg"); Forgive my lack of vocabulary.
Muchas gracias mister andrew....
A bit late to the party here but I want to tell you that this video is great!
ty! <3
Hello sir, thanks for these videos I find them very helpful, I copied your latest template for 4.5 but when I hit F5 it says that "launch: program does not exist launch json" even tho Im using the same launch.json files in your template, could u pls help me with that?
similar problem. ray5.1. followed tuto, then tried files, getting error no raylib.h, no program etc.
Ça parait trop facile mercii mais jai un probleme je trouve que des fichiers .zip ça veut dire je doit faire la configuration manuelement et je ne sais pas comment please help
ca
Would you mind sharing the other assets, as it seems you only shared the source code.
Instead of iterating through the array of asteroids It might be better to have a variable for the current amount of asteroids so you can just index into the array with the asteroidCount + 1 to get a open spot for a new asteroid. With bounds checking of course to make sure it's not over the size of the array. It would also allow to not need to check whether a asteroid is active or not every frame because you can just update or draw the array from 0 to asteroidCount - 1.
This is true until you destroy an asteroid: as asteroids are destroyed you create holes in the array, so when I want to create a new asteroid I look for a hole in that array. Additionally, this level of optimization is not necessary for something that happens occasionally as opposed to *every frame*. The most important rule when it comes to optimization vs code complexity: "measure don't guess!"
How do I set it up such that it uses MSVC compiler
I have got a question. Why didnt't you use pointers with structs? Isn't that more efficient?
More efficient than what? Technically if I use an array, I am using pointers :)
@@andrewhamelcodes712 managing memory
This doesn't work. As soon as I move the template project to a different directory it'll simply refuse to compile. I've been at this for 2 months, but I still haven't fixed this...
The example / template projects provided in raylib's source will have the paths to important resources (like compilers and raylib itself) as relative paths, meaning they have ../../ etc. to find the location. Make sure to replace these with absolute paths based on where you installed those contents, then you can move the folders whereever.
hello! I'm kinda new in C development. Is there a way to create a general "Entity" that has an update method and then instead of having an array of asteroids, have an array of entities that have different behavior? A way to "simulate" polimorphysm or composition maybe? I mean: Entity entities[MAX_ENTITIES]; for(int i = 0; int < MAX_ENTITIES; i++) { entities[i].update(); } In order to prevent having this: Asteroid asteroids[MAX_ENTITIES]; AnotherKindOfEnemy blabla[MAX_ENTITIES]; // ... more and more enemy types for(int i = 0; int < MAX_ENTITIES; i++) { asteroids[i].update(); blabla[i].update(); // ... all enemy types update() call } thank you in advance
Thanks for this, setting up as a beginner in C or C++ can be a pain if not just using some premade template like with Codeblocks or Visual Studio.
Ah soooooo cool! Learning and loving c, wanted to make more game stuff with it. Happy to find this 🎉