A Decade of Game Development

Happy New Year everyone! It’s 2020, meaning it’s the start of not just a new year but a new decade (at least your one of those people insistent that the decade starts on 2021)! Needless to say, it has been a full ten years, and it’s fitting that nearly ten years earlier I started working on a computer game for an Extended Project at my Sixth Form project. I did a brief summary of what I’ve done over the last decade on Twitter, but I figured I’d write about what my experience with game development has been like. I won’t write in detail about every game and related projects I’ve ever worked on (at this point it’s 48, not including some of the game jam projects that didn’t get finished), but to give some highlights. You can check out all the games I’ve worked on here, as well as the academic stuff here.

First game

I’ve always enjoyed playing video games, and it had crossed my mind on a number of occasions to have a go at making my own one. Problem was that I struggled when it came to trying new things on my own if I didn’t have someone to instruct me I’d get lost and eventually give up. I remember looking through DarkGDK and an old 3D game engine, and the tutorials were confusing so after a few days I gave up. Even when I was 16, I didn’t even think of being a programmer or a games developer (I originally wanted to be an electrical engineer) until one day where I took a class that was meant to demonstrate what you’d learn if you took Computer Studies as an A-Level course. Having a good teacher who could walk you through writing code (in Visual Basic .NET) effectively got me to consider taking up programming instead.

Game development was something else, I remember at the start of the year there was plenty of encouragement to do what’s called the AQA Extended Project, which is basically an assignment that students have a year to create on any given (approved) topic of their choosing. It’s the equivalent of half an A-level grade, and it’s advertised as being good on a University application because it’s extracurricular work. I remember in one of the numbers of presentations that the teacher speaking about it saying something to the likes of “You can do a project on almost anything, such as something you do on a daily basis like taking care of an animal, a certain subject you’re interested in, or a particular hobby you have. One year, someone made a computer game for their EPQ, if you want to try that, you can.” and almost immediately on my mind, I thought I should try that.

For the report, I looked at a number of tools at the time and stumbled onto Game Maker 7 (I later moved to Game Maker 8 when that came out). I read on a couple of websites that it was used in secondary schools for creating games, and it looked like you simply needed to understand flow charts in order to do stuff so I downloaded it and tried the tutorials. For the time, they must have been the most straightforward and clearest tutorials I’ve ever used. It took me less than a day to make a vertical scrolling shooter similar to 1942 just from following a PDF document, so I figured for the project I’d turn it into a horizontal scrolling shooter. I was also a fan of a sprite-based Final Fantasy webcomic called 8-Bit Theater by Brian Clevinger, so I figured I’d use Final Fantasy sprites and make it a fan-game: 8-Bit Theatre: Black Mage is in a Shooting Game.

Looking through all my documents, I think it’s safe to say I might have been a bit too ambitious for a first project. According to the design document I wrote for it, I was hoping to create eight levels, each with a boss battle (in the end, I only managed two levels and one boss battle). I even gave the game a full plot synopsis even though I never found the time to implement a game’s storyline. The game was also purely developed using the Drag and Drop visual scripting tool, which did enough that I wanted to do although more experienced Game Maker developers don’t even touch it and do everything almost entirely through Game Maker Language. That being said, I did try some of the more intermediate tools within Game Maker such as Timelines and Paths, and the boss I did end up making was massive. Regardless, it was definitely a learning experience, and it was a fun project to do in-between school, homework and a part-time job as a school cleaner. The teachers definitely thought that my game, even in an incomplete state, was an accomplishment and recognized that I had skill and drive. In some aspects, I probably had a bit too much drive, I made a gameplay video of it and put it up on a Youtube channel, pretending I was a games company called YARGHgames (I’m pretty confident it was an acronym but I cannot recall what it actually stood for). Still, we all have to start somewhere. I did try to remake this game back in 2018 for a games jam, and although I never went further than the original, I think the fact that I could remake what was more than a years work back in 2010 in around a single week in 2017 shows I must have improved somewhat.

University

When it came time to apply for University, wanted to do Games Programming as a career, with the hopes that I could write code for games on the major video game consoles. I originally chose to do games specific courses, but my parents insisted that I go to the more general computer science route instead. Neither of my parents had much of a background in computers and didn’t think there was a good chance in getting into games, and in fairness neither did my A-level teachers. My cousin was the one who recommended me to look into Staffordshire University because of the games and computer courses, and I made it my first choice. I enrolled as a Computer Science student in the latter half of 2011, and after taking an optional module in games programming I decided to transfer before the end of the first semester (I was able to convince my parents that I should do it, and early enough so I don’t have to do additional modules to catch up).

Most of my work was purely academic, the most game-like stuff was a Pac-Man clone and one where you controlled a goldfish. I did pick up a lot of stuff using Microsoft XNA and C#, as well as some early 3D programming using OpenGL (with the really old framework GLUT) and then later DirectX. I even spent three months at a Summer Camp in Hawley, Pennsylvania where one of the activities I did was teaching C# and XNA. I didn’t try to make proper games until two things happened: Game Jams and Microsoft.

First one was Global Game Jam 2013, I went mostly because I knew two of my friends were taking part. Staffordshire University was the largest GGJ site in Europe for a number of years, so you got to see a lot of people get involved. Joining one of my friend’s team, we worked in XNA to create this top-down driving game we named Anarchy Ambulance in a similar vein to crazy taxi, except you’re running people over and delivering their hearts (incidentally, this was the same GGJ where Surgeon Simulator was made). It was a terrifically fun project to work on and it remains one of my favourite team-projects I’ve worked on, we were able to get a lot done and had a laugh doing it. I didn’t think it was entirely possible to get the game done in two days, but James and I managed to pull off all the coding stuff, even the collision with rotated bounding boxes. It was received fairly well at the time because of its morbid concept, I remember years later seeing it featured on a showreel the University Games Design faculty played during open days for a few years after. I’ve gotten into doing game jams since that day, because there is a lot of creativity and drive to finish a game in a short amount of time, having to decide what’s worth implementing and what stuff needs to get polished.

The other one was Microsoft’s Windows Games Ambassadors, a programme that was set up to encourage students to build gamedev portfolios by writing games to Windows 8 and Windows Phone 8 and submitting them to Microsoft’s digital store. One of the requirements for the role was to make multiple games yourself to demonstrate and work on your own portfolio, so I made a couple such as BOOM, a game where you defend people from fireworks. There were a lot of good experiences I had worked as one of their ambassadors, from getting free devices (such as a Nokia Windows Phone which remained my smartphone for years) to attending events like EGX as one of Microsoft’s crew. It did give me an early look into building games for mobile devices in particular, as well as have early experiences with submitting games to storefronts (one that I’ll get more used to later on). I still get updates from other members of the team and almost all have worked in games in some capacity, such as with Unity, Playground Games and Supermassive, as well as other technical fields such as VR and Medical.

IBM

During the second year of University, most students were looking for an internship or student placement. At the time, games industry internships were hard to come by and often were available late into the year, so I started off by applying to big software companies. After a few rejections, I applied to IBM. I had a lot of help with the application process, from the University’s careers team to an old friend from Sixth Form (who was already working for IBM at the time) and my sister. I remember having to fill in application forms with answers that could be compiled into an essay and going to the Hursley offices for interviews, a presentation and multiple group exercises. I got accepted and decided to work at the Hursley office as it was their main software engineering hub in the UK starting in August 2013.

Despite the day-job having nothing to do with games (I worked in the RDM, which was one of their data management teams), the work environment was built to be relaxed enough that employees could spend half of their time in different parts of the building to attend other things like courses to pick up skills (I did a few C++ and PHP courses at the time), conferences, as well as events that ran to help the local community (called Givebacks). I did two of the more popular Givebacks, one was teaching a local primary school IT once a week and the other was making a game for a competition called Blue Fusion. I pitched a game called Clean Commuter where you learned programming by giving a car simple commands, with the goal of making the car reach a goal in the fewest possible moves. It became one of the selected games and I was appointed team lead, so along with assisting with writing the game’s visual side (other programmers worked on mechanics and network multiplayer parts) I also had to manage the team and make sure the game was ready in time for the competition. It was a struggle at first, but things got a lot more comfortable once a plan was put in motion and the work got into a routine.

Untitled-1

I was also working on Secret of Escape around that time, beginning as a game jam project with the premise of “What if there was a stealth game which you had to complete as fast as possible?” (I somehow forgot Metal Gear Solid: VR Missions had existed). Since I liked the concept I thought I’d make it a proper game. Because of my work at IBM, I had to keep the work outside of my spare time and hold back on releasing it, which did help in some areas. This was also the first game I made an attempt at showing in a public setting with the first Norwich Games Expo and the Indie Zone at London Gaming & Anime Con. I also did get to show the game unofficially at one of the early Indie Zones at Insomnia Gaming Festival, after I found the guy running it by chance and told him I was an indie game developer (networking was a funny thing back then). In retrospect, I’m not surprised the game didn’t do so well as it wasn’t exactly a game you could easily get into and hardly stood out. I also thought to add easter eggs that no one would find was a good idea, having one or two for a laugh is fine if they are easy to find with a bit of messing around but I put in a bunch that only I would know or someone if they had to dig through the project, Not to mention putting it on Desura and IndieGameStand not long before both services would shut down when Steam was starting to do Greenlight wasn’t a good decision, at least it’s still free on itch.io and was nominated for a games industry award. It’s also the time were two of my personal favourite solo game jam entries came from, Galaticus from GBJam and Glow Drop from Ludum Dare.

Final Year

After I finished my year at IBM, it was back to University for one last year. I did end up branching out a bit more by doing engine and multiplayer game development alongside more 3D programming. After spending most of my time with C# in the first two years, and Java in my placement year, I went almost entirely into C++ for the third year, with a few modules in C#. Two key projects at that time for me were the Junior/Senior project and the final year project.

The Junior/Senior project was Staffordshire University’s biggest game design course, with students from every games course (including Games Programming) being eligible to take. For the entire year, teams would make a single game. Each team was made up of sub-teams such as tech, art, design and sound, and each member had roles assigned to them, including a producer and director role. The team I was in was called Ironworks and after a few weeks of making concepts, we went with making an auto-runner where one player had to finish a course while the other player had to sabotage them. As I was the only person studying in Computer Games Programming in my team, I was assigned as a senior tech, meaning I worked under a lead tech and handled some of the more advanced parts of the game while the three junior techs worked on the less advanced parts. I remember our team being unfortunately unbalanced, as outside of the tech team and producers was one animator, one sound designer and mostly concept artists. Lack of animations were such a problem, that I took the initiative of writing small scripts to make the player look more animated when it moved. I remember the tech team joking that no matter what happened, our game was at least gonna look great. What made the course particularly special that year was that Epic Games sponsored the course and granted every student early access to Unreal Engine 4, so through the year we got new updates and would often raise issues with the engine that would get fixed in the following week if we were lucky.

It was also probably one of the longest and most intensive courses, being around four hours per week on a single day with an hour in-between, excluding any unscheduled sessions to get the game ready before the deadline. Because of my course having Junior/Senior technically being part of a separate module to every other course, I was only required to attend the first two hours whilst everyone else had to attend the four hours. After the first day, where I stayed home after finishing the first two hours, I ended up feeling bad for leaving everyone else to work so from the next week onwards I decided to stay for the entire four hours like everyone else, spending my hour break quickly going home to have a pizza before heading back to campus. Apparently, I was one of the few games programmers that actually did this, and maybe the others had other modules as a priority but I personally enjoyed spending four hours a week working on a big fancy looking game.

The Final Year project was the big chunk of the final year, as well as my degree. Everyone had to do a thesis on something related to the course they were on. I had a small interest growing in procedural content generation as the topic was growing in interest around the time (from Spelunky to No Man’s Sky), so I thought of using that as my topic. That quickly developed into level generation and an idea of building a tool that could help with generating levels. Doing a thesis required a lot of taking notes and writing down alongside with doing a project. I had to research a number of different algorithms and methods from academic papers and conference talks, alongside learning to use GUI, Unit Testing and file-format frameworks to create the tool. Thanks to the industrial placement at IBM, I got used to treating University more like a full-time job in some aspects, so even on days where there was little to no lectures or tutorials to attend, I’d go to campus in the morning and spend most of my time in the library until 5pm when I got home, made dinner and do stuff in the evenings. In the end, I had submitted an 80+ page bound essay with a fully functional level editor that used algorithms such as L-Systems, Hilbert Curves, Cellular Automata (plus ones I created myself) as well as a tiny demo where you had to find gemstones in a randomly generated cave. To this day I’m not sure what I’m more amazed by, either the fact that I was able to get it all done despite the thesis document getting corrupted, almost losing everything, and my computer exploding thanks to a faulty power supply (and accidentally damaging the hard drive twice when trying to fix my computer), or that I was able to get a first-class degree at the end of it all.

After I graduated, I was looking for work. I did get more rejections than I did when applying for an industrial placement, but I was given an offer to work for a company that made games in C++ using computer graphics on dedicated video betting hardware. I started working there in August 2015 and I’m still working there four and a half years on.

Gemstone Keeper

Going back to that little demo, I decided to look into it a bit more after graduation and kept working on it even after starting a new job. It was much different from what Gemstone Keeper ended up being, the exploration was much a part of it (because I wanted to demonstrate the level generation) but because I’m a fan of arcade shmups, the gameplay in that demo was much more rigid and focused on getting a high score than traversing caverns, collecting gemstones and finding the exit.

After I finished my thesis, I was getting more interested in roguelike games, where there is more of an emphasis on preserving your character and planning your route, as opposed to the games I typically play where you go straight in, guns blazing. As I got more into them, the more I felt I should focus on the exploration and the relaxed vibe, and was part of the reason why the game has its ASCII aesthetic. I’ve always had this concept of an arcade shmup combined with RPG elements in my mind, but I couldn’t get an idea for it to fit. Next thing I know, I play a few traditional roguelikes like Angband and DoomRL and suddenly, an idea just clicked.

There was a lot of experimentation and trial-and-error to get the ASCII art to look right, although I did anticipate that early on because I always like to develop a game where there was a considerable challenge that was a part of it. All the ASCII art is generated in-game using a single font file: the design of sprites, objects and walls were planned out and then I wrote out which characters should be rendered and where individually. Unfortunately with the nature of fonts, you cannot guarantee that the individual characters would be rendered in the right place, so eventually, I wrote out a function to print out all the generated textures so I could properly inspect them and make necessary adjustments.

Moving from the demo’s original framework of Allegro to SFML was a good move, in the long run, it’s a much nicer framework to work with. It also meant I had to structure the engine in order to get what I wanted. I take a lot of influence in my game engine architecture from Flixel (and it’s more modern equivalent HaxeFlixel) because I like how it’s built from simple pieces, where everything you see in the game is either a basic object, a physical object or a group like it’s purely the entity part of an entity-component system. Although I have tried to write a framework in the past with Ricoh2D, it was working on Gemstone Keeper and taking inspiration from HaxeFlixel that lead to Vigilante, my own game framework that I take pride in. I don’t believe creating your own engine yields an output superior to those who make games in a proprietary engine, but there is something I find satisfying in being able to control as much of your system as possible, to the point where you can find issues in the lower-level part and fix them as soon as possible.

I was worried through most of the Steam Greenlight experience since, despite the criticisms of the quality of most entries meaning the bar was pretty low, there was still that worry that not enough people would like the game enough for it to get through. Accepting an offer to be part of a Groupees bundle did help, even at the cost of the value of my game, as I feel that was mostly what got the game accepted onto the Steam store. It’s a shame that Steam has put less effort into quality control since dropping Greenlight for a direct fee. Despite a fairly rocky launch (I decided to launch the game a day before my birthday in 2017, whilst at Rezzed, and then ended up having to release several patches after I got back home because there were several bugs), I still feel like the game did really well. After all of my experience, I moderate my expectations, yet I was still chuffed to see statements saying how many copies were sold in the first few months.

I was aware of anticipated information on the upcoming generation of game consoles during University (PS4, Xbox One and Nintendo Switch), but it wasn’t until info came out about Nintendo Switch supporting OpenGL that I thought there was a possibility of bringing one of my own games to the console without the help of Unity or another game engine. It was about half a year after launch that I wrote a lengthy pitch about bringing over Gemstone Keeper for the Nintendo Switch, but I heard nothing. I did contemplate following up or trying again, as a few game developers I knew advised, but I wasn’t up for the possibility of radio silence. That was when I decided to do more game jams, particularly in 2018 where I did one game jam a month. Then in late 2018 I got an email from Nintendo asking if I still wanted to bring Gemstone Keeper to the Switch, I responded yes and so starting in 2019, I got my opportunity to develop games for a major games console.

Along with porting over SFML, I decided that the graphics need to be upgraded as the Switch was an HD console, so the game needed to be HD too. The game was originally built at half the 720p resolution, but upgrading involved more than just doubling the size of everything. All the positions, sizes, the movement calculations and other details had to be checked by hand, line by line. It was all worth it in the end.

I’ve gotten to show the efforts of the past year at two large game expos (the news of the latter blowing up on Reddit) and had my work written about in the game development magazine Wireframe.

What’s next?

The thing is, I’m honestly not sure. I said a few months earlier that I want to make my next game a Nintendo Switch exclusive, and I do have an idea or two, but even more than a month after accomplishing a goal that had been in my mind for 10 years, I’m struggling to find an answer to “What will I do now?” I’ll still maintain Gemstone Keeper as long as its necessary, and after only doing one Ludum Dare last year I want to get back into doing game jams, but right now I feel like I’ve just peaked a mountain. I think I’ll just find out where the wind will take me.

If there is anything that I want to show people from writing all this, is that getting to achieve your goals takes a lot of work. I’m as guilty as any other novice in his creative minefield in starting out expecting to make something much bigger than I was capable of. I needed good guidance, support and to take a lot of opportunities to get the experience I have today, and I’m nowhere near done. You might get lucky, but I wouldn’t rely on it. It might have taken 10 years for me to get a game onto a Nintendo console, but at least I have 10 years to look back on.

Time to see what the next 10 years will bring me.

Gemstone Keeper is out on the Nintendo Switch!

By the time you read this, Gemstone Keeper will be available for purchase on the Nintendo eShop in most of Europe, as well as Australia, New Zealand, Canada, Mexico and the United States!

Gemstone Keeper is an action twin-stick roguelike shooter where a brave explorer can traverse a large and mystical cavern to search for rare and precious gemstones. The deeper an explorer goes into the caverns, the more valuable gemstones that can be found, however at the risk of facing more of the dangerous and hostile creatures that live there, including creatures that are larger than life.

Armed only with a gun, explorers must break through rocks to collect minerals and gemstones and fight off the creatures, and find the portal that can help them go back up to sell what they collect or go further down.

Gemstone Keeper uses ASCII art in both a pure and diverse form, as almost every part of the game’s look come directly from text and symbols while very loose in form. The weapon and bullet system is fully interchangeable, over 150 gemstones to collect, several creatures and bosses, different game modes and a soundtrack that echoes through the open spaces in-between the rocky walls. Gemstone Keeper is the shooter that is both fun and eerie.

It is honestly just crazy for me to think that back when I started making games nearly 10 years ago, I wanted to make video games for one of the big consoles, and now I have achieved that goal! Any and all feedback will be great, and I’m just thankful for everyone who has helped in some way, from the SFML team for being helpful for technical issues I had, Vincent Rubinetti for coming on to produce the brilliant soundtrack, to Ironbell for reaching out to me with the idea of working together to bring SFML to the Nintendo Switch.

Gemstone Keeper (for the Switch) for the Public!

Hello everyone! It’s been a while, but my game development focus has been majorly on Gemstone Keeper for the Nintendo Switch! Significant progress has been made to it, plus Ironbell and I (as well as feedback from devs of Naezith) have been continuing our work on SFML-Switch, fixing issues that we find. The submission process is currently in its early stages and with any luck there will be an announcement on its release later this year.

The biggest areas of progress to Gemstone Keeper that have been made is that the Switch release has a local multiplayer mode called “Survival” where up to four players can fight an infinite amount of enemies until the last player dies.

Another big change to Gemstone Keeper is that the graphics have been significantly upgraded to a higher resolution to accomodate with the Switch’s HD displays. While it might seem strange to do this, but the painstaking process of using much larger fonts to generate the textures in the game results in a significantly sharper display overall. To the untrained eye it might not appear noticeable, but when compared side by side or in a split screenview, the differences become crystal clear (pun intended).

Back in June, the Switch port had a public test run at the Retro Revival Festival in Walsall (where I was also selling some games from my private collection). Despite some major technical difficulties, I managed to get some good feedback and players to try out the game, so I’d say it went pretty well!

From the event I also got to speak to Chris O’Regan from the video game podcast group Cane and Rinse, and after he got to have a go at the game and got in touch after the festival, he invited me on the Sausage Factory to talk about the game, as well as my development background and games design! I had a good time talking, although I usually get nervous when speaking in a mindset of having an audience, I like talking about my work and how I feel about games that show a more technical aspect over an artistic or epic approach to them. So if you have under an hour to spare, why not try hearing us talk for a bit?

Gemstone Keeper Episode of Sausage Factory

But that was back in June, what about now or next month? Well I’m happy to confirm that Gamepopper will be returning to the Indie Zone of Insomnia Gaming Festival as part of their i65 lineup (for the first time since i60 back in April 2017). Both myself and the game will be there for all four days of the festival, but do also come down for the rest of what indies have to offer.

There will be one more event in the near future where players can try out Gemstone Keeper, however I’m going to hold back on announcing it until after the final details get sorted.

 

Ludum Dare 44 and Console Game Development

As some of you were made aware, I took part in my first games jam of the year. While I said in my End of 2018 In Review that I’d be taking a break from game jams, Ludum Dare felt like the ideal event to take part in as it was in late April and is still one of the biggest and favourite of the online game jams. Even then I wasn’t fully aware it was happening until the week before when theme voting was about to begin, and it happened to be on the weekend where I had no urgent plans. So as the days drew nearer, I made my preperations for a 48-hour game dev session.

Continue reading

WizardJam – Re(re4ti0n

So June is almost over, and right now I’m writing as SGDQ is going on, but in the few weeks prior I was working on a game for my game-jam of June.

The game jam for this month is Wizard Jam, the seventh jam organised for the Idle Thumbs website and podcast. This was a jam that was fairly relaxed in comparison to most I take part in, being more than two weeks, with a very open themed convention. Instead of a singular theme, your theme is to choose from one of the many episode titles of the Idle Thumbs podcasts, which did take a while for me to pick, but I decided to choose one based on a little experimental project I was working on.

After being inspired from GDC earlier this year, I started work on a simple facial animation system to be used in the feature of a game. It used SFML’s primitive rendering system with interpolation and managed to get it to speak based on a simple string input. Wizard Jam gave me the opportunity to utilise it in a game with the theme “Read Our Lips” to test how effective it is.

The concept was a game where you were given quotes that are incomplete and corrupted, and your goal is to complete them based on your interpretation. The player had a short amount of time to enter their guess before being shown the next one. I went with giving the game a basic layout of an office, with a futuristic computer screen for the input and a faulty old looking monitor for the broken quotes. Thanks to SFML’s sf::Event::TextEntered, it’s incredibly easy to handle text input. It took less than a day to get the concept done, and an additional two days to get the initial layout done.

While I did take one day out to play around with the sfeMovie library, I spent most of the time polishing the existing game concept, improving the visuals and adding sound. I added camera movement so the text would be easier to see for a short amount of time. I updated the backgrounds so I could give a bit of a parallax effect.

The monitor was updated to use a lot of shaders, the title screen used the same amount of shaders. The main distortion shader was felixturner’s bad-tv-shader, combined with a fish-eye lens and scanline effect. I originally included a noise shader (as you can see in the previous tweet) but I found that darkened the colours so instead replaced it with the bloom shader that I’ve used in Berzerkatron and Gemstone Keeper. Finally, after some feedback, I added a simple chromatic aberration effect by offsetting the colour channels. It appeared to create an old and broken monitor effect that seemed to get some good impressions from people I showed it off on Discord servers.

There is no music for this game, just sound effects and ambient noise. Most of them were sourced from soniss’ GDC audio libraries, with some additional royalty free sounds for TVs and crowds. The name was kind of inspired by l33t speak, as I wanted to summarise the concept of the game (restoration/recreation) with the distortion you deal with.

The gameplay flow of having two minutes to guess as many quotes correctly was actually the last moment idea, originally you had to guess five random quotes with fifteen seconds each, but I felt that made the game too short for anyone finding it easy. One game dev on the Birmingham Indie Dev Discord suggested also making each quote progressively harder to start, but each would slowly become easier over a period of time. That way the game starts easy but gets difficult, but the currently displayed quote will slowly fix itself if you let it wait.

I was hoping to polish up the game a bit more over the weekend, but I went out to a party that unfortunately ended with the theft of one of my bags. While nothing game dev related was stolen, an expensive costume that I wear for public events was taken and it’s been reported to the authorities, although that didn’t stop the moment from dropping my emotional and motivational drive. I did get some last finishing touches done and missed the deadline by a few seconds, however the host was able to add Re(re4ti0n to the jam submission list the following morning.

You can play Re(re4ti0n by clicking the above image or right here.

SFML 2.5.0 Update (Or how I learned to hate RenderTextures)

 

 

On May 6th, the C++ Simple and Fast Media Library (or SFML for short) was updated to stable version 2.5.0, adding various updates including more optimial iOS support, bug fixes, added functionality for Text and Audio and various optimizations. For such a big release, it made sense to upgrade and get my Vigilante Game Framework updated, and why not update Gemstone Keeper while I’m at it?

Well it took nearly a month, but I did manage it in the end. Gemstone Keeper 1.0.5 has been uploaded to Steam, both for Windows and Linux!

As the title suggest, a lot of the work had to do with the updates to the sf::RenderTexture object. However, I don’t absolutely hate them, they are extremely useful for rendering a scene to an area of the screen, or to apply post-processing effects to. However the problem lied in how I was using them, and how the fixes done in the latest update effectively broke my engine’s rendering system.

The initial update showed promise, as my most recent game worked fine, but moving onto the framework’s examples and Gemstone Keeper showed that a lot of things weren’t rendering at all.

Vigilante Framework currently renders 3D models using Modern OpenGL, and while it was working fine with SFML 2.4.2, it rendered nothing with SFML 2.5.0. The solution was embarrassingly simple despite the amount of effort put into fixing it, including implementing my own version of SFML’s glCheck function and re-writing SFML’s own OpenGL example to run with modern OpenGL. When rendering the 3D scene, I modified some of the OpenGL states, which wouldn’t be an issue before but now those OpenGL states carry over into other contexts. The solution was to simply make sure that the GL states were reset BEFORE rendering the scene using a sprite object.

 ///Render 3D scene and apply to a sprite.
 RenderTarget.resetGLStates(); //Reset the GL states to the default for SFML
 Sprite->Draw(RenderTarget); //Render the sprite.

Gemstone Keeper however uses legacy OpenGL, and while I could have updated the VFrame source code but that could take more time to fix. Regardless, I was able to get it working by rearranging other objects that define sf::RenderTexture, including the bloom post processing effect and the help popup terminal.

Gemstone Keeper’s other graphics were another story. The approached I had been using up to this point was to render text objects onto a single rendertexture, and then store the generated texture to be used as a sprite, particle or tilemap. While this was okay for the time, but it is rather inefficient and bad for graphical memory.

I wanted to do a single-texture approach, where all the graphics are rendered onto a single texture, and a rectangle area is specified when creating renderable objects, for a while but I kept putting it off. SFML’s update, causing any newly created render textures to dereference generated textures, it was time to take this approach on. The best part is that most of the work was already done by myself with the additional code of Jukka Jylänki’s MaxRectBinPacker algorithm, all that needed doing was to change how I defined renderables from setting the texture to whatever the name of the genrated texture is to the name of one texture sheet, and to get the correct rectangle from a map/dictionary, searching by string ID.

CaptureCaptureCapture

Now this doesn’t mean the entire game’s visuals are rendered from one texture. Including the 3D gemstones, any assets that use a repeated texture grabs a subsection of the main texture as a copy, same applies to the VBackdrop as well. Getting the icon was a more painful looking process of converting the entire texture sheet to an sf::Image, so I can load in a subsection to a new sf::Texture object, and then convert the new texture object to an sf::Image in order to set it to be the application icon.

sf::IntRect iconArea = TextureData::p()->GetTextureRect(TextureData::p()->GetPortalTextureName(true));
 sf::Image image = VGlobal::p()->Content->LoadTexture("TextureSheet").copyToImage();
 sf::Texture tex;
 tex.loadFromImage(image, iconArea);
 VGlobal::p()->App->setIcon(iconArea.width, iconArea.height, tex.copyToImage().getPixelsPtr());

Like I said, not pretty.

So enjoy Gemstone Keeper, the number of you who own it. Now back to doing more stuff in C++…

Managing Content and the Joys of Smart Pointers

Hello everyone, I figured I’d write a post about something I’ve been working on for the last week or so, partly as a bit of advice for some budding programmer wanting to write a bit more low level games programming stuff, but also to try and explain why it has been several weeks since I last posted about a small prototype I’ve been working on, and why I have been posting less stuff on Twitter than usual.

To put it basically, a lot of C++ work, mostly involving Gemstone Keeper. I decided to go back to it one more time after a lot of bugs and feedback came in. By the time I’ve posted this, Gemstone Keeper has been updated to version 1.0.3, which includes bug fixes, UI updates and two new enemy types.

j7fcaz6

 

While most of this wasn’t planned (most of this would have happened much earlier if I was notified on Steam within days of it being reported), but it had been on mind for a particular reason.

To put it simply, I have been updating my C++ game framework, the Vigilante Game Framework. This is the framework that I had built up alongside the game it was made for, Gemstone Keeper, before open-sourcing it in the hopes that it could be improved for more projects. I noticed a problem with the content management system, and as such I had spent the last two weeks researching and implementing a new way that would make it more optimal while keeping it stable. Because of this, Gemstone Keeper will soon be updated with this improvement among other bug fixes, and any future games using the VFramework will feature this too.

dytc50n


Here is the original code for loading and setting an sf::Texture in my content system, according to the repository for Gemstone Keeper this was initally written around Feburary 2016, and aside from one change in April this remained how it was:

bool VContent::LoadTexture(const sf::String& name, sf::Texture &texture)
{
   if (FindTexture(name))
   {
      texture = textureDir[name];
      return true;
   }
   else
   {
      if (texture.loadFromFile(name))
      {
         VLog("%s loaded", name.toAnsiString().c_str());
         textureDir.insert(textureDir.begin(), std::pair<sf::String, sf::Texture>(name, texture));
         return true;
      }
   }

   VLog("Error loading texture: %s", name.toAnsiString().c_str());
   return false;
}

The approach should be fairly straightforward:

  • If a texture exists, set it to the texture object and return true.
  • If it doesn’t exist, load it using the texture object. Return true if load is successful.
  • If it cannot load, return false.

However there is one problem, setting the texture object doesn’t set the reference, despite passing the object in as a reference (hence the &). Instead it creates a copy, with a new texture ID and references.

Performance wise, this doesn’t have much of an issue, however memory wise there could be a concern with creating several sprites with the intention of using the same texture, but it isn’t. The intent of a content manager is to load, unload and store a single instance of an asset, with any objects merely referencing that content. I investigated a number of approaches (and spoke with eXpl0it3r of the SFML team) to find the right one.

The approach I finally went with required the following changes:

  • The load function should return the object itself as a non-pointer reference, not a bool. This is to ensure that if the loading or finding process goes wrong, the program should let you know and fail. The reason for a non-pointer is to ensure you wouldn’t return a NULL object. Returning a reference makes sure not to return a newly created copy.
  • If it cannot be loaded, an exception should be thrown. Exception handling is an ideal alternative to responding to function returning false, because it’ll make a function closing on failure much easier.
  • The texture should be stored as a unique pointer.

The reason for a unique pointer, instead of a regular or “raw” pointer, is to ensure that the object only has one true owner, and that once it’s dereferenced (either by closing the game or unloading it) it’ll be properly destroyed and unable to be used by other objects, all with little to no difference in performance. While a unique pointer cannot have more than one reference, the raw pointer can still be obtained and used, just make sure that once the content is unloaded there aren’t any active objects still referencing it.

This is what the texture loading function looks like now (from the Github Repository):

sf::Texture& VContent::LoadTexture(const sf::String& name)
{
   auto found = textureDir.find(name);
   if (found == textureDir.end())
   {
      std::unique_ptr<sf::Texture> texture = std::unique_ptr<sf::Texture>(new sf::Texture());
      if (texture->loadFromFile(name))
      {
         VBase::VLog("%s loaded", name.toAnsiString().c_str());
         textureDir[name] = std::move(texture);
      }
      else
      {
 #ifndef __linux__
         throw std::exception(("Error loading texture: " + name.toAnsiString()).c_str());
 #else
         throw ("Error loading texture: " + name.toAnsiString());
 #endif
      }
   }

   return *textureDir[name];
}

To use the functions in this format, I had to change a lot of objects around the game. Textures, Images, Fonts and SoundBuffers all changed to use raw pointers, and the returned values from the functions are converted to functions as well.

texture = &VGlobal::p()->Content->LoadTexture(filename);
sprite.setTexture(*texture);

This ensured that the object being set is has the same reference as the object being returned, no more copying data, no more instantiating new objects to handle the copy.

I’ve also turned a lot of other objects into unique pointers, particularly the objects in VGlobal, which is intended to only have one instance of. It’s ideal since these ones are all destroyed at the end, and in a scenario where an object could be replaced with another one, the unique pointer can destroy the old one in order to replace the new one.

Other small changes I’ve made to update the framework includes all objects that load textures now having an optional area rectangle. This was mainly put in if multiple sprites use the same texture, but different atlases. Best example would be in the LoadGraphic and setSize functions of VSprite, where the default parameter will ensure the whole texture is used, else the animation system will restrict the render area of the sprite to that rectangle. While sf::Texture does have the ability to load a rectangle area of a texture to an object, I feel like this only adds a separate texture, instead of the one loaded and taken from VContent. At some point I’d like to use this more for Gemstone Keeper and other games, as I see reducing the texture count and having more render calls using the same texture would have additional benefits, no matter how small.

Hopefully more changes like these will benefit games I make with this framework, I’d also like to use more smart pointers, maybe shared pointers for my general objects, but for the time being, I’ve got a project to get back to.