Wednesday, July 15, 2015

BobEngine v3.0 Bobsled

It's been a while, but in the time since my last update I've added a lot of new things to BobEngine. Since it's such a big update, I'm giving it a new version name: v3.0 Bobsled. Here goes:

  • RoomCache - In BobView.java you will find a new static class called RoomCache. As the name implies, RoomCache is used for storing and retrieving instances of Rooms. The nice thing about RoomCache is that you can call getRoom(Class roomType) with any class type that inherits Room and the function will return an instance of that room type, even if you haven't manually added a Room of that type to the cache. The function getRoom(...) will search the cache for an instance of roomType and return it if one is found OR it will create a new instance of roomType using reflection and return that. You'll also notice that there is a getRoom(Class roomType, Object... args) function. If you have created a room type that takes parameters other than (BobView view) like a default Room does, you can use this method to pass the required arguments to initialize a new instance of that room type if need be. The cache holds a specified max number of Rooms. When the cache is full and a new Room is added, the oldest Room is removed. You can make your own RoomCaches, but each BobView has it's own cache with an initial size of 3. To access it from your BobView, just call getRoomCache().
  • Along with RoomCache, BobView has received two new goToRoom overrides: goToRoom(Class roomType) and goToRoom(Class roomType, Object... args) for switching to rooms retrieved from the RoomCache.
  • Input events (newpress, released) are now handled on the main thread (same thread as step event). Handling game logic on the separate input thread was causing a lot strange glitches in my games when values were being changed when I was not expecting them to be changed. Now, input will be handled on the same thread just before the step event.
  • For even more convenience and even quicker game development, a new constructor has been added to GameObject: GameObject(Room room). This will automatically assign an instance ID number AND add the object to the room. What typically looked like this before:
    Code:
    GameObject object = new GameObject(room.nextInstance(), room);
    room.addObject(object);
    Now looks like this:
    Code:
    GameObject object = new GameObject(room);
    So simple! The old constructor is still there and behaves the same way for those who want it and for backwards compatibility.
  • Setting GameObject.visible to false will now hide all Quads belonging to that GameObject. This will not change the Quad.visible field for any Quad. Also, similarly to GameObject, Quads are now added to the GameObject when initialized.
  • Animations can now be played once and looped for a limited number of times. animationFinished() will return true when an animation has finished playing.
  • Animation class - a new class has been added to GameObject.java. This class can be used to predefine animations with a start frame, end frame, fps, and loop times.
  • Previously, I was using 3 coordinates for each vertex. I learned it's possible to use only 2 in OpenGL. Since the 3rd vertex is not needed, I changed the code to use only 2 vertices. I'm not sure if this actually caused any performance improvement.
  • Graphic.Parameters class - A new class in Graphic.java allows you to predefine Graphic parameters to use with GameObject.setGraphic(Graphic.Parameters params). Useful for when you want to switch between graphics on a GameObject often.
  • A new method in the Graphic class called setDimensions(int width, int height) allows you to set the height and width of the DPI level image you want to use for setGraphic(Graphic g, int x, int y...). Previously, you would have to use setPreciseGraphic(...) if you had different sized images for different DPI levels that have multiple graphics on them.
  • Set the color intensity of all GameObjects on a specific layer using Room.setLayerColor(int layer, float r, float g, float b, float a).
  • Graphics management (this is a big one):
    The Room, Graphic, and GraphicsHelper classes have been updated to improve and simplify management of graphics for large games. A new GraphicsHelper.cleanUp() method makes it easy to manage graphics. You can choose points in your game to call cleanUp(). When called, Graphics that have not been used recently will be unloaded and removed from the GraphicsHelper. Graphics have a new public field called 'persistent' which when set to true will cause the graphic to remain loaded when cleanUp() is called. All non-persistent Graphics will survive through a set number of cleanUp() calls before they are removed. If a Graphic is removed but then a GameObject tries to use it again, it will automatically be re-added to the GraphicsHelper and reloaded.

    You can also manually call:
    Graphic.load() to load a graphic after is has been added to the GraphicsHelper.
    Graphic.unload() to unload a graphic
    Graphic.remove() OR GraphicsHelper.removeGraphic(Graphic g) to unload and remove a Graphic from the GraphicsHelper.

OKAY, I think that's just about everything. I actually had to look through the changes in the GitHub commit to remember all the things I've changed xD There are a few other small changes but I didn't think they were important enough to list.

I'm tossing around the idea of doing a tutorial series for BobEngine. It would be a video series on my YouTube channel. I would start with the basics, then explain more advanced features like graphics management. I could also take requests for certain tutorials. I could even cover general game development topics and how to implement them with BobEngine. Doing this would be a lot of work so before I dive in I really want to gauge the level of interest in BobEngine. So far, it's been difficult to tell how many people are interested because I haven't gotten an overwhelming amount of replies here but every once in a while I get a PM or email asking for help. So if you're using BobEngine raise your hand! :P

And of course: if you've made anything with BobEngine I would love to see it! I've seen a few things and it makes me happy to see you guys using getting some use out of my engine.

Thanks for your time! If you have any questions, just ask. If you find any issues with BobEngine, go ahead and open an issue on GitHub and I will fix them. Also don't forget to let me know if you're using BobEngine!

Once again, the repo can be found here: https://github.com/Bobbyloujo/BobEngine


Ben Blaszczak
a.k.a. Bobby Lou Jo 

1 comment:

  1. i am interested in learning bobengine. I would suggest creating a few introductory videos for beginners so as to give the people who have no idea a chance to figure whether its worth it or not.

    ReplyDelete