This Week
Hello again TeamLiquid!
Welcome back to my blog about the development of The Adventures of Sam the Pirate, the 2D platformer I'm creating as the final game project for my Bachelor of Software Engineering degree. Last week I covered some of the User Interface work that I've done, and showed off a new piece of concept art. No new concept art this week, but I'll be going over the continued work on the user interface, and the start of work on the editor.
User Interface
As mentioned last week, the layout and other information for a specific interface layout is stored in a file. When I want to use a specific interface for a screen, such as a menu screen, the file is simply loaded, the UI system creates everything needed, and then it can be rendered over the top of everything else. Absolutely everything to do with the layout is stored. The number of UI elements like buttons and static images, the art used for each, their positions, their height and width, etc, everything needed to allow my UI system to create an interface that can be displayed.
As I mentioned in last weeks blog, I wasn't too sure how to give each button unique functionality without creating a different class for each button, which is inefficient and doesn't fit with my design goals of making things as generic and reusable as possible. I ended up doing what I talked about last week, using lua in a similar manner to how I used it in my debug console, which I talked about in a previous blog.
I could have also used the observer pattern, (where observers register with a button and can implement an OnClicked function or something similar, that is called anytime the button is clicked), but I'd totally forgotten about it, despite using it elsewhere and having seen it used in this manner before. Even if I had remembered, I'm not entirely sure I would have used it over the approach I have taken. While it would work, and both methods feel like they have about the same amount of work in them, I still prefer the lua method as it generally seems to fit with what I'm wanting to do. With the observer pattern, everything is done in code, but some changes would require a recompile of the project. With lua, I can change more things, like adding/removing UI elements, without having to recompile the code. It also feels like it would be easier to bring this code over to a new project and use it the system straight away.
With all the details for a layout being stored in a file, it is a bit of extra work in filling out all the details manually, and trying to manually position UI elements correctly, but as I was planning on creating a level editor, I've decided to simply expand the level editor by giving it the ability to edit interface layouts visually. More work now to save work later. This would also open up the possibility of giving the editor to an artist, so they can ensure that any UI art they have done is all positioned correctly and looking good.
Editor
Started work on my editor this week. As mentioned, initially it was just going to be a level editor, but with my work on the user interface stuff I've decided to add interface layout editing functionality, turning it into more of a generic editor to go with my framework.
I'm creating the level editor part first, as it will allow me to quickly create/edit levels visually, rather than trying to do them by hand, which is super important for saving time later. So far I've got a grid the size of the level being rendered, and you can scroll around it without going over the edges. This scrolling is done by holding the right mouse button down and moving the mouse around, but I'll probably look at adding scrolling by simply moving the mouse to the edges of the screen as well. I've also thought about adding a minimap, but that's pretty low priority at the moment.
The current plan is for a right click to bring up a menu, allowing me to change what tool I'm using, what tileset is being used for the art, etc. Tiles and other level elements like the player start position, enemy start positions etc is done with a left click. Hitting the Escape key would bring up a menu allowing me to save, load, switch editors, etc. A lot of this stuff would also likely be keybound, so I wouldn't necessarily have to open menus all the time. To make things a bit easier, I won't have to select the right tile piece, such as a corner for a corner, and simply be able to "paint" where I want platforms to be. To make sure the right tiles are selected for each square, I'll have an algorithm detecting the surrounding tiles and selecting the right piece of art. I'm not entirely sure this description will make sense to you, so once I have it all figured out I'll go over it in a future blog, with pictures!
Unfortunately for you, the reader, I'm not planning a public release of the editor at this time, so making the editor easy to use for someone who isn't me is not a big deal right now. I would like to potentially release it and allow for easy sharing of levels through something like the Steam workshop, or setup my own server for this, but there most definitely isn't time to do this right now. I'll have to see how things go after release and after I graduate.
What's next?
I'll continue working on the editor over the next week, the next step is to get tools working, and start being able to place tiles. This will include working on the algorithm to make sure that the right art pieces are selected for the correct tiles.
I should look at documenting what functions are available to Lua, as well as what they do, what their parameters are etc. Should also look at adding some more commands to the debug console, as I've been a bit slack and haven't added any since it was created.
I'd like to start showing off some screenshots, and soon video of the current state of the game as well, but unfortunately I'm a bit embarrassed about the art situation at the moment haha. Tiles and the main character are just white boxes with some text on them at the moment, so there isn't much to show off! Once I start to get more art and things start to take shape, keep an eye out for screenshots/videos!
Keep up to date!
Be sure to follow me on Twitter, and like the Facebook page to stay up to date on future content and blog posts when they happen. If you have any questions don't hesitate to ask, either through Twitter or Facebook!