Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 ... 20 21 [22] 23 24 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 95869 times)

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #315 on: August 01, 2010, 07:21:00 pm »

The problem with system("pause") is that it requests the console it is running in to pause for it. Other uses of system() are certainly platform dependant and probably better to avoid. I gave two pieces of code: One is a .bat file that would run the program and pause it, emulating the IDE, the other is a function that would pause the program, though not quite as well as system("pause").
Logged
Eh?
Eh!

IHateOutside

  • Bay Watcher
  • Fire safety is for wimps.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #316 on: August 01, 2010, 07:47:26 pm »

I meant the function. Well, I'm tired so off to bed right now. Will sort it out when I get up later.
Logged

ed boy

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #317 on: August 02, 2010, 06:49:37 pm »

This might be outside the scope of this thread (and if it is, can you say and I'll create a new thread), but does anybody know where I can find some 3d terrain generation algorithms?

I want to create a script that will output an array of voxels that will represent a planet. It would be divided up into three main parts: atmosphere, surface, and magma. The algorithms that would be used for the atmosphere and magma would be simple: just spheres, with all undefined voxels inside those spheres defined as atmosphere/magma. However, the surface is proving to be a different matter entirely. Although I could just go for a spherical surface, that would be boring and uninteresting.

I have found other algorithms in the past, and they have given very nice results, but they have been not quite what I want. Most algorithms start with a two-dimensional area and then extrude the points perpendicular to the original area. This gives very nice results, but it only be satisfactory for a small part of the planet's surface, not the whole thing.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #318 on: August 02, 2010, 08:12:25 pm »

http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=blogcategory&id=0&Itemid=47&limit=6&limitstart=6
Those might help; quite a few are about terrain generation on a spherical planet IIRC. Particularly the early ones (page six and up).
« Last Edit: August 02, 2010, 08:14:10 pm by alway »
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #319 on: August 02, 2010, 08:41:10 pm »

This might be outside the scope of this thread (and if it is, can you say and I'll create a new thread), but does anybody know where I can find some 3d terrain generation algorithms?

I want to create a script that will output an array of voxels that will represent a planet. It would be divided up into three main parts: atmosphere, surface, and magma. The algorithms that would be used for the atmosphere and magma would be simple: just spheres, with all undefined voxels inside those spheres defined as atmosphere/magma. However, the surface is proving to be a different matter entirely. Although I could just go for a spherical surface, that would be boring and uninteresting.

I have found other algorithms in the past, and they have given very nice results, but they have been not quite what I want. Most algorithms start with a two-dimensional area and then extrude the points perpendicular to the original area. This gives very nice results, but it only be satisfactory for a small part of the planet's surface, not the whole thing.
be careful, filling 3d areas is sort of stubbing the line into calculus.

how do you want the magma deposits and such to vary?
Logged

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #320 on: August 02, 2010, 08:52:48 pm »

Blech. No help whatsoever on how to translate images? Not even from qwertyuiopas?

@eerr:
Filling 3d areas is most definitely not calculus, I'm not sure where you're getting this from, eerr. Name your sources. "Filling" 3d areas is much the same as filling 2d areas (although the definition of 'filling' here is rather vague, and some further clarification is needed) - doing most things in 3d is usually just a simple extension of 2d geometries.
Logged

alfie275

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #321 on: August 02, 2010, 09:31:36 pm »

Idea: Diamond square algorithm with wrapping, each value being how far it is from the centre of the sphere.
Logged
I do LP of videogames!
See here:
http://www.youtube.com/user/MrAlfie275

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #322 on: August 02, 2010, 09:47:29 pm »

Yep, as stated, simple concentric 3D spheres are easy:
distance = GetDistance(planet.center, voxel.position);
if(distance<x and distance>y)
voxel.type = z;
else if...

No calculus involved. More complex than simple spheres and it gets more difficult, since distance from center and position on the surface must be taken into account and thus a coordinate system of some sort on the surface must be used. And then since the patterning desired on the surface is meant to represent that of the real world, one must figure out how the form of the features will be. Still no calc there unless your terrain features are really odd.
Logged

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #323 on: August 02, 2010, 10:52:58 pm »

Idea: Diamond square algorithm with wrapping, each value being how far it is from the centre of the sphere.
Noise functions will generally be faster and create more realistic-looking terrain. Diamond-square has few correct, or even good, use cases.

Layered noise functions are the simplest, fastest way to do a decent-looking terrain generator.
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #324 on: August 03, 2010, 06:19:03 pm »

Blech. No help whatsoever on how to translate images? Not even from qwertyuiopas?

@eerr:
Filling 3d areas is most definitely not calculus, I'm not sure where you're getting this from, eerr. Name your sources. "Filling" 3d areas is much the same as filling 2d areas (although the definition of 'filling' here is rather vague, and some further clarification is needed) - doing most things in 3d is usually just a simple extension of 2d geometries.
Oh
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #325 on: August 07, 2010, 01:17:30 am »

Will a pointer set to point at an instance of a class in a vector work after said vector has members added or removed? Because my pointers are spontaneously combusting for some reason.
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #326 on: August 07, 2010, 08:44:46 am »

Reallocating vectors involves resizing arrays, and frequently allocating them to new places.

That is to say, your pointers are not safe after adding or removing members to vectors.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #327 on: August 07, 2010, 06:07:53 pm »

Awesome, problems (mostly) solved, thanks!
Logged

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #328 on: August 09, 2010, 08:20:35 pm »

I've searched Google pretty hard, and I consider myself a master at it.

I need to find a way to find out the current text color in the windows console.

I want my function to print text in a certain color, then return it to the previous color.
I am already using windows.h for resizing and stuff, so I may as well use it to get console attributes.
Does anyone have any experience with this, or know of a link to a good resource?

EDIT: I've considered using external values if nothing else is found.
« Last Edit: August 09, 2010, 08:30:16 pm by Outcast Orange »
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #329 on: August 09, 2010, 08:44:10 pm »

Ouch. Google mastery, of all things, comes up short? How terrible! A "Google master" can't find it--

http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=windows.h+get+current+console+color
http://www.dreamincode.net/code/snippet4313.htm

--oh. First search, fourth result. Not even below the fold.

Hell. I guess I'm the Google master here. Does it come with a funny hat, or just a lack of perspective?
« Last Edit: August 09, 2010, 08:50:24 pm by Blacken »
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235
Pages: 1 ... 20 21 [22] 23 24 ... 78