Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 200 201 [202] 203 204 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 908461 times)

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3015 on: September 30, 2012, 01:16:57 am »

Well, sorry for being retarded, I guess. :/

I say use #pragma once if ye compiler supports it, and you don't need to share you project with others. Use #ifndef, #define, #endif if your onpiler doesn't support it, or you need cross-compiler compatiability. Also, you just need to know what it is. :P

... doesn't your vunderul book have anything about that in it? >.>
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Valid_Dark

  • Bay Watcher
  • If you wont let me Dream, I wont let you sleep.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3016 on: September 30, 2012, 02:26:39 am »

Well I'm not yet at the part in my book about multi sourced projects, and I refuse to skip ahead, but I've just about figured it all out.

Just got my first multi-sourced project to compile with no syntax errors, YAY!
it ended up being a lot easier than I was making it out to be, should have done this sooner.


and Skyrunner, I didn't call YOU retarded,  i didn't mean to call anyone retarded, but I did, and it wasn't directed at you.  I was saying, quoting what someone else said, and telling someone it's an answer to their question, when what was quoted had nothing to do with the problem, is something that a mentally disabled person might do.

Sorry for being mean everyone.  I'll try to be less aggressive in the future.
« Last Edit: September 30, 2012, 02:58:27 am by Valid_Dark »
Logged
There are 10 types of people in this world. Those that understand binary and those that don't


Quote
My milkshake brings all the criminals to justice.

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3017 on: September 30, 2012, 04:12:59 am »

Does anyone have a Python tutorial that they recommend? My newest part-time project uses it :P
I am using this.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3018 on: September 30, 2012, 04:14:12 am »

Does anyone have a Python tutorial that they recommend? My newest part-time project uses it :P
I am using this.
Thanks, I'll be sure to check it out :)
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Mini

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3019 on: September 30, 2012, 08:43:36 am »

Mini, that quote, from Skyrunner, doesn't answer the question I had about global variables,
Whoops.
Original question you asked: Yes, they only have file scope. To access it from other files stick the extern stuff Skyrunner posted about.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3020 on: September 30, 2012, 08:52:11 am »

just one thing,  when you declare global variables, they're still only in the scope of that one source file, right?  so instead you should make it a class member variable so you can access it from the other source files, right?   I've been programming with just one source file, my structure is kind of messed up, but I get it now, and just need to restructure a good amount of the code i've already written for this project. (I started it off as a single source project, then realized it was time to get organized)
Yes, they are global only to that file, but using the keyword extern you can "include" them in other files. Static members are the nicer option to globals, but both should be avoided as much as possible. They're too easy to abuse and you'll run into more problems later (Notice how I did not say "never use them").
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3021 on: September 30, 2012, 10:33:50 am »

I WOULD say never use extern, though. Allow access to them through functions, not directly. Will make things far, far easier in the long run.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3022 on: September 30, 2012, 02:49:03 pm »

I WOULD say never use extern, though. Allow access to them through functions, not directly. Will make things far, far easier in the long run.

Never say never. Except when you're talking about goto.

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3023 on: September 30, 2012, 04:21:21 pm »

There are seriously a few places I'd use a goto, though really only in switch statements, which are already "almost never" things. (Well actually I *used* to use them there, but some c++11 things alleviated the need for that with some local functions that can inherit local scope. So I guess gotos are back to "never".)
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3024 on: September 30, 2012, 04:37:51 pm »

There are seriously a few places I'd use a goto, though really only in switch statements, which are already "almost never" things. (Well actually I *used* to use them there, but some c++11 things alleviated the need for that with some local functions that can inherit local scope. So I guess gotos are back to "never".)

I've never had to resort to goto for anything, even before C++11. Mind giving an example of what you would use it for in C++03?

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3025 on: September 30, 2012, 04:40:31 pm »

Occasionally I wanted a few snippits of code to be used for multiple switch cases, and didn't want to use functions for it as it'd lose local scope. Redundant code sucks and I wanted to avoid that, too. So I'd use a goto to jump to a particular case's code whenever I wanted any particular case to use it.

So something like this:

Case 1:
//does blah
goto Case_3;
Case 2:
//do other blah
Case 3:
Case_3:
//do more blah, that's also done by cases 2 and 1
break;
« Last Edit: September 30, 2012, 04:43:29 pm by kaijyuu »
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3026 on: September 30, 2012, 05:04:35 pm »

Occasionally I wanted a few snippits of code to be used for multiple switch cases, and didn't want to use functions for it as it'd lose local scope. Redundant code sucks and I wanted to avoid that, too. So I'd use a goto to jump to a particular case's code whenever I wanted any particular case to use it.

So something like this:

Case 1:
//does blah
goto Case_3;
Case 2:
//do other blah
Case 3:
Case_3:
//do more blah, that's also done by cases 2 and 1
break;

I think I get what you're saying, but could you give an example with actual code in it? I'm very curious now, as this might be the first legitimate use I've seen for goto.

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3027 on: September 30, 2012, 05:05:34 pm »

That project's long gone, unfortunately :X

The actual use of the switch statement though was enemy behavior in a game. So there were a few different attack states that I wanted to all end in the same way, but had some different starting code. Stuff like that.
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3028 on: September 30, 2012, 05:10:00 pm »

That project's long gone, unfortunately :X

The actual use of the switch statement though was enemy behavior in a game. So there were a few different attack states that I wanted to all end in the same way, but had some different starting code. Stuff like that.

Hmm... Why not stick the shared code after the switch statement?

kaijyuu

  • Bay Watcher
  • Hrm...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3029 on: September 30, 2012, 05:15:05 pm »

Because not every case would use it. Just some.

(my enemy behavior was all done in the same switch, barring some basic things like movement)
Logged
Quote from: Chesterton
For, in order that men should resist injustice, something more is necessary than that they should think injustice unpleasant. They must think injustice absurd; above all, they must think it startling. They must retain the violence of a virgin astonishment. When the pessimist looks at any infamy, it is to him, after all, only a repetition of the infamy of existence. But the optimist sees injustice as something discordant and unexpected, and it stings him into action.
Pages: 1 ... 200 201 [202] 203 204 ... 796