Share this project


Share this project

Captain your star ship and lead your squad of mecha pilots to victory.
Captain your star ship and lead your squad of mecha pilots to victory.
Captain your star ship and lead your squad of mecha pilots to victory.
1,217 backers pledged $44,039 to help bring this project to life.

Special Behind the Scenes Feature: Programming Sunrider (1)

Hey guys, Vaendryl here. Sam asked me to write something for the blog so here I go.

Word of warning though: being a coder writing code is kind of my thing. You can expect to see some in this post.

Let’s start at the beginning. I first heard about Sunrider during the kickstarter through /r/visualnovels on reddit and I was really impressed with the video, the music, the story, art and the fact there was even a demo. For a reason I’m not sure of myself I thought I’d send Sam a message through kickstarter offering my services. I told him I suck at writing, don’t know anything about music, can’t draw a picture to save my life and doubt I’d be useful as a voice actor but that I was sure there was something I could do for him as I did have an affinity with programming. I offered to perhaps do some bug testing or other boring menial labour so that Sam could focus more on the actual creative aspect of development.

Not long after I got a message back asking if I could completely rewrite his entire combat engine. Mind you, at this point I knew nothing about python or ren’py so my initial reaction could probably best be described as ‘lolwat’. I hadn’t even noticed that it says on the kickstarter page all the way at the bottom that they were looking for a programmer. Now, I’ve had some limited coding experience with various languages and tools but the only real (useful) things I ever made were in visual basic for applications (VBA), the language used in Excel and other MS Office software.

Idiot that I am I accepted. I learned python in a week or so on and learned renpy through online documentation and analyzing the Sunrider KS demo and the RPG framework for ren’py made by the very talented Jake Staines.
As it turns out the original demo had a battle engine where every fight was completely scripted from the ground up with liberal use of copy paste. To understand what I mean the best way is to show you. Compare the following 2 ways of recording a value in code, like the HP of a ship: enemy1_hp = 500
enemy2_hp = 500
enemy3_hp = 500
Samu's Note: What's wrong with copy pasta code? :(
Samu's Note: What's wrong with copy pasta code? :(

I think you will see that if you want to have 10 enemies in a battle this is going to take some writing. A slightly more advanced way would be to put the values into a list, like so: 

Create an empty list named HP_list
loop 10 times:
 each loop add a new value of 500 to HP_list

And suddenly we have a list with 10 times a value of 500 in it. Further down the line when an enemy is damaged we can change the corresponding value in this list. This saves some writing but more importantly you can have the loop repeat as many times as you want. It doesn’t have to be 10 times, it could be 20 times. Or more.

The original demo however didn’t use any loops. Didn’t use lists or functions. It definitely didn’t use custom classes. Classes are really nifty and very flexible concepts in programming. By defining your own class it is possible to refer to each ship on the battlefield as it’s own object which has a number of properties which can be easily set individually. For example, if I wanted to set the HP of the sunrider I can do so like this:

Sunrider.hp = 2000

But classes support more than just properties. It also allows you to define your own methods tied to an object. If I want to move the Sunrider to a different place on the battlefield I can do so like this: 


There are tons of advantages to this approach that are probably boring to most people so I’ll leave it at this.

After getting a handle on python and ren’py I set out to completely recreate the combat system used in the first demo based on this new data system. For one thing it allowed for a limitless number of player and enemy ships right away and it made it very easy to define and customize new ships. Especially setting up each battle in the game would be very easy. This very first rewrite took me a solid month to get anywhere but I made a lot of cool new features that weren’t in the demo. 

For example, my new engine implemented shields and armor, various buffs like damage and accuracy and environmental buffs that applied to everyone. It even implemented a lot of different weapon types and the concept of weapons with multiple shots. Every shot gets calculated separately and interacts differently with armor and shields. I also created some pretty complex code for missiles, because those can be shot down while traveling from attacker to target by other ships in between. I eventually released this old version as an April Fools joke about a day or 2 before we releases the real march beta.
This was the cutting edge in ye olden days.
This was the cutting edge in ye olden days.

Somewhere in mid January Sam decided he wanted to completely redesign the user interface. Although the core of my battle system wouldn’t be affected much by this it would still require some significant rewriting of what I had already made to account for the layout changes. It was at this point I pushed for the idea of changing the game to a 2d grid system instead of the 7 columns we had up to that point, as it would be now or never as I didn’t feel like having to rework the interface yet again after that. It would certainly be a massive challenge to write but the game would improve massively if we could manage to pull it off. Sam insisted we’d need a way to zoom in and out of the battle grid but I was skeptical it could even feasibly be done in ren’py. It’s really not something ren’py was made for!

As luck would have it though I did think of a way to do it and a quick proof of concept later I knew it could be done, so Sam gave the go ahead and I started building combat engine number 2. Next time I’ll write more about the various troubles and challenges we faced while taming that wild beast :3
It was a long journey here.
It was a long journey here.
Jeff Szudzik, Vaendryl, and 32 more people like this update.


    1. Creator LibraSweets on April 7, 2014

      Whoah, it's amazing how you were able to improve the system in such a short time! It's a huge step forward from the demo and looks great. As a code newbie, this is inspiring to read :3

    2. Creator Jozern on April 7, 2014

      Awesome job Vaendryl.

    3. Creator Joseph Perez on April 7, 2014

      I'm just so happy with how much the game has improved.
      I thought it was great playing the demo with the old battle UI, but after playing the recent beta it's just been nothing but one massive upgrade after another!
      Awesome update once again!

    4. Creator FlamingFirewire on April 6, 2014

      Great update! I love hearing about stuff like this!

    5. Creator Matthew Warren on April 6, 2014

      What Isaac Lee said.

    6. Creator Isaac Lee on April 6, 2014

      Please, grace us with more Python goodness!

    7. Creator Korruptor on April 6, 2014

      I understood it :)

    8. Creator Agus Hartono on April 6, 2014

      I'm just going to pretend that I understand most of today's update, and click "like" :D.