Coding a Simple SFML Game Framework in C++/ SFML

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 206

  • @Naveication
    @Naveication 7 лет назад +253

    Watch out Unity and Unreal Engine... There's a new challenger in town!

    • @Hopsonn
      @Hopsonn  7 лет назад +105

      exactly
      in 2020 LowBudgetHopgine will be the next big thing

    • @kogorek1
      @kogorek1 7 лет назад +6

      Hopson you should do the time travel stuff after completing your engine :D

    • @meowgoesthedog_
      @meowgoesthedog_ 7 лет назад +7

      Crysis 4, bought to you by Hopgine

    • @johnthebun
      @johnthebun 6 лет назад

      Naveication what does he use to code?

    • @skyler948
      @skyler948 4 года назад +1

      @@genie193 the LowBudgetHopgin has been changed to the mouse game engine

  • @ceezymuccheez
    @ceezymuccheez 7 лет назад +5

    Just yesterday I was looking all over RUclips for a series like this, I'm just getting onto my second year at university for my Games development course and this is perfect for me and will really help me out :)
    Please don't stop this series, its amazing

  • @Hopsonn
    @Hopsonn  7 лет назад +26

    lmao this video ends before it begins :S
    Anyways, for those wanting Minecraft or something, check the pinned comment on the "One Week Challenge" video

    • @sutsuj6437
      @sutsuj6437 5 лет назад

      I have an issue with this on github ... ^^

  • @PasaulioValdovas
    @PasaulioValdovas 7 лет назад +8

    Love how simple everything looks when you explain it! Subscribed.

  • @tacowithgiantbeansallover
    @tacowithgiantbeansallover 7 лет назад +27

    This channel inspired me to learn C++. Thank you for the inspiration and keep up the good work!

    • @imagine_big9398
      @imagine_big9398 6 лет назад +2

      One hope youre still trying to learn it :D

    • @V0TION
      @V0TION 5 лет назад

      Still doin it?

    • @tacowithgiantbeansallover
      @tacowithgiantbeansallover 4 года назад +2

      Thanks everyone, i dont know why i didnt get any notifications from the other 2 replies. I did do C++ for a while (about a year), but recently switched to C# and began developing games in the Unity Engine.

  • @firstname4337
    @firstname4337 7 лет назад +27

    man, you type fast

    • @kebien6020
      @kebien6020 7 лет назад +21

      ikr, it almost seems fast-forwarded

    • @TheHHG7
      @TheHHG7 7 лет назад +1

      kebien6020 was just about to make that comment xD

  • @Stan10785
    @Stan10785 7 лет назад +1

    Looks great! Exactly what I was looking for. Just a basic framework to get started. More importantly to see it actually used. So many sites just put together an engine and sign off. I am looking forward to the next step!

  • @agfd5659
    @agfd5659 7 лет назад +42

    I believe "pseudo" is pronounced "sue-dough".

    • @Hopsonn
      @Hopsonn  7 лет назад +15

      Meh, pot-ay-toe, pot-arr-toe

    • @agfd5659
      @agfd5659 7 лет назад +5

      Sorry, I can't help correcting other people. It's like an addiction. :(

    • @harald921
      @harald921 7 лет назад

      Isn't that just what he said though?

    • @agfd5659
      @agfd5659 7 лет назад +2

      No, it sounded like "sue-do". "Do" as in the verb do. And my dictionary suggested only the previously stated pronounciation of the word is correct. On the other hand, I understand that different accents can heavily vary a pronounciation of a word.

    • @Kitulous
      @Kitulous 6 лет назад +1

      "sue-do" is because of his accent. For example, Hopson pronounces "at all" differently as well. That's not bad, that's just another accent. Still a British accent, but not standard.

  • @nephilesi
    @nephilesi 7 лет назад +1

    Hey Hopson, I actually wanted to say that I really appreciate and enjoy your videos and I hope that you can continue to make them and I look forward to your future videos.

  • @BlazertronGames
    @BlazertronGames 5 лет назад +2

    Writing a framework seems really interesting to me. I'm not really interested in making the next big game, I'm just interested in how to make games.
    I have the basics of C down, and I'm playing around with SDL, but I'll probably learn c++ at some point because I just love the idea of abstracting things away into classes.

  • @CVixen
    @CVixen 7 лет назад

    Your voice is pretty sweet, I like how you explain things so its fairly obvious you are learning and not just copying something else, something a few other videos lack.

  • @outsider1st
    @outsider1st 7 лет назад

    Nice project, useful for creating simple games. I like that the source code is written in modern cpp. It's also very easy to read as it's parts are well separated. Good job.

  • @DezBoyle
    @DezBoyle 7 лет назад +2

    The background music is a nostalgia trip XD Love the videos!

    • @Gizego
      @Gizego 6 лет назад

      whats the music plz?

  • @liquidexw
    @liquidexw 7 лет назад

    I love your vids. I am a developer myself, mostly in Java, but that doesn't stop me from learning a lot of various things from your videos. I will have to try out SFML for myself, I'm pretty interested what I can do (yes I know SFML is for C++ but I think it's about the time that I learn another language)
    PS. I like your accent. It really fits this type of video.

  • @praisesamuel3086
    @praisesamuel3086 7 лет назад +46

    The scary thing is this is real time

  • @parjupiter134
    @parjupiter134 2 года назад

    The video that got me back in game developmenta after years of inactivity. Thanks you, dude. :)

  • @Karolis554
    @Karolis554 7 лет назад +1

    Maybe you could implement Entity component system? it is a very flexible way to manage your game entities because it gets rid of inheritance based hierarchy and makes all game objects(entities) made out of components. This is a valuable topic that you might want to look at in the future ;)

  • @technolapin
    @technolapin 7 лет назад +1

    Really instructive

  • @Etredal
    @Etredal 7 лет назад

    Thanks for the high quality videos! This is helping me learn a little C++

  • @StefanGliga48
    @StefanGliga48 7 лет назад

    You sound a lot more lively in this video!It sounds as if you had stagefright in all your previous videos.

  • @iomarzgamedev4962
    @iomarzgamedev4962 4 года назад +1

    i made a game engine in java. it was inspired by your video :D

    • @Hopsonn
      @Hopsonn  4 года назад

      Awesome! Saw you made a video about it too, that was fun to watch :)

  • @Volcarona_
    @Volcarona_ 7 лет назад

    I'm looking forward to this series

  • @amosnimos
    @amosnimos 2 года назад

    Seriously this is great inspiration, I was making all this on my own without much available documentation for a person with no prior CPP experience, having this framework as a reference will be very helpful thanks.
    It's under MIT license so this framework could be modified and used by anyone to build a project and release it? Is their some restriction that I missed?

  • @DebuggedRobot
    @DebuggedRobot 7 лет назад +1

    Great job and good explaination as always !

  • @rcookie5128
    @rcookie5128 7 лет назад +1

    Thanks for the video and the source code!

  • @raphaelbaier6984
    @raphaelbaier6984 7 лет назад

    you should check-out "dear-imgui" its a fantastic c++ lib for drawing guis onto all sorts of stuff

    • @PaprikaYT
      @PaprikaYT 5 лет назад

      Not really nice to implement in sfml (he uses sfml) but there is tgui for sfml which es equally awesome ;)

  • @thearmyofiron
    @thearmyofiron 6 лет назад

    codeblock is indeed a good ide

  • @Latajacaryba
    @Latajacaryba 5 лет назад

    Hey, what's the difference between handleInput() and handleEvent()? Clearly the second proccess events like mouse click or pressing button but what does the first one?

  • @savkepro191
    @savkepro191 7 лет назад +1

    First of all great video and thank you for providing your code, but I was wondering if you could comment your code more so it can be easier to read your code. Thank you!

  • @cmdlp4178
    @cmdlp4178 7 лет назад

    I am working on a game, which lets the user allow to load a binary file(created by a python script out of a text-file:D) via commandline-args which includes textures and other resources, code and worlddata all in one.

  • @kogorek1
    @kogorek1 7 лет назад

    Thank you! Really useful

  • @domainshax5611
    @domainshax5611 7 лет назад +2

    for Random numbers generation on linux, isn't better the /dev/urandom ?

    • @Hopsonn
      @Hopsonn  7 лет назад +6

      I'm not on linux, plus it is better to used standardised libraries rather than platform specific ones.

  • @randomdudewithabeard7593
    @randomdudewithabeard7593 7 лет назад

    Love your work keep it up Bud

  • @bulutsonmez2951
    @bulutsonmez2951 7 лет назад +1

    solid video

  • @chancealexander3398
    @chancealexander3398 5 лет назад

    Yo! I'm using SFML for a school project to make a 2D cannon game in C++. If I were to use this game framework, what file would I actually code in? I'm pretty new to C++ so I don't really understand where I would begin after implementing the framework.

  • @MiSt3300
    @MiSt3300 6 лет назад

    but why not use:
    using namespace std; ??
    And if you want to randomly generate numbers, why not :
    #include
    srand(time(NULL));
    variable.rand%100+100;
    wouldn't that be just easier?

    • @Hopsonn
      @Hopsonn  6 лет назад

      For rand see this channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful
      For using namespace std see stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice

  • @deltav9784
    @deltav9784 7 лет назад +1

    Hello, I am learning to code and am at the very early stages. Could you tell me how you learned to code so well? What programs you used to help you learn, things like that. thx

    • @Hopsonn
      @Hopsonn  7 лет назад +1

      I used a book, and the book had various programming exercises for each topic.
      A good book for this (specifically for C++) is "C++ Primer 5th edition"

    • @xriccardo1831
      @xriccardo1831 6 лет назад

      I'm reading that book lol.

  • @elderadol4395
    @elderadol4395 7 лет назад

    Very good thank u

  • @yan-amar
    @yan-amar 6 лет назад

    One thing I don't get is the difference between update and fixed update, or why you need the latter. If you cover it in another video or comment i would be glad if you point me to it. Anyway, i love all your videos I have seen so far

  • @pako_powr
    @pako_powr 7 лет назад +1

    A question about the fixed update the way it is implemented on your github: Isn't the fixedUpdate function bottlenecking the game loop right now? (resulting in lower fps) ... Also: could this be solved by separating the update and rendering into different threads?

    • @Hopsonn
      @Hopsonn  7 лет назад

      No, the frame rate is not affected by the fixed update
      And yeah, that is one way, but I didn't want to do that for my "simple framework"

    • @protowalker
      @protowalker 7 лет назад

      Basically, rendering should be called in the normal update function while things like physics should be called in the fixed update function. Since the system never pauses to run the fixed update function it doesn't slow anything down.

    • @pako_powr
      @pako_powr 7 лет назад

      Because I saw the while loop around the fixed update I thought that was the case, wouldn't it be more logical to use an if statement instead?

  • @raulcorreia232
    @raulcorreia232 6 лет назад

    Hopson, what books do you recommend to do what you atm?
    Cheers

  • @foka.3kai
    @foka.3kai 7 лет назад +15

    What about creating terraria? :D

  • @AtomicBl453
    @AtomicBl453 7 лет назад

    General use computers can't create truly random numbers, of course. But quantum computers can.

  • @mrstanlez
    @mrstanlez 6 лет назад

    Please help me to load an jpg to opengl as texture using sfml/graphics. Opengl works but without any image is a tragedy. Codeblocks 17.12 under windows 10.

  • @LigmaBaldrich
    @LigmaBaldrich 7 лет назад

    I'm having an issue with my buttons, if I try to use the "getGlobalBounds" function, it works once and can't click. If I use a while loop, it crashes. What do I do?

  • @MaeveFirstborn
    @MaeveFirstborn 7 лет назад

    Hey, I noticed how something said "Args&&...'.
    Is the ... a Code::Blocks thing, or what?

    • @Hopsonn
      @Hopsonn  7 лет назад

      No, CB is an IDE
      Doing the && thing is part of modern C++, and it is called an "r-value reference"
      It's kinda a complex topic, but in the video, I am using it to pass arguments into a function and construct an object in place inside of an std::vector which is more efficient than copying the arguments in.

  • @diverseprogrammer18
    @diverseprogrammer18 5 лет назад

    Welp, I'm just gonna go back counting up one to ten...

    • @stephenott1952
      @stephenott1952 5 лет назад

      Just use Gauss's method. sum of all natural numbers from 1 to n is simply (n(n-1))/2

  • @vuzinskienterprise4568
    @vuzinskienterprise4568 7 лет назад

    Hey Hopson, what is your plan for the next game?

  • @miha53cevic
    @miha53cevic 7 лет назад

    great vid

  • @Maraus92
    @Maraus92 7 лет назад

    I know that this question maybe answered here somewhere, but are You developing on Windows? What program do You use, eclipse?

    • @Hopsonn
      @Hopsonn  7 лет назад

      code blocks

    • @Maraus92
      @Maraus92 7 лет назад

      Thank You! I tend to use VS, but it starts to annoys me more than it helps. Do You use GNU/gcc compiler?

    • @Hopsonn
      @Hopsonn  7 лет назад +1

      MinGW compiler comes with CodeBlocks, which is a port of GCC to Window :)
      Just make sure you download the one with "mingw-setup" in the title if you plan on using code blocks

  • @perch3428
    @perch3428 5 лет назад

    What ide do you use to code in c++/SFML?

  • @AMSASH
    @AMSASH 7 лет назад

    Can you try making a sonic game in C++/ SFML?

  • @krazy4940
    @krazy4940 7 лет назад +47

    Just sitting here not knowing wtf he is talking about xD

  • @mndtry
    @mndtry 6 лет назад

    How do I import this awesome framework in codeblocks with a cbp file? :( thanks!

  • @dynastylobster8957
    @dynastylobster8957 7 лет назад

    what project manager/ aplication programming interface are you using?, i know you are using one, because of the resource tree on the left

    • @dynastylobster8957
      @dynastylobster8957 7 лет назад

      never mind, i know its codeblocks, now that i have both sfml, and codeblocks, i just gotta find a way to tie them together

  • @mysta3152
    @mysta3152 7 лет назад

    When should I start using SFML? I just finished Jumping into c++ by Alex Allain

    • @Hopsonn
      @Hopsonn  7 лет назад

      When you are comfortable with C++ concepts such as pointers, classes and polymorphism.

    • @mysta3152
      @mysta3152 7 лет назад

      Okay, thanks for the response!

  • @mrlion1875
    @mrlion1875 7 лет назад +1

    Make a mario game! Something like the first (oldest) ones.

    • @purrleterian
      @purrleterian 6 лет назад

      MrLion18 they might seem simple, but even the first Mario game is extremely complex to program

  • @-zabest-1632
    @-zabest-1632 7 лет назад

    *Its... G O R G E O U S*

  • @nickkusters100
    @nickkusters100 5 лет назад +3

    I saw you started with C#, why did you move to c++?

  • @daggawagga
    @daggawagga 7 лет назад

    In the pseudorandom number generator used, what is the resolution of the std::time value given to the mersenne twister? Seconds? Nanoseconds? If multiple rng engines are created within the same smallest unit of time will they output the same results?

    • @Hopsonn
      @Hopsonn  7 лет назад +1

      std::time is usually the number of seconds it has been since January 1st, 1970
      I'm not really expert on RNG seeds, and so I cannot answer your second question.

    • @Smaxx
      @Smaxx 7 лет назад +1

      If they're using the same seed and algorithm, yes, they'll all produce the same results. That's how games such as The Binding of Isaac are able to provide (pseudo-)randomly generated levels that can be replayed by entering the initial seed.

    • @daggawagga
      @daggawagga 7 лет назад

      +Hopson I had just watched your Empire Cellular Automata video and was wondering if this affects it. It would be weird if all the values generated within the same second were the same. Maybe some very specific biases would crop up during the simulation because of that

    • @Hopsonn
      @Hopsonn  7 лет назад

      It can't be the same, the seconds since Jan 1970 will always be different :P
      Well, until 2038.

    • @daggawagga
      @daggawagga 7 лет назад

      The seconds won't be different if more than one std::time is created within the same second.
      But nevermind any of that. I saw the source linked in the cellular automata video and realized you used a static variable for the generator so it is indeed instanced only once. It won't matter too in this game engine as long as people who use it don't create more than one Random instance.

  • @brunomello6305
    @brunomello6305 7 лет назад +4

    3:44 what software did you use here?

  • @legomsq6479
    @legomsq6479 7 лет назад

    Hey i want to ask something how did u learn coding c++ or something books or something if it book can you advice some book for coding beginning level :D

    • @Hopsonn
      @Hopsonn  7 лет назад

      Check my Q&A video

    • @legomsq6479
      @legomsq6479 7 лет назад

      okey.....

    • @Hopsonn
      @Hopsonn  7 лет назад +1

      Sorry :P
      Basically, I learned basics from a book (as mentioned in the Q&A vid), and from there I created my own projects and slowly learned concepts over time :)

    • @legomsq6479
      @legomsq6479 7 лет назад

      ok thanks for answer my english is not good what book you learned?

    • @Hopsonn
      @Hopsonn  7 лет назад

      "Jumping into C++", as mentioned in the Q&A

  • @darkhunter777
    @darkhunter777 6 лет назад +1

    Это чтото типа "Hello world" да ? =)

  • @nekoest
    @nekoest 6 лет назад

    ayy lmao gg gj

  • @cordydl
    @cordydl 7 лет назад

    Which IDE do you use to program in C++?

    • @Hopsonn
      @Hopsonn  7 лет назад

      code blocks

    • @hexagonist23
      @hexagonist23 7 лет назад

      Are you trying to sound cool?

    • @cordydl
      @cordydl 7 лет назад

      TeknoSwift wtf do you mean?

    • @hexagonist23
      @hexagonist23 7 лет назад

      i mean some people say words like "IDE" to sound cool

    • @cordydl
      @cordydl 7 лет назад

      TeknoSwift ... okey but I dont use this word to sound cool, I just use it, cause its the correct definiton of the program, which he uses in this video

  • @gameurofplay7321
    @gameurofplay7321 6 лет назад

    you should make mario

  • @MaplecraftHero
    @MaplecraftHero 7 лет назад

    Have you looked into data oriented design?

    • @Hopsonn
      @Hopsonn  7 лет назад

      My research on that topic was watching the video where Mike Acton talks about it.
      Sounds like pretty interesting stuff :P

  • @MrLimetto
    @MrLimetto 7 лет назад +10

    I would appreciate if you could go over the code in more detail and probably explain advanced syntax / techniques like "&&". Anyway good video

    • @Hopsonn
      @Hopsonn  7 лет назад +5

      Thanks, I'll see :)
      The main issue is trying to target a wider audience, and while some would find it interesting, others would be very confused :P

    • @TheHHG7
      @TheHHG7 7 лет назад +1

      books are better

    • @Hopsonn
      @Hopsonn  7 лет назад +8

      Not a Troll I think he means r value references

    • @MrLimetto
      @MrLimetto 7 лет назад

      Exactly

    • @Stan10785
      @Stan10785 7 лет назад

      I can understand you fast forwarding through this part as you do have an 11 video playlist that covers pretty much the same thing in great depth!

  • @vitor-a12
    @vitor-a12 7 лет назад

    Teach us how to compile SFML projects for android :)

    • @marmoripelaao9830
      @marmoripelaao9830 7 лет назад

      incompatibility

    • @vitor-a12
      @vitor-a12 7 лет назад

      Marmori Pelaa :o NDK

    • @Krokoklemmee
      @Krokoklemmee 7 лет назад +1

      Marmori Pelaa :o if you look closely in the SFML source, you'd know that it very well is available for Android

  • @Off_Rip
    @Off_Rip 7 лет назад +1

    Create a version of super mario 64

  • @mikyjo2012
    @mikyjo2012 7 лет назад +2

    Hi guys I came here for Veigar montage???????

    • @StrexGamer
      @StrexGamer 7 лет назад

      fucking rubbish champ :)

  • @AshtonSnapp
    @AshtonSnapp 7 лет назад

    I want to make a text RPG framework. Ideas?

    • @fromant65
      @fromant65 7 лет назад

      The colonization of america 7u7

    • @AshtonSnapp
      @AshtonSnapp 7 лет назад

      fromant65 ... you missed one word in my comment. "Framework". As in not an actual game, just the backbone of one.

  • @neongamerlp9856
    @neongamerlp9856 7 лет назад

    What IDE is that?

    • @jackson570
      @jackson570 7 лет назад

      NeonGamerLP -using namespace Code- Code::Blocks

  • @cornchiptortilla2185
    @cornchiptortilla2185 7 лет назад

    hi

  • @plutaoopequenoplaneta1428
    @plutaoopequenoplaneta1428 6 лет назад

    is this real time?

    • @Hopsonn
      @Hopsonn  6 лет назад

      Plutão O Pequeno Planeta no its sped up

  • @kim15742
    @kim15742 6 лет назад

    sudo random

  • @rigobertomartinez941
    @rigobertomartinez941 6 лет назад

    Hola

  • @Nugcon
    @Nugcon 7 лет назад

    420 likes lol

  • @TheWizoid
    @TheWizoid 7 лет назад

    first!!!!

  • @Henrix1998
    @Henrix1998 7 лет назад

    How many years of coding I need for this stuff?

    • @Xpost2000
      @Xpost2000 7 лет назад

      It really depends on how much you commit to it. How much your willing to learn will probably be the main factor.
      But I'd give it about a year.

    • @Hopsonn
      @Hopsonn  7 лет назад

      Henrix98 The stuff in this video isn't too hard, so I'd say 5 months to a year would be enough

  • @kirtjoe283
    @kirtjoe283 7 лет назад +7

    Yes! With your brains and my imagination we can make a new minecraft that can reveloutionize the world
    Are you in sir?

    • @krakenofdeath1701
      @krakenofdeath1701 6 лет назад +1

      If this is a joke good job. If its not....
      1) you have nothing to add to the project. 2) He will never team with you. 3) He has better things to do than make a minecraft clone AGAIN(he did it already).

  • @ifizzysoda6658
    @ifizzysoda6658 7 лет назад +5

    Can you code in Java?

    • @Hopsonn
      @Hopsonn  7 лет назад +3

      a bit

    • @Krokoklemmee
      @Krokoklemmee 7 лет назад +5

      why would you want Java, if you have C++?

    • @ifizzysoda6658
      @ifizzysoda6658 7 лет назад

      OtakuNewb idk Java is coded differently and lots of games (like minecraft for example) are coddd in java

    • @darkbibni
      @darkbibni 7 лет назад +5

      lot of games xDDDD
      Not really... ^^'
      compared to C++/C# it's a minor part of all existing games.

    • @Krokoklemmee
      @Krokoklemmee 7 лет назад +2

      not quite. A majority of lower-tier mobile games (which make up the majority of mobile games) are written in Java for example.
      It's just that Java isn't quite suited for computation heavy applications, such as games, because it wasn't designed with those in mind.

  • @altaccount648
    @altaccount648 7 лет назад

    Create Growtopia (it's c++)

    • @marmoripelaao9830
      @marmoripelaao9830 7 лет назад

      actually it is made in p++ which is what the original creator of the game uses.

    • @altaccount648
      @altaccount648 7 лет назад

      Marmori Pelaa :o lol

  • @locallion1218
    @locallion1218 5 лет назад

    Your time-lapse is too fast IMO. Considering that your video is only 6 minutes it wouldn't be so bad to make it longer.

  • @pumpkin6429
    @pumpkin6429 7 лет назад

    Make GTA Online.

    • @SuperMCMatrix
      @SuperMCMatrix 7 лет назад

      Pumpkin that would be so complicated

  • @Geokit
    @Geokit 7 лет назад

    Hey can I be a beta tester for hopsoncraft