• 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
davidwik

Tailored logic and events in SDL2 game

0 posts in this topic

Hi everyone,

this is my first post here on gamedev.net

 

I have started to create games in SDL with C++. I've just moved over to SDL2 and I really enjoy producing games as a hobby. I love working with music, sound, graphics and code.

 

The first game I made was a top-view space shooter, with very simple structure with only a hardcoded menu, and play game loop.

 

So I felt ready to start with a larger project. In the new game I've introduced new concepts like camera, gamestates and other things. And a lot more story line. In simple terms it will be a 2d space shooter, with rpg elements. To be fair I believe it will be a hobby project that will span across 1-2 years.

 

This is how I imagne it to work:

 

- The game creates a new gamestate via a factory.

 

The game inits the gamestate (loading resources, preferrable from an xml, json) and

populate a big vector of gameObjects. A gameObject could be a tile, sprite, player etc. Pretty much anything

that has a coordinate and a graphical represententation on the screen.

 

The game loop:

  • gameState->listenToEvents()
  • gameState->updateLogic()
  • gameState->render()

Everything here is find and dandy and works really well for me. However, in a later stage I need more logic that introduces cutscenes and conversaions, and missions. I would also like to be able to create tailormade levels in form of game events.

 

To accomplish this I been thinking about two approaches:

  1. Create a class that works as "director" in the gamestate which can access all objects in the gameObject vector, with very specific functions and checks different conditions. It reads the different conditions and events from an xml, json file. This approach is probably the quickest one to implement, but it's hard to make it flexible and I feel I still have to write a lot of hacky C++ code that needs to be written to "customify" the levels.
     
  2. Use a interpreted language for the logic and initialization. I've been looking into incorporating Lua into C++, and it doesn't seem too difficult. When a gamestate is fired, it reads level data from a lua script, that instantiates all the gameObjects to the gameState. On the C++ side I guess I have to create somekind of API for lua to access.
    This has many upsides since I can edit a script while running the application, no need for recompiling everything, and a lot quicker to produce levels, and custom made missions. So all the hackyness is in the Lua files and clean "engine-code" in the game. The biggest downsides with this I believe are performace and debugging.

 

I feel that the latter alternative is most appealing, but I'm very unsure where to put all the logic from lua. I still need a gameloop, and it needs to read the lua code each "frame" to check for conditions and events. So performance-wise it seems a bit of a waste? Since interpreting Lua must be a bottleneck (on every game-loop iteration)? Where else could I place the interpretation code?

 

So of you've done anything like this before or have ideas on how to tackle this approach, please let me know!

I've been googling for several days to get some pointers on how to tackle this and I would like to have a clear idea before starting coding something that might be a very bad solution.

 

Thank you for taking the time to read this rather long post =)

Edited by davidwik
0

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0