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 ... 56 57 [58] 59 60 ... 78

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

ILikePie

  • Bay Watcher
  • Call me Ron
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #855 on: February 06, 2011, 03:07:32 pm »

Spoiler (click to show/hide)
I'd drop those braces, they look ugly.
Code: [Select]
if(!goOn && (a<sample(x+cur2, y, z)<b)){goOn = true;}
vs
if(!goOn && (a<sample(x+cur2, y, z)<b)) goOn = true;
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #856 on: February 06, 2011, 03:27:07 pm »

I'd drop those braces, they look ugly.
Ah, that solved everything! [/sarcasm] :P

I like em. Everything needs to be enclosed, or my scanning (reading the code w/o reading it) is severely hampered.

To do a<b && b<c I need:
Code: [Select]
if(!goOn){
  float b = sample(x,y,z);
  if(a<b && b<c){
    goOn = true;
  }
}
times 8. That's a line-inflation of 600%. I want to call "sample" as few times as possible, and keep stuff clean and small if possible. There's also the possibility that there's no way around this :(

I've got it! You can assign inside an expression!

Code: [Select]
float b; // can be reused
if(!goOn && (a<(b=sample(x+cur2, y, z)) && b<c))
Doesn't improve readability, but it works.
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))

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #857 on: February 06, 2011, 03:37:28 pm »

Just wondering, but are said cubes being compared lined up with the world axis or are they rotated at different angles?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #858 on: February 06, 2011, 03:56:52 pm »

Axis-aligned for now, but does it matter?
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))

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #859 on: February 06, 2011, 03:57:44 pm »

times 8. That's a line-inflation of 600%. I want to call "sample" as few times as possible, and keep stuff clean and small if possible. There's also the possibility that there's no way around this :(
That depends. If you're going for readability you could just write your own (inlined) comparer functions that takes a, b and c as it's parameters and use that as the body of the if-expression.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #860 on: February 06, 2011, 05:41:22 pm »

Yeah, that's what I'd do if I was doing it nice. :)
Solution works though. Now to find the "gaps"...
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))

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #861 on: February 06, 2011, 06:02:57 pm »

Ehh, you got it before me. I should read more carefully.
« Last Edit: February 06, 2011, 11:51:58 pm by eerr »
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #862 on: February 06, 2011, 06:23:10 pm »

It does, but I'm not sure what you'd want to do with them here?
Logged

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 #863 on: February 06, 2011, 08:45:00 pm »

Try

Code: [Select]
inline int is_between(float test, float low, float high)
{
    return test > low && test < high;
}
Logged
Eh?
Eh!

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #864 on: February 07, 2011, 05:26:26 am »

Yeah, that's even cleaner. It already works, though ;)

Edit: except that I don't use non-member functions. I don't know if I should, I never really had to.

In case anyone cares, what I needed it for:
Spoiler (click to show/hide)
« Last Edit: February 07, 2011, 04:56:55 pm by Siquo »
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))

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #865 on: February 07, 2011, 06:36:34 pm »

Lovely, but what willl you do with it?
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #866 on: February 07, 2011, 06:58:04 pm »

... making the most awesomest game EVER?  :D

This is for true 3D terrain generation (instead of a 2d terrain with a heightmap ::)), and (hopefully) easy and quick terrainmodification on any scale. Think... minecraft without cubes. With (almost) procedurally generated (almost) everything. Once I get there, the sky is the limit. Or the center of the earth is the limit, depending on which way you build/dig.
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))

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #867 on: February 07, 2011, 07:40:19 pm »

... making the most awesomest game EVER?  :D

This is for true 3D terrain generation (instead of a 2d terrain with a heightmap ::)), and (hopefully) easy and quick terrainmodification on any scale. Think... minecraft without cubes. With (almost) procedurally generated (almost) everything. Once I get there, the sky is the limit. Or the center of the earth is the limit, depending on which way you build/dig.

How will you handle terrain deformations?
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #868 on: February 07, 2011, 11:18:16 pm »

by the looks of things, that be a voxel engine.
Logged

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #869 on: February 08, 2011, 03:42:44 am »

Almostish.
I'm using the marching cubes algorithm recommended to me by Japa.
Spoiler (click to show/hide)
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 ... 56 57 [58] 59 60 ... 78