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

Author Topic: Lethn's Programming Questions Thread  (Read 53814 times)

0 Members and 1 Guest are viewing this topic.

Mosseman

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #150 on: October 10, 2013, 01:06:13 pm »
I actually understood that and I don't know why people didn't explain libraries that way to me before when I asked, so either this is a good website or people are all going to jump in now claiming it's bullshit. Thanks again for posting that Hatchet, I'm sure other people will find the website really useful too.
I'm hurt.

But serisously, I'm glad it helps.  It's taught me a lot, it's helped me design little programs and hopefully hasn't taught me any bad habits.

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #151 on: October 10, 2013, 01:13:53 pm »
LOL sorry! wrong person, so much spam :D Edited :P
« Last Edit: October 10, 2013, 06:04:42 pm by Lethn »

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #152 on: October 11, 2013, 09:05:30 am »
I had to ask as well, are the case and break's really necessary? The code looks nice and solid but I was just wondering because they're only basic if/else functions ( yey, the website is helping! ) I would have thought break would only be necessary if you didn't want to use a ";" or something.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Lethn's Programming Questions Thread
« Reply #153 on: October 11, 2013, 09:39:52 am »
If you read a decent book about C and understood how switch statements actually work, it would be pretty obvious why you need all of them.  I'll give you a real answer because I'm in a good mood but please go learn the language already.

If you skip a break; statement, then it won't break, it will just continue past the next case label.  This is handy when you want the same or similar things to happen in multiple cases.

As for why switch instead of if/else, switch statements are extremely simple to implement because it takes a single fundamental type and compares it against some constants.  An if statement has to be able to accept any boolean expresion no matter how complex.

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #154 on: October 11, 2013, 09:51:16 am »
I get that, so why is it then that the documentation code shown for events was completely different to the events tutorial and I know this is what threw me off from making the code work which is why I posted it here.


 while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
window.close();
}

 

There's no mention of event.type here yet there is in the tutorial so no one unless they already knew the answer right away would have been able to realise that the tutorial was the correct piece of code to use or was that on purpose? I was working on this assuming I should follow the documentation, I know enough about events but I haven't read up on break and switch properly yet.

The reason I ask these kind of questions is because books and tutorials won't answer, a lot of times books and tutorials always make the mistake of assuming you already know bits and pieces or skip out sections no matter how well they're written which is why I use multiple sources despite anyone's objections and I made this thread.

So either this code was written wrong, or the event tutorial code is what you use when using more advanced techniques, or, Laurent did this on purpose to catch people out :P.
« Last Edit: October 11, 2013, 09:53:58 am by Lethn »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Lethn's Programming Questions Thread
« Reply #155 on: October 11, 2013, 10:02:02 am »
I went and checked, and both the tutorial and documentation talk about event types, plus it's right there in the code snippet you pasted so what are you claiming is being left out?  Just because they use slightly different code that does the exact same thing doesn't mean that either one is wrong.

Also, it honestly sounded like you were saying the events tutorial should be teaching you how switch statements work, which is just ludicrous.  Once again, go learn C++ before trying to use a C++ library.  A real non-shitty C++ book WILL answer all your questions about C++, then you can come back to SFML and the documentation WILL answer all your questions about SFML.  You can't tackle both at once.

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #156 on: October 11, 2013, 10:04:42 am »
lol Guess I have more reading to do then :D the book I have was recommended but I still read from other sources.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Lethn's Programming Questions Thread
« Reply #157 on: October 11, 2013, 10:07:47 am »
Maybe that's the problem.  Since you complained about "all" sources assuming you already know certain parts, stick to one book that assumes you know nothing at all, teaching the whole language from start to finish, and use nothing else until you've completed the whole thing (except maybe a reference site like cplusplus.com).

If you want to be absolutely sure nothing is being left out or dumbed down to make things "more accessible", The C++ Programming Language is probably a safe bet, for obvious reasons.
« Last Edit: October 11, 2013, 10:09:57 am by Ixrec »

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #158 on: October 11, 2013, 10:31:06 am »
Well the C++ primer book I was recommended on this thread is very good but it's so frustrating to read, I think I'm just going to have to devote some proper time studying it bit by bit :S, I've gotten through a chunk of it but I'm only about two chapters in.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Lethn's Programming Questions Thread
« Reply #159 on: October 11, 2013, 10:39:35 am »
Is it more frustrating then having to come here and beg for help every time a basic feature of C++ confuses you?

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #160 on: October 11, 2013, 10:40:26 am »
Yes! :D That said I will admit it looks like the only way I'm going to be able to become independent as a programmer is rely on the book like others have said so I'm still going to keep at it.

Every time though I read the damn book I end up wanting to do this, particularly when it comes to variables:

Didn't I post on this thread that one of my friends even felt sorry for me for having to read a book like this? Lmao :p
« Last Edit: October 11, 2013, 10:58:38 am by Lethn »

Mosseman

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #161 on: October 11, 2013, 03:33:11 pm »
Yes! :D That said I will admit it looks like the only way I'm going to be able to become independent as a programmer is rely on the book like others have said so I'm still going to keep at it.
Good!  You're learning very slowly at the moment but keep reading your book (as others have said: use ONE resource at a time while you're learning).  It looks like making GUI apps is the only way you're keeping yourself motivate to do this, so if toying with SFML is the you've gotta do it, then it's the way you gotta do it.  I just wish, for your sake, that you'd stick to a good tutorial/book.

Quote
Every time though I read the damn book I end up wanting to do this, particularly when it comes to variables:
Variables are easy.  Wait until you start using pointers (essential to know).  Wrapping my head around that concept was difficult for me.

Ancurio

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #162 on: October 13, 2013, 02:35:13 pm »
Well the C++ primer book I was recommended on this thread is very good but it's so frustrating to read, I think I'm just going to have to devote some proper time studying it bit by bit :S, I've gotten through a chunk of it but I'm only about two chapters in.

If you want to create games, but aren't interested in (or even repulsed by) programming, you could just use something like GameMaker.

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Lethn's Programming Questions Thread
« Reply #163 on: October 13, 2013, 04:06:33 pm »
I like games and I do like the C++ language :) I started learning C++ and SFML because games are all either made in game engines or just clones of one another now. Just recently I played Rome 2 Total War and Battlefield 4 and I was amazed at how despite the shortcuts these supposedly professional game developers took there were still huge problems even though they bought or had pre-made engines themselves. I also think part of the problem with using game engines is that a lot of the time they're inflexible and are only good at doing one job. My game ideas that I have planned for later will definitely require something more sophisticated.

So yeah, no matter how much I might bitch :P I'm still going to get through that book I hope :D.
« Last Edit: October 13, 2013, 04:13:01 pm by Lethn »

 

anything