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

Jesse Maurais

  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Jesse Maurais

  • Rank
  1. Quote:Original post by gjaegy FYI I am using boost::mutex and their implementation is quite good. I guess you don't want to introduce any dependency to boost in the library, but it might give you another implementation inspiration ;) Can't believe I missed this before, but you could use boost::mutex without dedicating yourself to a long-term dependency problem, because it's being adopted as the standard in C++09 (as well as boost::thread). And from what I understand a portable sockets implementation for inter-process communication will be in there as well.
  2. The only change I would make to the code above is the use of strerror to format the return values of pthread functions. And to write them using cerr rather than cout.
  3. I went through the chapter (in the online book @ lua.org) about creating C data arrays that can be written to and read from in lua. I modified it a bit to use float instead of double, like so... #include <lua.hpp> typedef struct { int size; float values[1]; } NumArray; static NumArray *check( lua_State *vm, int index ) { void *user = luaL_checkudata( vm,index,"array" ); luaL_argcheck( vm,user!=0,index,"array expected" ); return (NumArray*) user; } static float &getvalue( lua_State *vm ) { NumArray *a = check( vm,1 ); int index = luaL_checkint( vm,2 ); luaL_argcheck( vm,1<=index<=a->size,2,"out of range" ); return a->values[index-1]; } static int newarray( lua_State *vm ) { int n = luaL_checkint( vm,1 ); size_t nbytes = sizeof( NumArray ) + ( n-1 )*sizeof( float ); NumArray * a = (NumArray*) lua_newuserdata( vm,nbytes ); luaL_getmetatable( vm,"array" ); lua_setmetatable( vm,-2 ); a->size = n; return 1; } static int setarray( lua_State *vm ) { getvalue(vm) = (float) luaL_checknumber( vm,3 ); return 0; } static int getarray( lua_State *vm ) { lua_pushnumber( vm,(lua_Number)getvalue(vm) ); return 1; } static int getsize( lua_State *vm ) { NumArray *a = check( vm,1 ); lua_pushnumber( vm,a->size ); return 1; } static int tostring( lua_State *vm ) { NumArray *a = check( vm,1 ); lua_pushfstring( vm,"array(%d)",a->size ); return 1; } int main( int argc, char **argv ) { lua_State * vm = lua_open(); luaL_openlibs( vm ); luaL_newmetatable( vm,"array" ); lua_pushstring( vm,"__tostring" ); lua_pushcfunction( vm,tostring ); lua_settable( vm,-3 ); lua_pushstring( vm,"__index" ); lua_pushcfunction( vm,getarray ); lua_settable( vm,-3 ); lua_pushstring( vm,"__newindex" ); lua_pushcfunction( vm,setarray ); lua_settable( vm,-3 ); lua_register( vm,"array",newarray ); luaL_dofile( vm,"test5.lua" ); lua_close( vm ); return 0; } And here's the test code "test5.lua" a = array(1000) print(a) for i=1,1000 do a[i]=1/i end print(a[10]) a[1] = 3.14 print(a[1]) Finally, my output array(1000) 0.10000000149012 3.1400001049042 But obviously this is not what one expects. What it should be, and what it was when using double instead of float is array(1000) 0.1 3.14 I'm wondering where the error crops up. I thought at first it was due to casting, so I put some explicit casting in the code, which did not help. Any ideas out there?
  4. As mentioned above, its true that mutexes will block if the memory is already locked, but this should not be a problem. When blocked the other threads wake up. Thats a good thing. Blocking gives process management over to the kernel. Let the kernel do its job.
  5. Just lock/unlock a mutex around the sensitive memory to prevent it from being clobbered. Easiest solution I can think of. https://computing.llnl.gov/tutorials/pthreads/ This is Unix specific but has good information on the topic.