Bay 12 Games Forum

Please login or register.

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

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

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3045 on: October 05, 2012, 12:19:06 am »

C++ has more fun in it since you can throw anything
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3046 on: October 05, 2012, 12:35:56 am »

C++ has more fun in it since you can throw anything

Err, right. I was thinking java.lang.Throwable was an interface and not a class. That, plus the lack of multiple inheritance, makes my hack idea for throwing literally any object as an exception moot.

And that makes me sad.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3047 on: October 05, 2012, 01:46:22 am »

"Throwing" makes me imagine a function chucking a variable outside its curly brackets, and the catch part catching it with a baseball glove.
It amuses me all the time xD Maybe I'm weird...
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

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3048 on: October 05, 2012, 01:48:10 am »

"Throwing" makes me imagine a function chucking a variable outside its curly brackets, and the catch part catching it with a baseball glove.
It amuses me all the time xD Maybe I'm weird...

Nah, I imagine that's fairly normal for programmers. On a side note, holy shit, it's 1:45 AM. I've been working on this project for 3 hours. At least I got a lot of work done. Refactoring code makes it prettier and easier to work with.

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #3049 on: October 05, 2012, 02:20:55 am »

I am once again working on getting caves into my terrain system. Soon I will have them!!! ^_^ Tomorrow, probably... I am being lazy and not working on it very much. Procedural terrain stuff is fun to work with :D
Logged
Fun is Fun......Done is Done... or is that Done is !!FUN!!?
Quote from: Mr Frog
Digging's a lot like surgery, see -- you grab the sharp thing and then drive the sharp end of the sharp thing in as hard as you can and then stuff goes flying and then stuff falls out and then there's a big hole and you're done. I kinda wish there was more screaming, but rocks don't hurt so I guess it can't be helped.

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 #3050 on: October 05, 2012, 04:23:11 am »

so, today I learned that in c++ the only REAL difference between a struct and a class, is that by default, struct members are public, and class members are private. but other than that they are the exact same 0_O  (that blew my mind)


and also, I just wanted to ask,  I've started on a project using multiple files, and wanted to ask if someone could take a look at my source code so far?
I just want to know if there's a better / more correct way of doing things that I'm doing.
it's in C++ using SDL,
there isn't much to it yet, but it's 13 files so far o.O
I just want some tips and tricks from some well seasoned C++ / SDL programmers.
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.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3051 on: October 05, 2012, 04:40:28 am »

Sure, could look at it, I've done a few things with SDL, but I'm not a pro.
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))

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3052 on: October 05, 2012, 05:15:31 am »

Usually, I make structs data structures, and classes ones that have functions that aren't related to the storage or retrieval of data.
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 #3053 on: October 05, 2012, 05:21:37 am »

ok, here is a zip of the source files and stuff
https://dl.dropbox.com/u/82870226/Platformer%20Test.zip

and yeah, structs are supposed to be used when all members are public, and there are no functions.
I was just surprised to learn that structs can have functions, constructors, destructors, and private members.

Edit: disclaimer: yeah, some of the source files have funky names, well not really funky, but badly named I guess.
« Last Edit: October 05, 2012, 05:30:42 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.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3054 on: October 05, 2012, 05:31:27 am »

As far as I can see (working now so just a quick once-over), you're doing it right. The .h files look nice & clean.

Nitpicking: use initialisation-lists in constructors, and decide whether to use pragma_once or ifdef guards.
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))

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 #3055 on: October 05, 2012, 05:34:42 am »

what exactly do you mean by initialisation-lists?
and yeah, one of the files has pragma once commented out, and did the ifdef guard in its place.
nitpicking is good, be as nitpicky as possible.
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.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3056 on: October 05, 2012, 05:56:37 am »

Code: [Select]
ClassName::ClassName() : a(10), b(3.5f)  //<-- that is an initialisationlist.
{
  c = new Player();
}
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))

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3057 on: October 05, 2012, 06:07:54 am »

That link is teaching me stuff I never knew. >.>

I feel like I'm stupid again...

For example, I never knew that that was how you do initialization lists, nor that there's a thing called implicit assignment. I still don't understand why exactly you are supposed to use initialization lists.
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 #3058 on: October 05, 2012, 06:31:15 am »

That link is teaching me stuff I never knew. >.>

I feel like I'm stupid again...


oo what link?

Code: [Select]
ClassName::ClassName() : a(10), b(3.5f)  //<-- that is an initialisationlist.
{
  c = new Player();
}

and that didn't help very much, lol.  never seen syntax like that before (haven't gotten to it yet in my book) so for now I think I'm not going to use it.  I mean,.. what sort of advantage does it give? and what does it do?
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.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3059 on: October 05, 2012, 07:07:43 am »

It's
A: a bit faster in some cases
B: you get to call the parent constructor.
Code: [Select]
// This is faster to type, but the constructor definition shouldn't really be in the .h
class A {
  int px, py;
  A(int x, int y) : px(x), py(y) {}
};

class B : public A {
  int pz;
  B(): A(0,0), pz(0){}
  B(int x, int y, int z) : A(x,y/z), pz(z){}
  B(int px, int pz) : A(px,pz/2),pz(pz)  {} // auto disambiguate, pz(pz) is okay, as if you did this->pz = pz;
};
C: it is necessary if you have const members

It mostly matters only if you initialise const members, references, or if you parametrise the parent's constructor. Using them anyway, even for primitives, is good practice, though.
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))
Pages: 1 ... 202 203 [204] 205 206 ... 796