Author Topic: Nightmare  (Read 96841 times)

0 Members and 3 Guests are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Nightmare
« Reply #180 on: April 11, 2011, 02:19:20 am »
My favorite part was the part when all the dummies mob you and also when the entire place breaks out into flames :) Also the hallucination parts are cool. The end boss was kinda anticlimactic though.
Also it's not as fun the second time around :(
My favorite part is when you fall down into the Hallway of Shortening doom >:D

So when will you add the next level?
It's being worked on right now :) It has a lot of new features so its taking a long time, lots to code!

Remember earlier, when I said I was interested in porting this game to Xbox 360?  I still am.  Could you post, in detail, how you go about casting shadows?
Alright, there are 4 types of shadows that are cast by light sources (yes plural) in the game.  2 types of shadows cast for each of the 2 types of light sources.  The two types of light sources are the single Dynamic Light Source, and all of the Static Light Sources.  There is only a single Dynamic Light Source, but there can be any number of Static Light Sources.  As per their names, the Dynamic Light Source can move freely, and the Static Light Sources are fixed once they are created. 

First, here are all the Shadow Buffers I have in the game.  Shadow buffers are overlayed over the world Tilemap using OR logic.  Transparent parts of a Shadow buffer represent lighted areas, while black areas represent shadow.

Primary Shadow Buffer:
Shadows cast by the tilemap walls and objects are cast onto this buffer.

Secondary Shadow Buffer:
Shadows cast by certain objects are cast onto this buffer.

Flashlight Buffer:
This buffer creates shadow anywhere the flashlight beam is not pointing, as well as 'cutting holes' in the darkness wherever Static Light Sources are.

Darkness Buffer:
This buffer controls the overall darkness of the world. 100% is pitch black, while 0% has no effect (normal shadows).

The only reason there are 2 Shadow Buffers is so they can have separate transparency levels (since setting the transparency of a single image is faster than drawing many transparent rectangles).  The Primary Buffer is usually set at 100%, while the Secondary can be set to any level to give certain object shadows that are partially opaque.  The Flashlight Buffer also has a variable opacity, and can be changed to represent different 'intensities' of darkness.  The Darkness Buffer can be used to completely black the screen, and is actually a virtual buffer located inside the Flashlight Buffer.

Dynamic Light Source (DLS)

The Dynamic Light Source is usually tethered to the players flashlight, but can under certain circumstances be latched onto other objects such as Static Images or other NPC's, or simply set by the scripting engine to a certain location.  The Dynamic Light Source is represented by a pair of position coordinates, which is a global offset from the top left corner of the map.

Wall Shadows:
Wall shadows are shadows that the DLS casts on the walls of the tilemap.  All opaque walls are tile number 0, and are 40x40 pixels.  To cast the shadows, the engine readies a transparent Primary Shadow Buffer the same size of the screen.  The engine loops through all tiles that are on the screen, and chooses the sides that are facing towards the location of the DLS.  Using that side, and similar triangles, form a rectangle where the two sides next to the tiles side extend away from the location of the DLS all the way off screen, and are then connected with a 4th side to form a rectangle.  Fill this rectangle onto the Primary Shadow Buffer and repeat for all sides for all tiles on screen.  (this can be optimized by not drawing tiles that cannot be seen, but I haven't optimized it yet).

Object Shadows:
Object shadows are shadows that the DLS casts onto objects which support shadows.  Every object in the world has a Shadow Value, which ranges from 0 to 2.  0 means the object casts no shadow.  1 means the object casts shadow onto the Primary Shadow Buffer.  2 means the object casts shadow onto the Secondary Shadow Buffer.  Shadows for the Objects are cast in much a similar way as Wall Shadows.  Each object that casts shadows also has an array of lines that represent the bounds of the object shadow.  When the object's shadow is displayed, each line in the list of lines is extended away from the light source and draws a filled rectangle onto the Shadow Buffer that the object defines.

Static Light Sources (SLS):

Static Light Sources are pretty memory intensive.  Each SLS contains an image representing the light gradient it casts onto the world.  All of these gradients are sent to the Flashlight Buffer, where their images are subtracted from the overall buffer to create a kind of 'cut out' in the darkness of the flashlight.

Wall Shadows:
Static Light Sources are static so that Wall Shadows can be precalculated when the SLS is added into the world.  The method to do this is pretty much exactly the same as for the DLS, except you are casting shadows onto your own private gradient buffer instead of the Primary Shadow Buffer.  Static Light Objects also are initialized with a brightness value, which controls the transparency of the buffer upon initialization, and costs no extra CPU.  Transparency can also be changed dynamically during game, but at a small cost to recalculating the transparency controller.

Object Shadows
These are also done in a similar fashion as the DLS object shadows, but everything is handled by the Flashlight Buffer code.  When the SLS gradient is sent to the Flashlight Buffer code, its position, gradient bounds, light radius, and other information are also sent, to determine when an object is in reach of the light.  If it is, it uses the same arrays of lines in the object to cast a shadow onto the Flashlight Buffer.



I hope that was enough detail for you, the shadow engine is very complex, and there is still more I could go into detail with.  You could always check out the source code, as it is open source :)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #181 on: April 12, 2011, 07:41:58 am »
That seems really complex BuilderBoy, I love the lighting engine of Nightmare, it's very detailed, I guess that's why it's so complicated.

SirCmpwn

  • Guest
Re: Nightmare
« Reply #182 on: April 12, 2011, 08:16:51 am »
Thanks for the explanation!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #183 on: April 12, 2011, 10:05:25 am »
I just tried Nightmare (not for the first time, I had tried it before, but it was *very* different from now).

How amazing is this? This is just fantastic, awesome, no words to describe it. For a few moments I was really, *really* scared (I know that's the point).

I'd love it if this game was more famous.

I have a suggestion: Change cursor in game, the Windows mouse looks bad on it.

Which reminds me, is it just Windows? Cos in Omnimaga's homepage it says so, but Java is cross-platform.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Nightmare
« Reply #184 on: April 12, 2011, 10:13:36 am »
That seems really complex BuilderBoy, I love the lighting engine of Nightmare, it's very detailed, I guess that's why it's so complicated.

Thanks! :D The lighting engine is a work in progress that has *been* in progress for years, and I'm very proud of it, I think it really makes Nightmare what it is :)

Thanks for the explanation!

No problem!  So for the Xbox version are you gonna need some larger sprites or something?  We can be partners ^^

I just tried Nightmare (not for the first time, I had tried it before, but it was *very* different from now).

How amazing is this? This is just fantastic, awesome, no words to describe it. For a few moments I was really, *really* scared (I know that's the point).

I'd love it if this game was more famous.

I have a suggestion: Change cursor in game, the Windows mouse looks bad on it.

Which reminds me, is it just Windows? Cos in Omnimaga's homepage it says so, but Java is cross-platform.

Thanks so much :D What was your favorite part?  What was the part that really scared you?  And unfortunately I don't know of any way to change the cursor as of right now, but be sure I will do so if I figure out how to :) Its java, so it is cross platform.  Where does it say only windows?

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #185 on: April 12, 2011, 10:46:08 am »
@Builderboy: It doesn't say it's just windows, but if you check Omniaga>Home, it says "TI Calculator Projects" and then "Windows\n-Nightmare".

The scariest part was when the flashlight fell and I had to catch it and I was not sure if I had to catch it, but the X Ray part is pretty scary as well.

Looking forward for a XBox version of it :) (not to play though, I don't have one :()

EDIT:
I got to the part where it said 'Alert: To be continued', is it really the end of demo?
« Last Edit: April 12, 2011, 04:25:11 pm by Scout »

SirCmpwn

  • Guest
Re: Nightmare
« Reply #186 on: April 12, 2011, 04:37:38 pm »
I could probably make do if you just gave me all the resources you used (art, sound, etc)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #187 on: April 13, 2011, 04:48:52 am »
I could probably make do if you just gave me all the resources you used (art, sound, etc)

I'm pretty sure the 'Download Source Code' is big enough in the page. I think the images and sounds are there =D

SirCmpwn

  • Guest
Re: Nightmare
« Reply #188 on: April 13, 2011, 08:26:58 am »
I still need his permission to use them :P

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #189 on: April 13, 2011, 08:46:53 am »
I still need his permission to use them :P

Oh yeah, is this gonna be for Arcade or Indies? I guess Indies, since you need to pay for Arcade.

SirCmpwn

  • Guest
Re: Nightmare
« Reply #190 on: April 13, 2011, 08:54:08 am »
You need to pay for both :P but Indies.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Nightmare
« Reply #191 on: April 13, 2011, 08:55:02 am »
You need to pay for both :P but Indies.

We need to pay for Indies? That sucks, but ok, hope that when finished, a lot of people download it.

I meant, *we have to pay for Indies*, I meant the coders, not gamers, bad grammar, sorry.
« Last Edit: April 13, 2011, 09:52:18 am by Scout »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Nightmare
« Reply #192 on: April 13, 2011, 09:38:45 am »
Yeah go ahead :) I just want credit and a share of the profits >:D Are you going to raise the resolution or keep it the same?

SirCmpwn

  • Guest
Re: Nightmare
« Reply #193 on: April 13, 2011, 04:37:49 pm »
Builderboy, not sure yet.
As for pricing on XBL, you can't sell for free unless you're a first party

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Nightmare
« Reply #194 on: April 13, 2011, 06:09:35 pm »
What do you mean?  You cant put up your games for free unless you are first party?  Or that its only free for you to charge others for your games if you are first party?