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


  • Content count

  • Joined

  • Last visited

Community Reputation

124 Neutral

About altich88

  • Rank
  1. Thanks for the advice, I've managed to split it up some more now (EventManager, EventCallbackStore and EventQueue). I haven't achieved full white box testing as my custom data structure tests rely on using add/retrieve methods in combination but I think that's as close as I can get without adding methods to expose the underlying data structures.
  2. Hi,   I'm trying to learn some architecture and design patterns in my latest project including the use of dependency injection and hopefully unit-testable code.   I've written a simple event manager and would like some feedback on its implementation. All functionality currently resides in a single class which features the relevant data structures to store events and callbacks as well as the public methods used to offer clients the required functionality.   public class EventManager { private static final String LOG_TAG = EventManager.class.getSimpleName(); private final int NUMBER_EVENT_QUEUES = 2; private int activeQueueIndex = 0; private Array<SortedIntList<Event>> eventQueues; private ObjectMap<Class<? extends Event>, SortedIntList<EventCallback>> eventCallbackMap; // Default constructor @Inject public EventManager() { eventQueues = new Array<SortedIntList<Event>>(NUMBER_EVENT_QUEUES); // Create the empty event queues for (int i = 0; i < NUMBER_EVENT_QUEUES; i++) { eventQueues.add(new SortedIntList<Event>()); } eventCallbackMap = new ObjectMap<Class<? extends Event>, SortedIntList<EventCallback>>(); } public void onUpdate() { // Iterates all events in the current queue and calls the registered callbacks for each... } public boolean queueEvent(Event event) { // Queues an event if there is at least 1 callback registered tor receive it (returns true)... } public boolean triggerEvent(Event event) { // Calls all registered callbacks for the given event (returns false is there are none)... } public boolean addCallback(Class<? extends Event> eventType, EventCallback callback) { // Adds a callback to the map, returns true if successful, false if already registered... } }   My concern is that my unit tests would not be able to probe deep enough when testing correct behaviour. In testing the addCallback function for example I would be limited to checking the boolean returned and would not be able to directly check whether the callback had in fact been added by looking at the last added item to the corresponding list.   Similarly for testing triggerEvent, I would first have to add a callback for a type of event (thus relying on a method outside of the current test), before calling triggerEvent and then checking to see if the callback executed (maybe by having the callback alter some variable I could watch or something equally horrible).   This doesn't feel right but I'm not sure how best to split this up so my testing can be more thorough.   Do the data structures of events/callbacks count as dependencies, or not as they are initially all empty?   Any comments would be greatly appreciated.
  3. Thanks for the replies, I think you're right in your thinking regarding the capped fps/sleeping thread theory. Everything runs much smoother with an unlimited frame rate. Interestingly I've noticed a similar problem whilst using Slick2D as well. As a quick fix for know I've set the limit to 200 so at least the GPU isn't spinning up too much. The lag spikes are now much less frequent. I'll try it on my work laptop after Christmas to see how a completely different graphics card behaves. Edit: As another point of interest, watching a video (YouTube in chrome) whilst playing the game causes serious lag issues, whilst simply pausing the video seems to be enough to avoid this.
  4. Thanks for your reply. I have changed the delta argument to a double but unfortunately the jerky movement persists. When you suggested not mixing nanoseconds/milliseconds/seconds, how would I avoid this? Presumably I need to use some sort of milli/nanosecond timer at some point and convert the returned value to seconds? As well as the new code I've also posted an example of how an object's position is updated and then drawn using the delta argument in case there is an error in the logic on that end too. The object's position is stored and calculated using doubles, but when it comes to drawing it I am forced to give integer x and y arguments to specify the pixel position - could this rounding lead to jerky movement? Many thanks for your help so far. public void run() { long desiredFPS = 60; long desiredDeltaLoop = (1000*1000*1000)/desiredFPS; long beginLoopTime; long endLoopTime; long currentUpdateTime = System.nanoTime(); long lastUpdateTime; long deltaLoop; double deltaSec = 0; while (isRunning) { beginLoopTime = System.nanoTime(); window.panel.repaint(); lastUpdateTime = currentUpdateTime; currentUpdateTime = System.nanoTime(); onUpdateGame(deltaSec); deltaSec = ((currentUpdateTime - lastUpdateTime) / 1000000000.0); endLoopTime = System.nanoTime(); deltaLoop = endLoopTime - beginLoopTime; if (deltaLoop > desiredDeltaLoop) { // Do nothing. We are already late } else { try { Thread.sleep((desiredDeltaLoop - deltaLoop) / 1000000); } catch (InterruptedException e) { // Do nothing } } } }   // position.x and position.y are doubles and 100 is the desired pixels/s to move position.x += (GameApp.deltaMs * 100.0); position.y += (GameApp.deltaMs * 100.0); g2d.translate(position.x, position.y); g2d.setColor(Color.GREEN); g2d.fillRect(0, 0, 100, 100);
  5. public void run() { long desiredFPS = 500; long desiredDeltaLoop = (1000*1000*1000)/desiredFPS; long beginLoopTime; long endLoopTime; long currentUpdateTime = System.nanoTime(); long lastUpdateTime; long deltaLoop; int deltaMs = 0; while(isRunning){ beginLoopTime = System.nanoTime(); window.panel.repaint(); lastUpdateTime = currentUpdateTime; currentUpdateTime = System.nanoTime(); onUpdateGame(deltaMs); deltaMs = (int) ((currentUpdateTime - lastUpdateTime)/(1000*1000)); endLoopTime = System.nanoTime(); deltaLoop = endLoopTime - beginLoopTime; if(deltaLoop > desiredDeltaLoop){ //Do nothing. We are already late } else { try{ Thread.sleep((desiredDeltaLoop - deltaLoop)/(1000*1000)); } catch (InterruptedException e) { //Do nothing } } } }   Hi,   I'm trying to implement a 2D game using the Java2D API. I'm using the code posted below in my run() method of my main thread to limit the framerate to a specific maximum.   Objects are moved by a distance calculated from the elapsed time between frames. The movement of said objects, however is noticeably jerky.   Could the problem be to do with the method used below? I've seen this type of thing used in several introductory examples to games in Java.   Many thanks.
  6. Hi, I'm trying to implement a component-based actor architecture for a game project. [CODE]public <T extends ActorComponent> T getComponent(int componentId) { // HashMap<Integer, ActorComponent> components; T component = (T) components.get(componentId); return component; }[/CODE] ActorComponent is my base class from which all my components inherit. The idea is that you can call [CODE] PhysicsComponent physics = actor.<PhysicsComponent>getComponent(PHYSICS_COMPONENT); [/CODE] The above code all works, but I have a feeling that surely the unchecked cast [CODE] T component = (T) components.get(componentId); [/CODE] can be avoided somehow? Any advice much appreciated.
  7. [quote name='swiftcoder' timestamp='1333975626' post='4929538'] I'm a fan of [url="http://www.fraps.com/"]FRAPs[/url]. It will dump a giant losslessly-compressed video to your hard drive, that then needs to be converted to a compressed codec before you upload to youtube. The advantage here is that because you perform the (very expensive) compression step as a post-process, you don't take nearly as much of a performance hit while recording. [/quote] Thanks for that, I've tried fraps and have to agree the output is great. What program do you suggest for converting to a compressed codec? I have no idea what settings etc to use and so far the resultant videos on YouTube have looked awful .
  8. I'm trying to record some footage of my OpenGL application to upload it to YouTube. What software should I have a look at for doing this? I'm absolutely clueless when it comes to codecs/encoders etc so any advice on where to start would be much appreciated. I'm looking to record at 480p. Should I be looking at some sort of screen capture software like Cam Studio? The output from this seeks OK but the files sizes are huge. Cheers.
  9. [quote name='SimonForsman' timestamp='1333486821' post='4928002'] [quote name='altich88' timestamp='1333481040' post='4927967'] Thanks all for your advice, I never new about debug running slower! [/quote] Just out of curiosity, what performance did you get with a release build ? Also, what resolution are you rendering at ? as the quads cover the full screen fillrate will be an issue at high resolutions even on a modern GPU. (at 30fps and 1000 fullscreen quads per frame you're basically redrawing the full screen 30000 times per second, at 800x600 that would be 14.4 billion pixels per second. The radeon HD 4890 has a fillrate of around 13.6 billion pixels per second(according to techreport) so just below 30 fps is pretty reasonable for what you are doing if that is the resolution you're using. [/quote] It was 800x600, *applauds the maths*. As for performance it doubled to around 60fps in release mode. Thanks for the info on overdraw etc, I've never tried that test before so was a bit worried something was wrong with my GPU but if it seems in the normal range that's cool.
  10. Thanks all for your advice, I never new about debug running slower!
  11. I've been playing about with OpenGL for a while now, but have never bothered to use anything other than immediate mode until now. I constructed the quick test code below to test the performance of immediate mode, but found that drawing 1000 textured quads to the screen yields a framerate of only ~30fps according to fraps. What is going on? I remember reading on here once that Quake 2 use immediate mode and rendered something like 10000 triangles per frame! My computer is a couple of years old but has an i5 and a 4890. Why isn't my code below running at a higher frame rate? [CODE] void display() { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glBegin(GL_QUADS); for(int i=0; i<1000; i++) { glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(screenWidth, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(screenWidth, screenHeight); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, screenHeight); } glEnd(); glFlush(); } [/CODE] Many thanks
  12. [quote name='RobinsonUK' timestamp='1329137514' post='4912567'] .. [/quote] Hey, Thanks for the reply. Yeah that does sound like a good idea what with the flexibility and all, thanks [img]http://public.gamedev.net//public/style_emoticons/default/cool.png[/img].
  13. Hi, I'm currently making a GUI in OpenGL and C++. The systems uses a family tree style structure, where each element has a number of child elements. A window say, could have several buttons and sliders as its children, for example. Each element has fields such as position, width and height etc. associated with it. All elements however use the same font for their text labels. I'm not sure where the best place for the UI's font would be. It would seem wasteful for each element to have a "font" field as it would be exactly the same for each element. Another thought was to have some sort of "UserInterface" class which would house the root element of the system, and therefore indirectly, all its children too. If the UI font was associated with this UserInterface class however, how would each element have access to it without every single element having a pointer to it? This seems a hacky way of doing things. What would be the best way to go about this? Cheers.
  14. Yes I'm completely with you on all that, sounds good. Thanks for all your help, it's definitely going to make this much easier!
  15. Awesome, thanks for that I'll give it a go.