Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Explosion Simulator in C++  (Read 7007 times)

0 Members and 1 Guest are viewing this topic.

Raynobrak

  • Newbie
  • *
  • Posts: 13
    • View Profile
Explosion Simulator in C++
« on: January 05, 2019, 05:24:47 pm »
Hey guys,

So, I'm currently learning to be an informatician at the ETML in Lausanne, Switzerland. And here, at the end of the schoolyear, every student has to do a project (best time of the year), and the cool thing about it is that we can choose what it's gonna be. We have 4 weeks to complete it.
My project was an explosion simulator in C++ and, obviously, SFML. The teachers were a bit skeptical about my project, because we don't learn C++ (we learn C# instead) nor physics at the ETML  ;D.

But anyway, I managed to make a "game" that is quite fun to play (at least that's what my friends told me ahah), it's in french but even if you don't speak it, you shouldn't have any problem, there isn't a lot of text and the UI is pretty simple.

Btw, I know there are bugs, it was the first time I tried to resolve collisions that take velocity and mass into account, so it wasn't easy even though everything is axis-aligned :P

In the future, I'd like to remake this game entirely, but with OBB collisions, better looking and more satisfying physics and better code design. So if you guys have any suggestions, I'm open to new ideas !

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Explosion Simulator in C++
« Reply #1 on: January 05, 2019, 06:03:05 pm »
Sounds interesting, do you have some screenshots? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raynobrak

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Explosion Simulator in C++
« Reply #2 on: January 05, 2019, 06:35:43 pm »
There's a .zip to download if you want. Or maybe are you on Linux ? :'(

Here you go :

https://postimg.cc/gallery/1hvhs4up4/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Explosion Simulator in C++
« Reply #3 on: January 05, 2019, 06:46:52 pm »
I don't like to download zips just to look at pictures that could be directly embedded. ;)

Also currently on my phone.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Explosion Simulator in C++
« Reply #4 on: January 05, 2019, 06:54:24 pm »
SFML seems very popular with Swiss people.

Quote
My project was an explosion simulator in C++ and, obviously, SFML. The teachers were a bit skeptical about my project, because we don't learn C++ (we learn C# instead) nor physics at the ETML  ;D.
I've done many funny things like these. Like use Pascal or Lua instead of C/C++/C#/Java we got taught, or make my project for 'Programming 3 - C#/Java' in C# on Mono on Linux using GTK#, SFML.Net and Box2DNet despite taking Java classes and not C# classes.

It's not only fun to friendly troll people a bit (of course only the young fresh master/doctorate teachers who are like under 40 or something, don't troll some old grumpy professor) but I also think this is a very good and cost efficient way of building faculty confidence in you and showing you're not just passively absorbing what they tell you, especially on first term/year (at least it was for me, maybe in Switzerland everyone is a leet coder in university so it'll be harder to impress anyone). At one point a teacher I never met before knew me already from word of mouth.

There are (slightly stale) C and C# official bindings if you need them, BTW.
Back to C++ gamedev with SFML in May 2023

Raynobrak

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Explosion Simulator in C++
« Reply #5 on: January 05, 2019, 07:32:28 pm »
SFML seems very popular with Swiss people.

Quote
My project was an explosion simulator in C++ and, obviously, SFML. The teachers were a bit skeptical about my project, because we don't learn C++ (we learn C# instead) nor physics at the ETML  ;D.
I've done many funny things like these. Like use Pascal or Lua instead of C/C++/C#/Java we got taught, or make my project for 'Programming 3 - C#/Java' in C# on Mono on Linux using GTK#, SFML.Net and Box2DNet despite taking Java classes and not C# classes.

It's not only fun to friendly troll people a bit (of course only the young fresh master/doctorate teachers who are like under 40 or something, don't troll some old grumpy professor) but I also think this is a very good and cost efficient way of building faculty confidence in you and showing you're not just passively absorbing what they tell you, especially on first term/year (at least it was for me, maybe in Switzerland everyone is a leet coder in university so it'll be harder to impress anyone). At one point a teacher I never met before knew me already from word of mouth.

There are (slightly stale) C and C# official bindings if you need them, BTW.


Well, I didn't really troll my teachers because I told them I was gonna do the project in C++ and they agreed, but normally, they want you to do everything in C#.  But yeah, I definitely agree on the "not just passively absorbing what they tell you". When I came to the ETML, I already knew how to code in C++, but I didn't know how to code correctly. And I was kinda hoping to learn how to write good code at the ETML, but the teachers here don't seem to really give a damn about "good practices", to them it's simpler : It works or it doesn't.
So I read a book instead :
https://www.amazon.com/Coder-efficacement-Bonnes-pratiques-erreurs-ebook/dp/B00II5Y8DE

This book radically changed the way I code. My code is now more readable, contains less complicated abstract concepts and makes more sense overall.

About SFML.Net, we currently have a project at the ETML where we need to create an algorithm that can generate mazes and solve them. We were supposed to make it in the Console only (which I did), but I managed to finish the algorithm pretty quickly, so I used it to make a game with SFML.Net and C# eheh  ;D


FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Explosion Simulator in C++
« Reply #6 on: January 05, 2019, 08:48:37 pm »
Quote
Well, I didn't really troll my teachers because I told them I was gonna do the project in C++ and they agreed, but normally, they want you to do everything in C#.
Yeah, that one is not trolling but just good impression and showing initiative but with right people some slight trolling can apply too, e.g. sending a Pascal program instead of a C one (it was a simple assignment since it was a contest style question where the real task is translating the problem into right algorithm, not implementation itself) to a teacher who you know for sure knows Pascal (but most students these days don't or think it's old/dead language, I happen to know it from high school and use it for one personal program - linked in my forum footer) and getting called a 'connaisseur' jokingly as a result.

Once a teacher even thought and asked if I'm testing our faculty's staff by putting small mistakes into my programs because one of my == was replaced with = in a way that never showed up in the program behavior (it was an actual accident but it was pretty funny and proof I was thought of highly to get asked that).

Quote
About SFML.Net, we currently have a project at the ETML where we need to create an algorithm that can generate mazes and solve them. We were supposed to make it in the Console only (which I did), but I managed to finish the algorithm pretty quickly, so I used it to make a game with SFML.Net and C# eheh  ;D
There are many fun algorithms for that depending on what you need. What did you use? I once used Kruskal's minimum spanning tree algorithm (I found it really neat and wanted to use it in a simple retro style game) but with randomly (instead of by weight) sorted edges to generate a random 2D tree on a tile map for this game (exe in last post): https://en.sfml-dev.org/forums/index.php?topic=20228.0

Quote
And I was kinda hoping to learn how to write good code at the ETML, but the teachers here don't seem to really give a damn about "good practices", to them it's simpler : It works or it doesn't.
That kinda happens in reality too for various reasons (some good, some bad). And there are some competitive (group) programming contests (I even took part in like 3 or 4 of them, including ACM ICPC CERC like twice and few national ones here) where this is actually how it works (either your program passes or not, and limits and input format and such are known up front so if your program exploded, segfaulted, printed false results, etc. at n + 1 input lines but limits in the task said max n lines - it's okay but in reality you'd of course try to fail gracefully).

And I'm not sure how it is at your specific university but computer science and 'programming' are often lumped together and that causes this gap. There's lots of in between stuff too, like cryptography is kinda math but no one would ever use something like RSA or AES without a program to do it but writing your own requires both math and programming skills to not have either kind of holes in the implementation. Or languages like Haskell and maybe some ML dialects which have some super interesting properties for practical use but are very math-y in their background, related to the entire 'Lambda calculus' thing, etc. Lisp, Prolog and F# have more science-y roots too.

Your not giving a damn teachers might be Ph.D.s who never programmed professionally and are better at theoretical CS, math, know enough C, Pascal, C++, C#, Java, Python, etc. to get by or use for their papers (they might even be Ph.D.s of physics or math, not even CS, I had few like that). Even though I'm a programmer (and that's why I studied) I'm still a (roughly translated) 'master of engineering of computer science' and had tons of theoretical, math and so on classes too (and one physics one) in addition to all the practical and programming ones and my master paper was a 100% math-y CS paper about Petri nets (but my engineering one was a practical one about Lua's implementation) with 0 lines of code in it.

I kinda ended up appreciating the differences too after getting my master's even though they were frustrating at the time, maybe you'll too.
« Last Edit: January 05, 2019, 10:00:59 pm by FRex »
Back to C++ gamedev with SFML in May 2023