Results 1 to 4 of 4

Thread: spot light effect in platform game

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    12

    Question spot light effect in platform game

    what would be a good way to simulate a spot light effect for a 2d game ?

    the way i would do it if i could - would be to draw everything on the backbuffer, put a mask on it in the shape of a triangle (well something more complex but triangle would do for now) and then flip to the primary ...

    the thing is i want to be able to rotate the mask so that i could have my hero holding a torch so when he walks around all you see is a tirangle infront of him and nothing else ...

    more advanced i would want to have tranperancy on the edges of the triangle but not required at this moment....

    any advice would be great .. thanks
    note - i am using dx7
    Last edited by mydogma; Nov 19th, 2002 at 04:54 PM.

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    For rotation: Simple 90 degree rotation is easy. Get the new Pixel X and Y with this:
    VB Code:
    1. NewX = Width - Y
    2. NewY = X
    So, you can manually SetPixel/GetPixel your way out of that one. Actually, just saw you were doing directdraw.. so get/setlockedpixel or getlockedarray would be what you're looking for.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    12
    well the rotation angle is incremented by about 5 degress everytime you press left or right .. so not just 90 degree rotations.

    well what i am really asking i guess is the funtion that creats the mask. i never had to do masking before but what i have read is that it is used to create transparency effect.

    from what i understant you need to have a bitmap in the shape of the mask you want. the thing is; the light effect will be pretty big. over all about 30 percent of the screen... so the concern becomes would masking with such a big bitmap slow down the computer (if it works the way i think it does) .... also i would need to rotate the bitmap by some angle each time and then apply it as a mask.

    so it seems this would create alot of load and slow down the game ...

    is this how it is done ?

    note: when i mean mask i guess i am refering to the effect achived using photoshop mask ... putting a layer over a picture with a hole in it ...

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yeah, it would create tons of overhead. Listen, if you're looking to create a game with that much scale, just go full out 3D. You can't get this kind of speed in VB.... But anyway. I suggest doing the game at a smaller scale, or limiting the size of the flashlight (just a small cone, maybe one that fades out).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width