Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 17 18 [19] 20 21 ... 91

Author Topic: Programming Help Thread (For Dummies)  (Read 100633 times)

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #270 on: August 25, 2011, 12:23:45 am »

@3:
IIRC libtcod has two stages for determining lighting: a luminosity determining step based on distance to the source, and a diffusion step that diffuses light across a room. The luminosity determining step is basically just a polar function (which means that the intensity of the light depends only on the radius (i.e. distance from the square to the light source), and in some cases the angle (such as for his variable radius light). For the second step, I haven't looked through his methodologies, but it looks like he's using some sort of simple diffusion algorithm, which will work regardless of what kind of light you are shining (well, should look anyways).

However, keep in mind that line of sight is not the same thing as luminosity. They are two separate effects and you might have an easier time thinking of them as separate steps: first calculate the light in the room (will be a color), then calculate the visibility (between 0 and 1). Then multiply the visibility by the color of the light to get the final color.
Logged

3

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #271 on: August 25, 2011, 01:11:29 am »

I guess I could say that's enlightening. HA HA. It'll certainly help later on if the project ever gets far enough. Thanks.

For the moment, at least, Siquo's idea looks good for my purposes since all I'm trying to do is get the regular FOV in a tighter radius.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #272 on: September 20, 2011, 05:35:24 am »

GAMES PROGRAMMERS, I SUMMON THEE!
Ok, so here is the problem, 2d array of tiles to make a 2d level.
I want nice smooth scrolling at you move across.
To achieve this, I have a 2d vector for the top left of the camera.
I divide the vectors value by the size of a tile to find the first tile in the array I need to draw.
I then modulos the vectors value by the size of the tile to find the offset, and subtract this from the initial draw location.
Because of this, if I draw just enough tiles to fill the screen then when I am half way through scrolling over a tile it leaves an white gap along the edges.
To fix this, I print one more tile than the minimum required to fill the screen, filling the space.

However, when I get to the 'edge of the level', so to speak, that is to say the last tile in the array, it tried to print one more across, thus giving me an index out of bounds exception.

WWSED?
(What would somebody else do?)

olemars

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #273 on: September 20, 2011, 06:02:48 am »

Stop scrolling at the second to last tile.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #274 on: September 20, 2011, 06:13:07 am »

The problem then is that then they can't see the very edge of the level. I was thinking of making the level generator add an extra row and column to the edges of the level that is never printed, but that seems like bad form...

Shades

  • Bay Watcher
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #275 on: September 20, 2011, 06:38:23 am »

The problem then is that then they can't see the very edge of the level. I was thinking of making the level generator add an extra row and column to the edges of the level that is never printed, but that seems like bad form...

Stop scrolling at the second to last tile.

This seems like the way to do it. You should still be able to show the last square because you don't need to display the extra tile until you move that extra pixel. This is course is impossible as you stop scrolling before that can happen. Just make sure your formula isn't picking up the extra square when it doesn't need it.
Logged
Its like playing god with sentient legos. - They Got Leader
[Dwarf Fortress] plays like a dizzyingly complex hybrid of Dungeon Keeper and The Sims, if all your little people were manic-depressive alcoholics. - tv tropes
You don't use science to show that you're right, you use science to become right. - xkcd

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #276 on: September 20, 2011, 06:40:56 am »

Eh, guess I'm going to have the ends of my array full of empty. Well crap.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #277 on: September 20, 2011, 07:25:04 am »

Check your drawing logic, it might be that you're accidentally accessing one more row/column than you need to, which would give you the error. If that's not it, I could have a look at your code to see if something else is wrong.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #278 on: September 20, 2011, 07:38:16 am »

I have a quick fix going, but it isn't what I would call elegant at all.
I'll throw in some comments, zip it up and send it to you if you would be that willing. Have you got xna? And do you have a preferred file depot?

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #279 on: September 20, 2011, 08:04:11 am »

Check bounds before you access the array?
Or is that just crazy talk?
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 Help Thread (For Dummies)
« Reply #281 on: September 20, 2011, 08:19:30 am »

Checking bounds is possible, but that doesn't fix the real error in the code, which could rear it's ugly head at any other point. I don't assume Max is so desperate to get this shipped that he'd prefer to use hacks instead of taking the time to code properly.

I have a quick fix going, but it isn't what I would call elegant at all.
I'll throw in some comments, zip it up and send it to you if you would be that willing. Have you got xna? And do you have a preferred file depot?
I don't think I've still got XNA after my recent cleanup, but I'll first take a look at your code in a text editor to see if I can spot anything. If the problem starts to hurt my head I'll go fetch a copy of it for testing. Also, any file depot is fine with me.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #282 on: September 20, 2011, 08:23:27 am »

Eh, I always just use Gmail these days, so I don't really have one that I ever use. Was fishing for recommendations.  :P To google!

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #283 on: September 20, 2011, 08:25:57 am »

Oh in that case, I could recommend Dropbox. I typically use that if I need to share something over the web or between my own computers.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: Programming Help Thread (For Dummies)
« Reply #284 on: September 20, 2011, 08:44:23 am »

I'm hoping that is structured enough to be easy to follow.
Pages: 1 ... 17 18 [19] 20 21 ... 91