Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 257 258 [259] 260 261 ... 796

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

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3870 on: February 12, 2013, 05:18:19 am »

I vary rarely use Windows API so I can't help you there pal.

You missed my terrible joke. That's the error GCC gives me when I try to compile an empty file.
Logged

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 #3871 on: February 12, 2013, 05:42:26 am »

ohh,... yeah,
that was a pretty terrible joke.
I don't think I've EVER tried to compile an empty file,. I mean... why would you??
(other than for terrible jokes that is)
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.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3872 on: February 12, 2013, 03:13:53 pm »

Back before C++11, stringstream got a lot of abuse from me, since the to_string function didn't exist.

Code: (Actual code from one of my utility headers) [Select]
template<typename T> string toString(T data) { // Will fail to compile if operator<< isn't defined for the type.
    stringstream sstr(""); // yeah, explicit initialization to a blank string isn't necessary, but I still do it
    sstr << data;
    return sstr.str();
}

Soadreqm

  • Bay Watcher
  • I'm okay with this. I'm okay with a lot of things.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3873 on: February 12, 2013, 03:29:35 pm »

x=24;
name<<"string"<<42<<"string"<<x;
name.str is how you'd call the string, so
cout>>name.str(); should output  "string42string24"

In Java, you'd type
System.out.println("string" + 42 + "string" + x);
to output that.

Does the '+' operator do anything for strings in C++?
Logged

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3874 on: February 12, 2013, 03:51:38 pm »

const const double*& strangeType();,
That makes me wonder how many times you can fit const into a single c++ statement.
Logged

dreadmullet

  • Bay Watcher
  • Inadequate Comedian
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3875 on: February 12, 2013, 04:27:04 pm »

const const double*& strangeType();,
That makes me wonder how many times you can fit const into a single c++ statement.

This is a good reference that I use: http://jriddell.org/const-in-cpp.html

Quote
const int*const mymethod(const int*const&)const

It will return a pointer which is constant and points to a constant integer, the method doesn't alter either the variable pointed to by the paramater or the pointer itself and it doesn't alter any of the member variables of the object the method is it.

Although, I suppose if you used templates it could go on forever:

Code: [Select]
template<const int A , const int B , const int C> const int* const mymethod(const int* const&) const
But wouldn't those consts be redundant, since template parameters have to be constant anyway?
Logged

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 #3876 on: February 12, 2013, 04:32:06 pm »

Back before C++11, stringstream got a lot of abuse from me, since the to_string function didn't exist.

Code: (Actual code from one of my utility headers) [Select]
template<typename T> string toString(T data) { // Will fail to compile if operator<< isn't defined for the type.
    stringstream sstr(""); // yeah, explicit initialization to a blank string isn't necessary, but I still do it
    sstr << data;
    return sstr.str();
}

AHA I knew I wasn't crazy, I didn't think it existed before c++ 11, but a quick google didn't show anything about it.  My compiler doesn't support c++ 11 which would explain why I've never used it.
x=24;
name<<"string"<<42<<"string"<<x;
name.str is how you'd call the string, so
cout>>name.str(); should output  "string42string24"

In Java, you'd type
System.out.println("string" + 42 + "string" + x);
to output that.

Does the '+' operator do anything for strings in C++?
Yes, see my previous post.  But in c++ you cant add a variable or a number to a string unless they are converted into a string first, and converting them to strings is a headache (before C++ 11 existed)


And mr.Skyrunner, I would like to see your triangle water code maybe if it wouldn't be a bother to you.
« Last Edit: February 12, 2013, 05:01:22 pm 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.

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3877 on: February 12, 2013, 05:25:16 pm »

Yes, see my previous post.  But in c++ you cant add a variable or a number to a string unless they are converted into a string first, and converting them to strings is a headache (before C++ 11 existed)

I'll happily link Qt into any application I make, even if it's just for QStrings. All the convenience rolled into one.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3878 on: February 12, 2013, 07:42:58 pm »

x=24;
name<<"string"<<42<<"string"<<x;
name.str is how you'd call the string, so
cout>>name.str(); should output  "string42string24"

In Java, you'd type
System.out.println("string" + 42 + "string" + x);
to output that.

Does the '+' operator do anything for strings in C++?

It concatenates string objects. The issue is, it *only* concatenates string objects. By extension, it will also work with anything that can be implicitly cast as a string, which, in the standard, is all of one* thing: char arrays. User-defined classes that define implicit casting to string will also work. So, more function calls are needed to concatenate data of other types.

*I'm not 100% familiar with C++11, so I'm not sure if char initializer lists can be implicitly converted to strings or not.

kaenneth

  • Bay Watcher
  • Catching fish
    • View Profile
    • Terrible Web Site
Re: if self.isCoder(): post() #Programming Thread
« Reply #3879 on: February 12, 2013, 09:34:13 pm »

Which is one of the nice things in C#, everything has a .ToString() implementation.
Logged
Quote from: Karnewarrior
Jeeze. Any time I want to be sigged I may as well just post in this thread.
Quote from: Darvi
That is an application of trigonometry that never occurred to me.
Quote from: PTTG??
I'm getting cake.
Don't tell anyone that you can see their shadows. If they hear you telling anyone, if you let them know that you know of them, they will get you.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3880 on: February 12, 2013, 10:05:18 pm »

Which is one of the nice things in C#, everything has a .ToString() implementation.

Also Java. It just doesn't always do what you want.

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 #3881 on: February 13, 2013, 04:33:45 am »

been working most of the day on the backend of a heightmap generator,
so far it's not giving me the results I had hoped for.

using a version of the diamond square algorithm,
it IS working, just not right, with some fine tuning I think I can get it working nicely.
« Last Edit: February 13, 2013, 05:42:29 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.

GalenEvil

  • Bay Watcher
    • View Profile
    • Mac-Man Games
Re: if self.isCoder(): post() #Programming Thread
« Reply #3882 on: February 13, 2013, 05:29:16 am »

@Valid_Dark: Try putting the values at all four corners before starting the Diamond-Square Algorithm. It looks like you are not setting up the map corners and clamping to a byte value which would give a large possibility of seeing what you just showed, most of the values trying to move into negative space and it clamping the values to zero.
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 #3883 on: February 13, 2013, 05:38:39 am »

I wanted all of the edges to be 0,
I'm making a fair amount of progress,
I just thought I'd share these with you.
Spoiler: "First Attempt" (click to show/hide)

Spoiler: "Too many islands" (click to show/hide)

Not asking for help, just showing you guys what I'm up to.

Edit: ok, I'm still having an issue with the lines, I'm thinking I might make a smoothing function, and have it run over the whole map and just smooth everything out, how do you think that sounds?

each pixel in these images are going to be 32x32 tiles.
« Last Edit: February 13, 2013, 06:37:11 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.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #3884 on: February 13, 2013, 07:42:51 am »

The lines seem to tell me that you implemented the algorithm in a less-than optimal way. When I did my version, it had no line artifacts.

How are you doing the algorithm? Recursive, iterative? Clamped to a grid every step? There was some source code I saw a long time ago that used floating points (probably not the right terminology) instead of ones clamped to grids...
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
Pages: 1 ... 257 258 [259] 260 261 ... 796