• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    24
  • comments
    17
  • views
    45258

Flashlights and Things that Go Bump in the Night

Sign in to follow this  
Followers 0
toddbluhm

839 views

[color=#000000][font=Georgia,]Blog post by Dan, Programming Director at Demergo, (Sorry, I forgot to repost this here after it went live a week ago on the blog)[/font][/color]

[color=#000000][font=Georgia,]Setting the right mood in the environment surrounding the player is very important. A very difficult and many times incorrectly-done part of this is the lighting. Depending on whether the game is 2D or 3D, and if you want dynamic lighting all play into how difficult it is. As with most every other decision, your target device (computer, console, mobile devices, etc) and your target market will heavily influence the entire process; Devices have limitations, and different styles of games need different moods and environments.[/font][/color]

[color=#000000][font=Georgia,]With Fixbot, we wanted to have some lighting in one of the levels. We weren't really worried about having realistic shadows or dynamic lighting - we just wanted the idea of navigating the player in the dark with something like a flashlight to be another fun gameplay element.[/font][/color]

[color=#000000][font=Georgia,]With this being my first major game project using Cocos2D for iPhone, I hadn't done any form of lighting with it yet. I had done lighting (both dynamic and non-dynamic) in other PC and Xbox360 projects, using different 2D engines including Microsoft's XNA and the more cross-platform SDL. Even though I had done similar lighting styles with these systems, I was having trouble figuring out how to best do the lighting in Cocos2D. I think my biggest problem was that I was still learning the underlying core of Cocos2D: while Cocos2D is very advanced, and is a wonderful engine for indie developers because it is open-source, it was doing things a little differently than I was used to. Now that I have had more time to learn it, as well as time spent on digging through forums, blogs, and finally the engine's source code itself, I have a much better understanding of it.[/font][/color]

[color=#000000][font=Georgia,]At first, we tried doing the lighting in OpenGL. I had my best programmer, Ian, digging through OpenGL books and rewriting shaders to work with OpenGL ES (which is what Cocos2D uses). While Ian spent a week on that with minimal success (it just wasn't performing like we needed it to), I started researching again. I was digging through blogs and forums (and again the source code) looking for methods to do simple lighting in Cocos2D. I was looking for an old-school 2D approach to the lighting - have a light sprite on the screen, and color all of the other pixels on the screen based on their distance from the light. Another method I was looking for was where you have a black (darkness) overlay covering the entire screen, and then "cut holes" in it using the light's sprite (usually based off of the sprite's alpha values).[/font][/color]

[color=#000000][font=Georgia,]Eventually I found the start for what I needed in order to do the second method - cutting holes in an overlay. My biggest worry going in was performance - for the lighting we wanted, we didn't just want to have the player have the only "flashlight" - we wanted objects in the environment to have lights as well. This is when I found the CCRenderTexture class in Cocos2D. It's a very powerful tool that can be used to do multiple things, including blending and masking.[/font][/color]

[color=#000000][font=Georgia,]So, in order to create our lighting effect, I have a CCRenderTexture that covers the screen and is black. Then, every tick, it gets updated according to whether there are lights currently visible on the screen. It's always good to narrow down how much you are doing in a tick method to help keep performance high.[/font][/color]

[color=#000000][font=Georgia,]My update tick works something like this:[/font][/color]

  • Begin drawing on the CCRenderTexture
  • Clear the CCRenderTexture with black to make it look dark
  • Set the color mask to ignore everything but the alpha channel
  • Find all of the lights that are actually visible on the screen. This narrows down how much drawing is being done.
  • Draw the visible lights (CCSprites have a 'visit' method)
  • Reset the color mask back to normal
  • End drawing on the CCRenderTexture

    [color=#000000][font=Georgia,]Overall this achieves our desired lighting effect, and with a decent amount of testing it's proven to be performance effective as well. Now, our players have flashlights so that they can see the things that go bump in the night.[/font][/color]

    [color=#000000][font=Georgia,]Reposted from Fixbot Blog[/font][/color]

2
Sign in to follow this  
Followers 0


0 Comments


There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now