Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 475 476 [477] 478 479 ... 796

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

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #7140 on: April 08, 2015, 10:57:55 am »

It's actually pretty realistic to have lone smaller peaks near areas of solid mountain.
Yeah, and mountains in the real world transition gradually (usually). By necessity I have an instant color switch. I can talk all I want about trying to make the mountain ranges "realistic", but it's obvious I just want them to look good. :P

I'll probably just have to deal with it; a more pressing problem is determining how to render these maps in-game. That whole hex grid is just a set of vertices with texture coordinates being piped through opengl each render pass, so determining what they will be rendered as is important to establish beforehand. What you see in those screenshots is a single white hex graphic drawn over and over, with colors applied to the 4 vertices of each one.

I was planning on using a sprite for each terrain type, but this color gradient looks too good to pass up. The problem is that it's difficult to add any detail to the tiles when they're being tinted, since the color is subtracted from the original sprite.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7141 on: April 08, 2015, 01:10:58 pm »

Compile a single executable that just starts cata with that option?
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7142 on: April 08, 2015, 06:03:11 pm »

Here's you guys with your fancy terrain generation, and here's me with weird ASCII splodges.
Spoiler (click to show/hide)
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7143 on: April 08, 2015, 08:23:57 pm »

Here's you guys with your fancy terrain generation, and here's me with weird ASCII splodges.
Spoiler (click to show/hide)
I planned on displaying it with ascii characters once I am happy with it, it's just easier for me to visualize the map this way  :D. I can see the whole thing without panning around, and can fit multiple maps on a screen at once this way.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7144 on: April 12, 2015, 05:09:56 pm »

So, I'm working on some graphics tutorials with some folks, generally using C++ with OpenGL or OpenGL-like stuff. Intention being minimal explanation outside the code itself, using simple, understandable coding style to do so.

Question: what is the most confusing part of this code? Or in general, what would most keep you from arbitrarily modifying it into something with similar code but different results? https://github.com/jalway/tut0
Logged

TheDarkStar

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7145 on: April 12, 2015, 05:17:19 pm »

I'm looking at wxWidgets for the first time (FOSS C++ application framework). Is there anything that I should keep in mind while using it?
Logged
Don't die; it's bad for your health!

it happened it happened it happen im so hyped to actually get attacked now

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7146 on: April 12, 2015, 06:10:42 pm »

-And solved, finally managed to track down the answer-
« Last Edit: April 12, 2015, 06:37:26 pm by i2amroy »
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7147 on: April 12, 2015, 07:20:10 pm »

There are still many things that I do not understand. Currently I am trying to create a function that can determine each individual region of the world in my world generator. For example, it would be able to tell one lake, forest, or mountain from each other. The specific method of achieving this isn't what I am asking about, I did some brainstorming and I think I am going to do some sort of flood fill approach to determine which regions are which.

To do this, I will have a vector that contains the region classes. The part of code that causes problems is this:

Code: [Select]

//check if current tile is part of existing region, if not create new region and add it to the region vector.

NaturalRegionContainer.push_back(new NaturalRegion); //create new object of the NaturalRegion class.

Now, let me explain some of my thoughts behind this. I cannot know how many regions I will have because the map is randomly generated, so I used a vector as the container. For the same reason, I attempted to create a new region the way I did. I figured this method would be much easier, since this way I would not have to individually name each region by myself in the code. When building I get the error "Undefined reference to NaturalRegion".

So, how exactly could I create a new object of a class on demand and add it to a vector, without knowing how many regions I will have until runtime?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7148 on: April 12, 2015, 07:34:26 pm »

"Undefined xyz" means that the cpp module doesn't have access to the definition of the "xyz" class or function. It means that you need an #include to link the class definition from somewhere. modules only know about the existence of code on their #include path, so you have to explicitly set this up. Generally the best solution is a strict "need to know" basis, so i avoid letting .h files have other includes in them whenever possible. put all your #includes at the cpp level then you can see clearly which modules are using which headers.
« Last Edit: April 12, 2015, 07:42:19 pm by Reelya »
Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7149 on: April 12, 2015, 07:44:29 pm »

"Undefined xyz" means that the cpp module doesn't have access to the definition of the "xyz" class or function. It means that you need an #include to link the class definition from somewhere. modules only know about the existence of code on their #include path, so you have to explicitly set this up. Generally the best solution is a strict "need to know" basis, so i avoid letting .h files have other includes in them whenever possible. put all your #includes at the cpp level then you can see clearly which modules are using which headers.

Hmm, odd. I have the definition of NatureRegion in GameMap.h. The function mentioned is within GameMap.cpp, which includes GameMap.h. I'll try sticking the class in its own header though. Also, should the above code work, how I wished it to function?
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7150 on: April 12, 2015, 07:52:40 pm »

you shouldn't need a separate .h file. you just need to ensure that natureRegion is properly on the #include path wherever it's used.

But i notice that you're saying both "NaturalRegion" and "NatureRegion", so check spelling.

I find namespaces can make errors more informative. if you had:

namespace gameMap
{
   // .h stuff 
   class NaturalRegion;
}

and refer to it as gameMap::NaturalRegion, then you get the error instead "gameMap does not include a definition of "NatureRegion", which is more informative than just "undefined".
« Last Edit: April 12, 2015, 07:58:26 pm by Reelya »
Logged

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7151 on: April 12, 2015, 08:02:40 pm »

The GameMap.cpp is something like 2000 lines so I'm just putting the function involved, unless you want it's entirety. It's currently incomplete, I decided not to do anything extensive until I had this sorted out.

GameMap.h
Spoiler (click to show/hide)

GameMap.cpp
Spoiler (click to show/hide)

That should be everything. I also tried separating them into different files, and that did nothing, as you had said.

Edit: This is the error that is thrown.
Code: [Select]
Release\obj\GameMap.o:GameMap.cpp:(.text+0x6323): undefined reference to `NatureRegion::NatureRegion()'

But i notice that you're saying both "NaturalRegion" and "NatureRegion", so check spelling.
Oh, sorry for the confusion. It seems I just did that in the pseudo code.

I find namespaces can make errors more informative. if you had:

namespace gameMap
{
   // .h stuff 
   class NaturalRegion;
}

and refer to it as gameMap::NaturalRegion, then you get the error instead "gameMap does not include a definition of "NatureRegion", which is more informative than just "undefined".

Just to be sure. You can have multiple classes in a namespace, correct?
« Last Edit: April 12, 2015, 08:07:54 pm by HavingPhun »
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7152 on: April 12, 2015, 08:09:51 pm »

Quote
2000 lines
How much stuff is handled in that file?
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

TheDarkStar

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7153 on: April 12, 2015, 08:18:34 pm »

I'm looking at wxWidgets for the first time (FOSS C++ application framework). Is there anything that I should keep in mind while using it?

Following up on this, I've spent 3-4 hours trying to get this to work. It's my first time installing a library and the documentation for doing this is rather lacking. Tutorials on the same wiki are for arbitrary versions and pick random problems to provide help for. Some of them assume that a reader has extensive knowledge of the subject already. I've googled several different things relating to problems, and I think I've solved most of them.

The error that I'm getting right now is essentially "ld.exe cannot find -lwxmsw30u". I'm using code::blocks and I've already looked through the wxWidgets files to see if a file similar to "lwxmsw30u" exists (but I didn't find it anywhere). Does anyone have any help to offer?
« Last Edit: April 12, 2015, 08:21:27 pm by TheDarkStar »
Logged
Don't die; it's bad for your health!

it happened it happened it happen im so hyped to actually get attacked now

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7154 on: April 12, 2015, 08:22:24 pm »

Quote
2000 lines
How much stuff is handled in that file?
Well, it has all the stuff for world generation, including the temperature, moisture, and biome functions. But really it could do with some pruning, there are a few functions that I don't even use anymore.

Also, Reelya, I added the namespace, and now it just says this for an error:
Code: [Select]
Release\obj\GameMap.o:GameMap.cpp:(.text+0x6323): undefined reference to `MapSystem::NatureRegion::NatureRegion()'

So, I am guessing that there is something wrong with this line, without it there is no error:
Code: [Select]
NatureRegions.push_back(new NatureRegion);
Just to note, NatureRegions is the vector containing the regions, it could probably use a better name. I'm not yet, quite sure of any other ways to do what I want that line to do.
« Last Edit: April 12, 2015, 08:24:53 pm by HavingPhun »
Logged
Pages: 1 ... 475 476 [477] 478 479 ... 796